mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[DSOUND_NEW]
- Setup a default format for the primary sound buffer - Store last used write position and use it when checking current position - Check if the buffer has already started to play - Fill audio buffer with silence bytes when initializing the secondary sound buffer -- Partialy makes graphedit work when building a simple render graph(FileAsync->WaveParser->AudioRenderer). svn path=/trunk/; revision=45584
This commit is contained in:
parent
082d9c9fe7
commit
5974fe1781
3 changed files with 61 additions and 3 deletions
|
@ -15,7 +15,7 @@
|
||||||
#include <dsconf.h>
|
#include <dsconf.h>
|
||||||
#include <vfwmsgs.h>
|
#include <vfwmsgs.h>
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#define NDEBUG
|
#define YDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <ks.h>
|
#include <ks.h>
|
||||||
#include <ksmedia.h>
|
#include <ksmedia.h>
|
||||||
|
|
|
@ -100,6 +100,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetCaps(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCaps\n");
|
||||||
|
|
||||||
if (!pDSBufferCaps)
|
if (!pDSBufferCaps)
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -130,6 +132,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition\n");
|
||||||
|
|
||||||
if (This->dwLevel < DSSCL_PRIORITY)
|
if (This->dwLevel < DSSCL_PRIORITY)
|
||||||
{
|
{
|
||||||
/* needs priority level */
|
/* needs priority level */
|
||||||
|
@ -157,6 +161,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetFormat(
|
||||||
DWORD FormatSize;
|
DWORD FormatSize;
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFormat\n");
|
||||||
|
|
||||||
FormatSize = sizeof(WAVEFORMATEX) + This->Format.cbSize;
|
FormatSize = sizeof(WAVEFORMATEX) + This->Format.cbSize;
|
||||||
|
|
||||||
if (!pwfxFormat && !pdwSizeWritten)
|
if (!pwfxFormat && !pdwSizeWritten)
|
||||||
|
@ -199,6 +205,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetVolume(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetVolume\n");
|
||||||
|
|
||||||
if (!plVolume)
|
if (!plVolume)
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -219,6 +227,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetPan(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetPan\n");
|
||||||
|
|
||||||
if (!plPan)
|
if (!plPan)
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -239,6 +249,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetFrequency(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFrequency\n");
|
||||||
|
|
||||||
if (!pdwFrequency)
|
if (!pdwFrequency)
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -259,6 +271,8 @@ PrimaryDirectSoundBuffer8Impl_fnGetStatus(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetStatus\n");
|
||||||
|
|
||||||
if (!pdwStatus)
|
if (!pdwStatus)
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -312,6 +326,8 @@ PrimaryDirectSoundBuffer8Impl_fnPlay(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnPlay dwFlags %x\n", dwFlags);
|
||||||
|
|
||||||
if (dwReserved1 != 0 || !(dwFlags & DSBPLAY_LOOPING))
|
if (dwReserved1 != 0 || !(dwFlags & DSBPLAY_LOOPING))
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
|
@ -447,6 +463,8 @@ PrimaryDirectSoundBuffer8Impl_fnStop(
|
||||||
{
|
{
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
DPRINT("PrimaryDirectSoundBuffer8Impl_fnStop\n");
|
||||||
|
|
||||||
PrimaryDirectSoundBuffer_AcquireLock(iface);
|
PrimaryDirectSoundBuffer_AcquireLock(iface);
|
||||||
|
|
||||||
if (This->State == KSSTATE_RUN)
|
if (This->State == KSSTATE_RUN)
|
||||||
|
@ -631,9 +649,10 @@ PrimaryDirectSoundBuffer_GetPosition(
|
||||||
KSAUDIO_POSITION Position;
|
KSAUDIO_POSITION Position;
|
||||||
KSPROPERTY Request;
|
KSPROPERTY Request;
|
||||||
DWORD Result;
|
DWORD Result;
|
||||||
|
|
||||||
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface, CDirectSoundBuffer, lpVtbl);
|
||||||
|
|
||||||
|
//DPRINT("PrimaryDirectSoundBuffer_GetPosition\n");
|
||||||
|
|
||||||
if (!This->hPin)
|
if (!This->hPin)
|
||||||
{
|
{
|
||||||
if (pdwCurrentPlayCursor)
|
if (pdwCurrentPlayCursor)
|
||||||
|
@ -770,6 +789,15 @@ NewPrimarySoundBuffer(
|
||||||
This->VolumePan = DSBPAN_CENTER;
|
This->VolumePan = DSBPAN_CENTER;
|
||||||
This->hPin = NULL;
|
This->hPin = NULL;
|
||||||
|
|
||||||
|
/* FIXME: determine default format for audio device */
|
||||||
|
This->Format.cbSize = sizeof(WAVEFORMATEX);
|
||||||
|
This->Format.nChannels = 2;
|
||||||
|
This->Format.nSamplesPerSec = 44100;
|
||||||
|
This->Format.wBitsPerSample = 16;
|
||||||
|
This->Format.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
This->Format.nBlockAlign = (This->Format.nChannels * This->Format.wBitsPerSample) / 8;
|
||||||
|
This->Format.nAvgBytesPerSec = (This->Format.nChannels * This->Format.nSamplesPerSec * This->Format.wBitsPerSample) / 8;
|
||||||
|
|
||||||
InitializeCriticalSection(&This->Lock);
|
InitializeCriticalSection(&This->Lock);
|
||||||
|
|
||||||
*OutBuffer = (LPDIRECTSOUNDBUFFER8)&This->lpVtbl;
|
*OutBuffer = (LPDIRECTSOUNDBUFFER8)&This->lpVtbl;
|
||||||
|
|
|
@ -19,6 +19,7 @@ typedef struct
|
||||||
DWORD dwLevel;
|
DWORD dwLevel;
|
||||||
DWORD dwFlags;
|
DWORD dwFlags;
|
||||||
DWORD dwFrequency;
|
DWORD dwFrequency;
|
||||||
|
DWORD BufferPosition;
|
||||||
LONG Volume;
|
LONG Volume;
|
||||||
LONG VolumePan;
|
LONG VolumePan;
|
||||||
LPWAVEFORMATEX Format;
|
LPWAVEFORMATEX Format;
|
||||||
|
@ -135,7 +136,12 @@ SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition(
|
||||||
|
|
||||||
//DPRINT("SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition This %p Play %p Write %p\n", This, pdwCurrentPlayCursor, pdwCurrentWriteCursor);
|
//DPRINT("SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition This %p Play %p Write %p\n", This, pdwCurrentPlayCursor, pdwCurrentWriteCursor);
|
||||||
|
|
||||||
return PrimaryDirectSoundBuffer_GetPosition(This->PrimaryBuffer, pdwCurrentPlayCursor, pdwCurrentWriteCursor);
|
if (pdwCurrentWriteCursor)
|
||||||
|
{
|
||||||
|
*pdwCurrentWriteCursor = This->BufferPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PrimaryDirectSoundBuffer_GetPosition(This->PrimaryBuffer, pdwCurrentPlayCursor, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
|
@ -322,6 +328,12 @@ SecondaryDirectSoundBuffer8Impl_fnLock(
|
||||||
|
|
||||||
*ppvAudioPtr1 = This->Buffer + dwOffset;
|
*ppvAudioPtr1 = This->Buffer + dwOffset;
|
||||||
*pdwAudioBytes1 = dwBytes;
|
*pdwAudioBytes1 = dwBytes;
|
||||||
|
|
||||||
|
This->BufferPosition = dwOffset + dwBytes;
|
||||||
|
|
||||||
|
if (This->BufferPosition == This->BufferSize)
|
||||||
|
This->BufferPosition = 0;
|
||||||
|
|
||||||
if (ppvAudioPtr2)
|
if (ppvAudioPtr2)
|
||||||
*ppvAudioPtr2 = NULL;
|
*ppvAudioPtr2 = NULL;
|
||||||
if (pdwAudioBytes2)
|
if (pdwAudioBytes2)
|
||||||
|
@ -351,6 +363,13 @@ SecondaryDirectSoundBuffer8Impl_fnPlay(
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
ASSERT(dwFlags & DSBPLAY_LOOPING);
|
ASSERT(dwFlags & DSBPLAY_LOOPING);
|
||||||
|
|
||||||
|
|
||||||
|
if (This->State == KSSTATE_RUN)
|
||||||
|
{
|
||||||
|
/* sound buffer is already playing */
|
||||||
|
return DS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* set dataformat */
|
/* set dataformat */
|
||||||
hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, TRUE);
|
hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, TRUE);
|
||||||
|
|
||||||
|
@ -371,6 +390,8 @@ SecondaryDirectSoundBuffer8Impl_fnPlay(
|
||||||
PrimaryDirectSoundBuffer_ReleaseLock(This->PrimaryBuffer);
|
PrimaryDirectSoundBuffer_ReleaseLock(This->PrimaryBuffer);
|
||||||
|
|
||||||
DPRINT("SetFormatSuccess PrimaryBuffer %p\n", This->PrimaryBuffer);
|
DPRINT("SetFormatSuccess PrimaryBuffer %p\n", This->PrimaryBuffer);
|
||||||
|
This->State = KSSTATE_RUN;
|
||||||
|
|
||||||
return DS_OK;
|
return DS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +502,13 @@ SecondaryDirectSoundBuffer8Impl_fnStop(
|
||||||
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_ACQUIRE);
|
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_ACQUIRE);
|
||||||
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_STOP);
|
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_STOP);
|
||||||
|
|
||||||
|
DPRINT("SecondaryDirectSoundBuffer8Impl_fnStop\n");
|
||||||
|
|
||||||
|
|
||||||
|
/* set state to stop */
|
||||||
|
This->State = KSSTATE_STOP;
|
||||||
|
This->BufferPosition = 0;
|
||||||
|
|
||||||
return DS_OK;
|
return DS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +647,8 @@ NewSecondarySoundBuffer(
|
||||||
return DSERR_OUTOFMEMORY;
|
return DSERR_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fill buffer with silence */
|
||||||
|
FillMemory(This->Buffer, lpcDSBufferDesc->dwBufferBytes, lpcDSBufferDesc->lpwfxFormat->wBitsPerSample == 8 ? 0x80 : 0);
|
||||||
|
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
This->lpVtbl = &vt_DirectSoundBuffer8;
|
This->lpVtbl = &vt_DirectSoundBuffer8;
|
||||||
|
|
Loading…
Reference in a new issue