mirror of
https://github.com/reactos/reactos.git
synced 2024-07-02 10:45:24 +00:00
- Add sanity checks
- Implement IDirectSoundCaptureBuffer8::Stop - Implement changing the stream format for secondary buffers - Silence debug flood svn path=/trunk/; revision=43946
This commit is contained in:
parent
c5fab80345
commit
b8fc27d6a3
|
@ -335,8 +335,10 @@ IDirectSoundCaptureBufferImpl_Start(
|
|||
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 @@ HRESULT
|
|||
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
|
||||
|
|
|
@ -13,6 +13,45 @@ const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {
|
|||
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(
|
||||
HANDLE hFilter,
|
||||
|
|
|
@ -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>
|
||||
|
@ -110,6 +110,11 @@ NewDirectSound(
|
|||
|
||||
/* misc.c */
|
||||
|
||||
BOOL
|
||||
SetPinFormat(
|
||||
IN HANDLE hPin,
|
||||
IN LPWAVEFORMATEX WaveFormatEx);
|
||||
|
||||
BOOL
|
||||
CreateCompatiblePin(
|
||||
IN HANDLE hFilter,
|
||||
|
|
|
@ -519,8 +519,14 @@ PrimaryDirectSoundBuffer_SetFormat(
|
|||
|
||||
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
|
||||
|
|
|
@ -294,25 +294,29 @@ SecondaryDirectSoundBuffer8Impl_fnPlay(
|
|||
return DSERR_INVALIDPARAM;
|
||||
}
|
||||
|
||||
DPRINT("SecondaryDirectSoundBuffer8Impl_fnPlay dwPriority %x dwFlags %x\n", dwPriority, dwFlags);
|
||||
hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, (dwFlags & DSBPLAY_LOOPING));
|
||||
/* sanity check */
|
||||
ASSERT(dwFlags & DSBPLAY_LOOPING);
|
||||
|
||||
/* set dataformat */
|
||||
hResult = PrimaryDirectSoundBuffer_SetFormat(This->PrimaryBuffer, This->Format, TRUE);
|
||||
|
||||
DPRINT("Result %x\n", hResult);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue