IDirectSoundBuffer::SetVolume()

Discussion in 'Bug Reports' started by kode54, Oct 6, 2003.

  1. kode54

    kode54 New Member

    Joined:
    Oct 31, 2002
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    Is it supposed to only work with the front left/right channels? If I create the buffer with the DSBCAPS_LOCSOFTWARE flag set, the SetVolume function works on all channels.
     
  2. Eugene Gavrilov

    Eugene Gavrilov kX Project Lead Programmer and Coordinator

    Joined:
    Dec 7, 2002
    Messages:
    3,146
    Likes Received:
    9
    Trophy Points:
    48
    hmm.. that's strange
    in user level there are no parameters for the SetVolume method
    however, in =kernel= level the SetVolume function accepts a 'channel' parameter
    and this parameter is 0..1, not 0..5...
    sometimes it is =-1 (which means 'all the channels' -- and kX supports this)
    that is, the kernel part of the direct sound engine doesn't wish to call provide our driver with the correct 'channel'..

    please let me know if you find anything about this issue...
    (and, btw, after some of =my= tests, I found out (well, it was long time ago) that software mixing behaves the same way -- at least, with WinDVD and similar tools)

    /E
     
  3. kode54

    kode54 New Member

    Joined:
    Oct 31, 2002
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    User-level.

    The buffer is created with 1, 2, 4, or 6 channels, using the flags DSBCAPS_GETCURRENTPOSITION2, DSBCAPS_STICKYFOCUS, and DSBCAPS_GLOBALFOCUS, and a WAVEFORMATEX structure defining the sample format. If creation fails, it copies WAVEFORMATEX to a WAVEFORMATEXTENSIBLE struct and adds a channel mask, KS_SPEAKER_MONO, STEREO, QUAD, or 5POINT1, depending on the number of channels.
     
  4. Eugene Gavrilov

    Eugene Gavrilov kX Project Lead Programmer and Coordinator

    Joined:
    Dec 7, 2002
    Messages:
    3,146
    Likes Received:
    9
    Trophy Points:
    48
    >> If creation fails, it copies WAVEFORMATEX to a WAVEFORMATEXTENSIBLE

    well, I think it should be done in reversed order...

    but, anyway, I've added a 'compatibility' flag in the very recent driver release (3535rc2)
    this flag is set by default
    you can turn it off by running kxctrl -shw 18 <value>, where:
    <value>
    |= 0x100 -- clear the flag
    0,1,2,3,4 -- preferred spatialization method (0 is the default; 4 - is 8-point -- for headphones)

    ===

    I've double checked all the calls received by the driver -- the multichannel applications don't wish to set-up the volume for any channel>=2 -- and this is strange (according to WinXP DDK)

    /E
     
  5. kode54

    kode54 New Member

    Joined:
    Oct 31, 2002
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    The application I am referring to is Foobar2000's fading DirectSound 2.0 output, which fades out its streams on seek, pause, and stop. A binary version of this output is included with the 0.7.1 beta installer located here. (Directory link in case there's a new beta before you see this.)

    Most of the code in the standard DirectSound output is identical to the new output, except for the lack of SetVolume related code, since only the fading actually uses it. The source code to foo_output_std is included with the SDK. You'll have to ask Peter why he opted to try WAVEFORMATEXTENSIBLE after WAVEFORMATEX. Maybe its because its only a fallback, since it shouldn't be necessary for the generic 1/2/4/6 setups supported.

    As for supporting >2 channel volume changing, as I said, this user-mode application is calling SetVolume, which only has a volume level parameter. Is the software supposed to create a 2 channel buffer for each pair of channels, and then try to ensure sample-exact synchronization between them all?
     
    Last edited: Oct 7, 2003
  6. Eugene Gavrilov

    Eugene Gavrilov kX Project Lead Programmer and Coordinator

    Joined:
    Dec 7, 2002
    Messages:
    3,146
    Likes Received:
    9
    Trophy Points:
    48
    >> try WAVEFORMATEXTENSIBLE after WAVEFORMATEX

    as far as I remember, WAVEFORMATEXTENSIBLE is not required, while WAVEFORMAT(EX) is --
    so, the new 'extensible' structure will never be used (since most drivers support EX version)

    /E
     
  7. Eugene Gavrilov

    Eugene Gavrilov kX Project Lead Programmer and Coordinator

    Joined:
    Dec 7, 2002
    Messages:
    3,146
    Likes Received:
    9
    Trophy Points:
    48
    >> as for supporting >2 channel volume changing, as I said, this user-mode application is calling SetVolume, which only
    >> has a volume level parameter

    yes, I know
    there seems to be either a 'gap' in the DDK (it doesn't mention that the driver should set all the channels), or it is a bug in DirectSound...
    or, under 'some-unknown-circumstances' DirectSound changes all the channels... who knows?.. :)

    anyway, 3535rc2 supports multichannel volume
    (btw, according to the logs, it still receives two calls: one for '0 channel' and another for '1 channel' -- even if there are 5.1 channels opened...)

    /Eugene
     
  8. kode54

    kode54 New Member

    Joined:
    Oct 31, 2002
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    I get this debug info for volume changes on 2 channel buffers:

    kx_lib:
    !! invalid ch(2) in audio_set_param [vol]
    kx_lib:
    !! invalid ch(4) in audio_set_param [vol]
     
  9. Eugene Gavrilov

    Eugene Gavrilov kX Project Lead Programmer and Coordinator

    Joined:
    Dec 7, 2002
    Messages:
    3,146
    Likes Received:
    9
    Trophy Points:
    48
    ah, ok

    I've added a 'hack' but haven't added a special check for 'generic' stereo voices :)
    these messages should not affect anything (they are just warnings)

    anyway, the 3535rc2 driver [the present one], even if displaying such messages, should not cause any problems with multichannel playback

    /E
     

Share This Page

visited