[ros-diffs] [janderwald] 43946: - Add sanity checks - Implement IDirectSoundCaptureBuffer8::Stop - Implement changing the stream format for secondary buffers - Silence debug flood

janderwald at svn.reactos.org janderwald at svn.reactos.org
Wed Nov 4 03:16:49 CET 2009


Author: janderwald
Date: Wed Nov  4 03:16:49 2009
New Revision: 43946

URL: http://svn.reactos.org/svn/reactos?rev=43946&view=rev
Log:
- Add sanity checks
- Implement IDirectSoundCaptureBuffer8::Stop
- Implement changing the stream format for secondary buffers
- Silence debug flood


Modified:
    trunk/reactos/dll/directx/dsound_new/capturebuffer.c
    trunk/reactos/dll/directx/dsound_new/misc.c
    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/capturebuffer.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/capturebuffer.c?rev=43946&r1=43945&r2=43946&view=diff
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/capturebuffer.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/capturebuffer.c [iso-8859-1] Wed Nov  4 03:16:49 2009
@@ -335,8 +335,10 @@
     if (This->State == KSSTATE_RUN)
         return DS_OK;
 
-    /* sanity check */
-    ASSERT(This->hPin);
+
+    /* check if there is a pin instance */
+    if (!This->hPin)
+        return DSERR_GENERIC;
 
     /* setup request */
     Property.Set = KSPROPSETID_Connection;
@@ -385,8 +387,42 @@
 WINAPI
 IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
 {
-    UNIMPLEMENTED
-    return DSERR_INVALIDPARAM;
+    KSPROPERTY Property;
+    DWORD Result;
+    KSSTATE State;
+
+    LPCDirectSoundCaptureBufferImpl This = (LPCDirectSoundCaptureBufferImpl)CONTAINING_RECORD(iface, CDirectSoundCaptureBufferImpl, lpVtbl);
+
+    if (This->State == KSSTATE_STOP)
+    {
+        /* stream has already been stopped */
+        return DS_OK;
+    }
+
+    if (!This->hPin)
+        return DSERR_GENERIC;
+
+    /* setup request */
+    Property.Set = KSPROPSETID_Connection;
+    Property.Id = KSPROPERTY_CONNECTION_STATE;
+    Property.Flags = KSPROPERTY_TYPE_SET;
+    State = KSSTATE_STOP;
+
+
+    /* set pin to stop */
+    Result = SyncOverlappedDeviceIoControl(This->hPin, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&State, sizeof(KSSTATE), NULL);
+
+    ASSERT(Result == ERROR_SUCCESS);
+
+    if (Result == ERROR_SUCCESS)
+    {
+        /* store result */
+        This->State = State;
+        return DS_OK;
+    }
+
+    DPRINT("Failed to stop pin\n");
+    return DSERR_GENERIC;
 }
 
 HRESULT

