Author: janderwald
Date: Fri Feb 12 10:54:56 2010
New Revision: 45584
URL:
http://svn.reactos.org/svn/reactos?rev=45584&view=rev
Log:
[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).
Modified:
trunk/reactos/dll/directx/dsound_new/precomp.h
trunk/reactos/dll/directx/dsound_new/primary.c
trunk/reactos/dll/directx/dsound_new/secondary.c
Modified: trunk/reactos/dll/directx/dsound_new/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/pre…
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/precomp.h [iso-8859-1] Fri Feb 12 10:54:56 2010
@@ -15,7 +15,7 @@
#include <dsconf.h>
#include <vfwmsgs.h>
#include <setupapi.h>
-#define NDEBUG
+#define YDEBUG
#include <debug.h>
#include <ks.h>
#include <ksmedia.h>
Modified: trunk/reactos/dll/directx/dsound_new/primary.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/pri…
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/primary.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/primary.c [iso-8859-1] Fri Feb 12 10:54:56 2010
@@ -100,6 +100,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCaps\n");
+
if (!pDSBufferCaps)
{
/* invalid parameter */
@@ -130,6 +132,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition\n");
+
if (This->dwLevel < DSSCL_PRIORITY)
{
/* needs priority level */
@@ -156,6 +160,8 @@
{
DWORD FormatSize;
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFormat\n");
FormatSize = sizeof(WAVEFORMATEX) + This->Format.cbSize;
@@ -199,6 +205,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetVolume\n");
+
if (!plVolume)
{
/* invalid parameter */
@@ -219,6 +227,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetPan\n");
+
if (!plPan)
{
/* invalid parameter */
@@ -239,6 +249,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFrequency\n");
+
if (!pdwFrequency)
{
/* invalid parameter */
@@ -258,6 +270,8 @@
LPDWORD pdwStatus)
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetStatus\n");
if (!pdwStatus)
{
@@ -312,6 +326,8 @@
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnPlay dwFlags %x\n", dwFlags);
+
if (dwReserved1 != 0 || !(dwFlags & DSBPLAY_LOOPING))
{
/* invalid parameter */
@@ -446,6 +462,8 @@
LPDIRECTSOUNDBUFFER8 iface)
{
LPCDirectSoundBuffer This = (LPCDirectSoundBuffer)CONTAINING_RECORD(iface,
CDirectSoundBuffer, lpVtbl);
+
+ DPRINT("PrimaryDirectSoundBuffer8Impl_fnStop\n");
PrimaryDirectSoundBuffer_AcquireLock(iface);
@@ -631,8 +649,9 @@
KSAUDIO_POSITION Position;
KSPROPERTY Request;
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)
{
@@ -770,6 +789,15 @@
This->VolumePan = DSBPAN_CENTER;
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);
*OutBuffer = (LPDIRECTSOUNDBUFFER8)&This->lpVtbl;
Modified: trunk/reactos/dll/directx/dsound_new/secondary.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/sec…
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/secondary.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/secondary.c [iso-8859-1] Fri Feb 12 10:54:56
2010
@@ -19,6 +19,7 @@
DWORD dwLevel;
DWORD dwFlags;
DWORD dwFrequency;
+ DWORD BufferPosition;
LONG Volume;
LONG VolumePan;
LPWAVEFORMATEX Format;
@@ -135,7 +136,12 @@
//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
@@ -322,6 +328,12 @@
*ppvAudioPtr1 = This->Buffer + dwOffset;
*pdwAudioBytes1 = dwBytes;
+
+ This->BufferPosition = dwOffset + dwBytes;
+
+ if (This->BufferPosition == This->BufferSize)
+ This->BufferPosition = 0;
+
if (ppvAudioPtr2)
*ppvAudioPtr2 = NULL;
if (pdwAudioBytes2)
@@ -350,6 +362,13 @@
/* sanity check */
ASSERT(dwFlags & DSBPLAY_LOOPING);
+
+
+ if (This->State == KSSTATE_RUN)
+ {
+ /* sound buffer is already playing */
+ return DS_OK;
+ }
/* set dataformat */
hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format,
TRUE);
@@ -371,6 +390,8 @@
PrimaryDirectSoundBuffer_ReleaseLock(This->PrimaryBuffer);
DPRINT("SetFormatSuccess PrimaryBuffer %p\n", This->PrimaryBuffer);
+ This->State = KSSTATE_RUN;
+
return DS_OK;
}
@@ -480,6 +501,13 @@
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_PAUSE);
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_ACQUIRE);
PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_STOP);
+
+ DPRINT("SecondaryDirectSoundBuffer8Impl_fnStop\n");
+
+
+ /* set state to stop */
+ This->State = KSSTATE_STOP;
+ This->BufferPosition = 0;
return DS_OK;
}
@@ -619,6 +647,8 @@
return DSERR_OUTOFMEMORY;
}
+ /* fill buffer with silence */
+ FillMemory(This->Buffer, lpcDSBufferDesc->dwBufferBytes,
lpcDSBufferDesc->lpwfxFormat->wBitsPerSample == 8 ? 0x80 : 0);
This->ref = 1;
This->lpVtbl = &vt_DirectSoundBuffer8;