PDA

View Full Version : Sharing 1 sound buffer between 2 DirectSound objects


code2K
06-24-2006, 08:32 PM
Hello, I am sending the same music to 2 sound cards simultaneously. I'm using a Direct Sound object per sound card and a Primary and obligatory Secondary buffer on each of these. I would like to economise on mem usage by using the DuplicateBuffer() call to share secondary sound buffer memory, but DuplicateBuffer() fails because the buffers are on separate DirectSound objects. Has anyone heard of a solution to this problem? - perhaps I should create a Primary Buffer with write access on one sound card and just stream the sound to it as the other device plays??? But this seems unnecessarily complicated. Any ideas welcome.

Jare
06-25-2006, 08:39 AM
Perhaps there is some way to coerce DirectSound into accepting a SoundBuffer that uses an user-supplied buffer (in software mixing mode, obviously), but I don't see such a capability in the DSBUFFERDESC struct.

juhnu
06-26-2006, 12:46 AM
Are you trying to stream the music to both devices? In that case the buffer sizes are meaningless, as you need only a one buffer per device.

If that's not the case and you really need to lower the memory usage, you could do the mixing in software and then stream the mixed audio to both devices.

code2K
06-26-2006, 03:12 PM
Yes. I've have tried this by using the DSBCAPS_LOCSOFTWARE flag when creating the buffers but unfortunately DuplicateSoundBuffer() only returns successfully (with a duplicated buffer that shares mem of the original)when the buffer being duplicated and the original buffer are on the same DirectSound object(ie the same sound card). Tricky.

code2K
06-26-2006, 03:29 PM
Yes. Maybe mixing in the software is the only way but ideally I would like to keep the mixing done on the hardware as well.