Modified: trunk/reactos/dll/directx/dsound_new/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/misc.c?rev=43946&r1=43945&r2=43946&view=diff
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/misc.c [iso-8859-1] Wed Nov  4 03:16:49 2009
@@ -12,6 +12,45 @@
 const GUID KSPROPSETID_Pin                     = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Topology                 = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 const GUID KSPROPSETID_Audio = {0x45FFAAA0L, 0x6E1B, 0x11D0, {0xBC, 0xF2, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
+
+BOOL
+SetPinFormat(
+    IN HANDLE hPin,
+    IN LPWAVEFORMATEX WaveFormatEx)
+{
+    DWORD dwResult;
+    KSPROPERTY Property;
+    KSDATAFORMAT_WAVEFORMATEX DataFormat;
+
+    /* setup connection request */
+    Property.Id = KSPROPERTY_CONNECTION_DATAFORMAT;
+    Property.Set = KSPROPSETID_Connection;
+    Property.Flags = KSPROPERTY_TYPE_SET;
+
+    /* setup data format */
+    DataFormat.WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
+    DataFormat.WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
+    DataFormat.WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
+    DataFormat.WaveFormatEx.cbSize = 0;
+    DataFormat.DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
+    DataFormat.DataFormat.Flags = 0;
+    DataFormat.DataFormat.Reserved = 0;
+    DataFormat.DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
+    DataFormat.DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+    DataFormat.DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
+    DataFormat.DataFormat.SampleSize = 4;
+    DataFormat.WaveFormatEx.nChannels = WaveFormatEx->nChannels;
+    DataFormat.WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
+    DataFormat.WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
+
+    dwResult = SyncOverlappedDeviceIoControl(hPin, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSPROPERTY),(LPVOID)&DataFormat, sizeof(KSDATAFORMAT_WAVEFORMATEX), NULL);
+
+    if (dwResult == ERROR_SUCCESS)
+        return TRUE;
+    else
+        return FALSE;
+}
+
 
 BOOL
 DoDataIntersection(

Modified: trunk/reactos/dll/directx/dsound_new/precomp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/precomp.h?rev=43946&r1=43945&r2=43946&view=diff
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/precomp.h [iso-8859-1] Wed Nov  4 03:16:49 2009
@@ -15,7 +15,7 @@
 #include <dsconf.h>
 #include <vfwmsgs.h>
 #include <setupapi.h>
-#define YDEBUG
+#define NDEBUG
 #include <debug.h>
 #include <ks.h>
 #include <ksmedia.h>
@@ -111,6 +111,11 @@
 /* misc.c */
 
 BOOL
+SetPinFormat(
+    IN HANDLE hPin,
+    IN LPWAVEFORMATEX WaveFormatEx);
+
+BOOL
 CreateCompatiblePin(
     IN HANDLE hFilter,
     IN DWORD PinId,

Modified: trunk/reactos/dll/directx/dsound_new/primary.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/primary.c?rev=43946&r1=43945&r2=43946&view=diff
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/primary.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/primary.c [iso-8859-1] Wed Nov  4 03:16:49 2009
@@ -519,8 +519,14 @@
 
     if (This->hPin)
     {
-        /* fixme change format */
-        ASSERT(0);
+        // FIXME
+        // check if multiple buffers are active
+        // in that case need mixing
+
+        if (SetPinFormat(This->hPin, pcfxFormat))
+            return DS_OK;
+        else
+            return DSERR_GENERIC;
     }
 
     do

Modified: trunk/reactos/dll/directx/dsound_new/secondary.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/dsound_new/secondary.c?rev=43946&r1=43945&r2=43946&view=diff
==============================================================================
--- trunk/reactos/dll/directx/dsound_new/secondary.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/dsound_new/secondary.c [iso-8859-1] Wed Nov  4 03:16:49 2009
@@ -294,25 +294,29 @@
         return DSERR_INVALIDPARAM;
     }
 
-    DPRINT("SecondaryDirectSoundBuffer8Impl_fnPlay dwPriority %x dwFlags %x\n", dwPriority, dwFlags);
-    hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, (dwFlags & DSBPLAY_LOOPING));
-
-    DPRINT("Result %x\n", hResult);
+    /* sanity check */
+    ASSERT(dwFlags & DSBPLAY_LOOPING);
+
+    /* set dataformat */
+    hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, TRUE);
+
     if (!SUCCEEDED(hResult))
     {
         /* failed */
+        DPRINT1("Failed to set format Tag %u Samples %u Bytes %u nChannels %u\n", This->Format->wFormatTag, This->Format->nSamplesPerSec, This->Format->wBitsPerSample, This->Format->nChannels);
         return hResult;
     }
 
+    /* start primary buffer */
     PrimaryDirectSoundBuffer_SetState(This->PrimaryBuffer, KSSTATE_RUN);
-
-
+    /* acquire primary buffer */
     PrimaryDirectSoundBuffer_AcquireLock(This->PrimaryBuffer);
-
+    /* HACK write buffer */
     PrimaryDirectSoundBuffer_Write(This->PrimaryBuffer, This->Buffer, This->BufferSize);
-
+    /* release primary buffer */
     PrimaryDirectSoundBuffer_ReleaseLock(This->PrimaryBuffer);
 
+    DPRINT1("SetFormatSuccess PrimaryBuffer %p\n", This->PrimaryBuffer);
     return DS_OK;
 }
 




More information about the Ros-diffs mailing list