Fixed duplicate sound buffer handling. Updated status.
This commit is contained in:
parent
26cae9dd30
commit
689b9f8993
|
@ -253,6 +253,7 @@ struct IDirectSoundBuffer {
|
||||||
ULONG freqAdjust;
|
ULONG freqAdjust;
|
||||||
LONG volume,pan;
|
LONG volume,pan;
|
||||||
LONG lVolAdjust,rVolAdjust;
|
LONG lVolAdjust,rVolAdjust;
|
||||||
|
LPDIRECTSOUNDBUFFER parent; /* for duplicates */
|
||||||
LPDIRECTSOUND dsound;
|
LPDIRECTSOUND dsound;
|
||||||
DSBUFFERDESC dsbd;
|
DSBUFFERDESC dsbd;
|
||||||
LPDSBPOSITIONNOTIFY notifies;
|
LPDSBPOSITIONNOTIFY notifies;
|
||||||
|
|
|
@ -8,10 +8,22 @@
|
||||||
* implement the stuff in a single thread anyway. And most DirectX apps
|
* implement the stuff in a single thread anyway. And most DirectX apps
|
||||||
* require threading themselves.
|
* require threading themselves.
|
||||||
*
|
*
|
||||||
* FIXME: This file is full of race conditions and unlocked variable access
|
* Most thread locking is complete. There may be a few race
|
||||||
* from two threads. But we usually don't need to bother.
|
* conditions still lurking.
|
||||||
*
|
*
|
||||||
* Tested with a Soundblaster clone and a Gravis UltraSound Classic.
|
* Tested with a Soundblaster clone, a Gravis UltraSound Classic,
|
||||||
|
* and a Turtle Beach Tropez+.
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* Implement DirectSoundCapture API
|
||||||
|
* Implement SetCooperativeLevel properly (need to address focus issues)
|
||||||
|
* Use wavetable synth for static buffers if available
|
||||||
|
* Implement DirectSound3DBuffers (stubs in place)
|
||||||
|
* Use hardware 3D support if available (OSS support may be needed first)
|
||||||
|
* Add support for APIs other than OSS: ALSA (http://alsa.jcu.cz/)
|
||||||
|
* and esound (http://www.gnome.org), for instance
|
||||||
|
*
|
||||||
|
* FIXME: Status needs updating.
|
||||||
*
|
*
|
||||||
* Status:
|
* Status:
|
||||||
* - Wing Commander 4/W95:
|
* - Wing Commander 4/W95:
|
||||||
|
@ -27,6 +39,16 @@
|
||||||
* The background sound of the startscreen works ;)
|
* The background sound of the startscreen works ;)
|
||||||
* - WingCommander Prophecy Demo:
|
* - WingCommander Prophecy Demo:
|
||||||
* Sound works for the intromovie.
|
* Sound works for the intromovie.
|
||||||
|
* - Total Annihilation (1998/12/04):
|
||||||
|
* Sound plays perfectly in the game, but the Smacker movies
|
||||||
|
* (http://www.smacker.com/) play silently.
|
||||||
|
* - A-10 Cuba! Demo (1998/12/04):
|
||||||
|
* Sound works properly (for some people).
|
||||||
|
* - dsstream.exe, from DirectX 5.2 SDK (1998/12/04):
|
||||||
|
* Works properly, but requires "-dll -winmm".
|
||||||
|
* - dsshow.exe, from DirectX 5.2 SDK (1998/12/04):
|
||||||
|
* Initializes the DLL properly with CoCreateInstance(), but the
|
||||||
|
* FileOpen dialog box is broken - could not test properly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -46,11 +68,15 @@
|
||||||
#include "objbase.h"
|
#include "objbase.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "xmalloc.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_OSS
|
#ifdef HAVE_OSS
|
||||||
|
# include <sys/ioctl.h>
|
||||||
#include <sys/ioctl.h>
|
# ifdef HAVE_MACHINE_SOUNDCARD_H
|
||||||
|
# include <machine/soundcard.h>
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_SYS_SOUNDCARD_H
|
||||||
|
# include <sys/soundcard.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
/* #define USE_DSOUND3D 1 */
|
/* #define USE_DSOUND3D 1 */
|
||||||
|
|
||||||
|
@ -70,10 +96,18 @@ static void DSOUND_CloseAudio(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HRESULT WINAPI DirectSoundEnumerate32A(LPDSENUMCALLBACK32A enumcb,LPVOID context) {
|
HRESULT WINAPI DirectSoundEnumerate32A(
|
||||||
|
LPDSENUMCALLBACK32A enumcb,
|
||||||
|
LPVOID context)
|
||||||
|
{
|
||||||
|
TRACE(dsound, "enumcb = %p, context = %p\n", enumcb, context);
|
||||||
|
|
||||||
#ifdef HAVE_OSS
|
#ifdef HAVE_OSS
|
||||||
enumcb(NULL,"WINE DirectSound using Open Sound System","sound",context);
|
if (enumcb != NULL)
|
||||||
|
enumcb(NULL,"WINE DirectSound using Open Sound System",
|
||||||
|
"sound",context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,7 +855,13 @@ static DWORD WINAPI IDirectSoundBuffer_Release(LPDIRECTSOUNDBUFFER this) {
|
||||||
if (this->ds3db && this->ds3db->lpvtbl)
|
if (this->ds3db && this->ds3db->lpvtbl)
|
||||||
this->ds3db->lpvtbl->fnRelease(this->ds3db);
|
this->ds3db->lpvtbl->fnRelease(this->ds3db);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),0,this->buffer);
|
if (this->parent)
|
||||||
|
/* this is a duplicate buffer */
|
||||||
|
this->parent->lpvtbl->fnRelease(this->parent);
|
||||||
|
else
|
||||||
|
/* this is a toplevel buffer */
|
||||||
|
HeapFree(GetProcessHeap(),0,this->buffer);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),0,this);
|
HeapFree(GetProcessHeap(),0,this);
|
||||||
|
|
||||||
if (this == primarybuf)
|
if (this == primarybuf)
|
||||||
|
@ -836,6 +876,7 @@ static HRESULT WINAPI IDirectSoundBuffer_GetCurrentPosition(
|
||||||
TRACE(dsound,"(%p,%p,%p)\n",this,playpos,writepos);
|
TRACE(dsound,"(%p,%p,%p)\n",this,playpos,writepos);
|
||||||
if (playpos) *playpos = this->playpos;
|
if (playpos) *playpos = this->playpos;
|
||||||
if (writepos) *writepos = this->writepos;
|
if (writepos) *writepos = this->writepos;
|
||||||
|
TRACE(dsound, "playpos = %ld, writepos = %ld\n", *playpos, *writepos);
|
||||||
return DS_OK;
|
return DS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1172,6 +1213,7 @@ static HRESULT WINAPI IDirectSound_CreateSoundBuffer(
|
||||||
/* we allocated this structure with HEAP_ZERO_MEMORY... */
|
/* we allocated this structure with HEAP_ZERO_MEMORY... */
|
||||||
(*ppdsb)->playpos = 0;
|
(*ppdsb)->playpos = 0;
|
||||||
(*ppdsb)->writepos = 0;
|
(*ppdsb)->writepos = 0;
|
||||||
|
(*ppdsb)->parent = NULL;
|
||||||
(*ppdsb)->lpvtbl = &dsbvt;
|
(*ppdsb)->lpvtbl = &dsbvt;
|
||||||
(*ppdsb)->dsound = this;
|
(*ppdsb)->dsound = this;
|
||||||
(*ppdsb)->playing = 0;
|
(*ppdsb)->playing = 0;
|
||||||
|
@ -1200,7 +1242,7 @@ static HRESULT WINAPI IDirectSound_CreateSoundBuffer(
|
||||||
|
|
||||||
InitializeCriticalSection(&((*ppdsb)->lock));
|
InitializeCriticalSection(&((*ppdsb)->lock));
|
||||||
|
|
||||||
#if 0
|
#if USE_DSOUND3D
|
||||||
if (dsbd->dwFlags & DSBCAPS_CTRL3D) {
|
if (dsbd->dwFlags & DSBCAPS_CTRL3D) {
|
||||||
IDirectSound3DBuffer *ds3db;
|
IDirectSound3DBuffer *ds3db;
|
||||||
|
|
||||||
|
@ -1245,14 +1287,13 @@ static HRESULT WINAPI IDirectSound_DuplicateSoundBuffer(
|
||||||
|
|
||||||
*ppdsb = (LPDIRECTSOUNDBUFFER)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundBuffer));
|
*ppdsb = (LPDIRECTSOUNDBUFFER)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundBuffer));
|
||||||
|
|
||||||
(*ppdsb)->ref =1;
|
pdsb->lpvtbl->fnAddRef(pdsb);
|
||||||
(*ppdsb)->buffer = (LPBYTE)HeapAlloc(GetProcessHeap(),0,pdsb->buflen);
|
memcpy(*ppdsb, pdsb, sizeof(IDirectSoundBuffer));
|
||||||
memcpy((*ppdsb)->buffer,pdsb->buffer,pdsb->buflen);
|
(*ppdsb)->ref = 1;
|
||||||
(*ppdsb)->buflen = pdsb->buflen;
|
|
||||||
(*ppdsb)->playpos = 0;
|
(*ppdsb)->playpos = 0;
|
||||||
(*ppdsb)->writepos = 0;
|
(*ppdsb)->writepos = 0;
|
||||||
(*ppdsb)->lpvtbl = &dsbvt;
|
|
||||||
(*ppdsb)->dsound = this;
|
(*ppdsb)->dsound = this;
|
||||||
|
(*ppdsb)->parent = pdsb;
|
||||||
memcpy(&((*ppdsb)->wfx), &(pdsb->wfx), sizeof((*ppdsb)->wfx));
|
memcpy(&((*ppdsb)->wfx), &(pdsb->wfx), sizeof((*ppdsb)->wfx));
|
||||||
/* register buffer */
|
/* register buffer */
|
||||||
this->buffers = (LPDIRECTSOUNDBUFFER*)HeapReAlloc(GetProcessHeap(),0,this->buffers,sizeof(LPDIRECTSOUNDBUFFER)*(this->nrofbuffers+1));
|
this->buffers = (LPDIRECTSOUNDBUFFER*)HeapReAlloc(GetProcessHeap(),0,this->buffers,sizeof(LPDIRECTSOUNDBUFFER)*(this->nrofbuffers+1));
|
||||||
|
@ -1417,6 +1458,9 @@ static struct tagLPDIRECTSOUND_VTABLE dsvt = {
|
||||||
IDirectSound_Initialize
|
IDirectSound_Initialize
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* See http://www.opensound.com/pguide/audio.html for more details */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
DSOUND_setformat(LPWAVEFORMATEX wfex) {
|
DSOUND_setformat(LPWAVEFORMATEX wfex) {
|
||||||
int xx,channels,speed,format,nformat;
|
int xx,channels,speed,format,nformat;
|
||||||
|
|
Loading…
Reference in New Issue