mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
WaveHdr prepare/unprepare/submit now gets handled within the context of the
appropriate sound thread. This removes some responsibility of the sound threading from the actual usermode sound component implementations. Minor cleanup to CallSoundThread as we can deduce the thread handle from the sound device instance. svn path=/trunk/; revision=39608
This commit is contained in:
parent
43961e394e
commit
727a48a397
5 changed files with 84 additions and 20 deletions
|
@ -376,7 +376,7 @@ GetSoundDeviceType(
|
||||||
MMRESULT
|
MMRESULT
|
||||||
SetSoundDeviceFunctionTable(
|
SetSoundDeviceFunctionTable(
|
||||||
IN PSOUND_DEVICE SoundDevice,
|
IN PSOUND_DEVICE SoundDevice,
|
||||||
IN PMMFUNCTION_TABLE FunctionTable OPTIONAL);
|
IN PMMFUNCTION_TABLE FunctionTable);
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
GetSoundDeviceFunctionTable(
|
GetSoundDeviceFunctionTable(
|
||||||
|
@ -438,9 +438,8 @@ DestroySoundThread(
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
CallSoundThread(
|
CallSoundThread(
|
||||||
IN PSOUND_THREAD Thread,
|
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
||||||
IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
|
IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
|
||||||
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
|
|
||||||
IN PVOID Parameter OPTIONAL);
|
IN PVOID Parameter OPTIONAL);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ DestroySoundDeviceInstance(
|
||||||
SND_ASSERT( FunctionTable->Close );
|
SND_ASSERT( FunctionTable->Close );
|
||||||
if ( FunctionTable->Close == NULL )
|
if ( FunctionTable->Close == NULL )
|
||||||
{
|
{
|
||||||
/* Bad practice, really! If you can open, why not close?! */
|
/* This indicates bad practice, really! If you can open, why not close?! */
|
||||||
return MMSYSERR_NOTSUPPORTED;
|
return MMSYSERR_NOTSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,26 +18,26 @@
|
||||||
/*
|
/*
|
||||||
Attaches a function table to a sound device. Any NULL entries in this
|
Attaches a function table to a sound device. Any NULL entries in this
|
||||||
table are automatically set to point to a default routine to handle
|
table are automatically set to point to a default routine to handle
|
||||||
the appropriate function. If NULL is passed as the function table itself,
|
the appropriate function.
|
||||||
the entire function table will use only the default routines.
|
|
||||||
*/
|
*/
|
||||||
MMRESULT
|
MMRESULT
|
||||||
SetSoundDeviceFunctionTable(
|
SetSoundDeviceFunctionTable(
|
||||||
IN PSOUND_DEVICE SoundDevice,
|
IN PSOUND_DEVICE SoundDevice,
|
||||||
IN PMMFUNCTION_TABLE FunctionTable OPTIONAL)
|
IN PMMFUNCTION_TABLE FunctionTable)
|
||||||
{
|
{
|
||||||
VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
|
VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
|
||||||
|
VALIDATE_MMSYS_PARAMETER( FunctionTable );
|
||||||
|
|
||||||
/* Zero out the existing function table (if present) */
|
/* Zero out the existing function table (if present) */
|
||||||
ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE));
|
ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE));
|
||||||
|
|
||||||
if ( FunctionTable )
|
if ( ! FunctionTable )
|
||||||
{
|
return MMSYSERR_INVALPARAM;
|
||||||
/* Fill in the client-supplied functions */
|
|
||||||
CopyMemory(&SoundDevice->FunctionTable,
|
/* Fill in the client-supplied functions */
|
||||||
FunctionTable,
|
CopyMemory(&SoundDevice->FunctionTable,
|
||||||
sizeof(MMFUNCTION_TABLE));
|
FunctionTable,
|
||||||
}
|
sizeof(MMFUNCTION_TABLE));
|
||||||
|
|
||||||
return MMSYSERR_NOERROR;
|
return MMSYSERR_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,7 @@ CreateSoundThread(
|
||||||
/* Wake the thread up */
|
/* Wake the thread up */
|
||||||
if ( ResumeThread(NewThread->Handle) == -1 )
|
if ( ResumeThread(NewThread->Handle) == -1 )
|
||||||
{
|
{
|
||||||
|
SND_ERR(L"Failed to resume thread!\n");
|
||||||
CloseHandle(NewThread->Handle);
|
CloseHandle(NewThread->Handle);
|
||||||
DestroySoundThreadEvents(NewThread->Events.Ready,
|
DestroySoundThreadEvents(NewThread->Events.Ready,
|
||||||
NewThread->Events.Request,
|
NewThread->Events.Request,
|
||||||
|
@ -199,14 +200,16 @@ DestroySoundThread(
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
CallSoundThread(
|
CallSoundThread(
|
||||||
IN PSOUND_THREAD Thread,
|
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
||||||
IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
|
IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
|
||||||
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
|
|
||||||
IN PVOID Parameter OPTIONAL)
|
IN PVOID Parameter OPTIONAL)
|
||||||
{
|
{
|
||||||
VALIDATE_MMSYS_PARAMETER( Thread );
|
VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
|
||||||
VALIDATE_MMSYS_PARAMETER( RequestHandler );
|
VALIDATE_MMSYS_PARAMETER( RequestHandler );
|
||||||
|
|
||||||
|
/* TODO: Don't call this directly? */
|
||||||
|
PSOUND_THREAD Thread = SoundDeviceInstance->Thread;
|
||||||
|
|
||||||
SND_TRACE(L"Waiting for READY event\n");
|
SND_TRACE(L"Waiting for READY event\n");
|
||||||
WaitForSingleObject(Thread->Events.Ready, INFINITE);
|
WaitForSingleObject(Thread->Events.Ready, INFINITE);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,62 @@
|
||||||
#include <ntddsnd.h>
|
#include <ntddsnd.h>
|
||||||
#include <mmebuddy.h>
|
#include <mmebuddy.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
This structure gets used locally within functions as a way to shuttle data
|
||||||
|
to the sound thread. It's safe to use locally since CallSoundThread will
|
||||||
|
not return until the operation has been carried out.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MMWAVEHEADER_FUNC Function;
|
||||||
|
PWAVEHDR Header;
|
||||||
|
} THREADED_WAVEHEADER_PARAMETERS;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Helper routines to simplify the call to the sound thread for the header
|
||||||
|
functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
MMRESULT
|
||||||
|
WaveHeaderOperationInSoundThread(
|
||||||
|
PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
||||||
|
IN PVOID Parameter)
|
||||||
|
{
|
||||||
|
THREADED_WAVEHEADER_PARAMETERS* Parameters = (THREADED_WAVEHEADER_PARAMETERS*) Parameter;
|
||||||
|
return Parameters->Function(SoundDeviceInstance, Parameters->Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
MMRESULT
|
||||||
|
WaveHeaderOperation(
|
||||||
|
MMWAVEHEADER_FUNC Function,
|
||||||
|
PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
||||||
|
PWAVEHDR Header)
|
||||||
|
{
|
||||||
|
THREADED_WAVEHEADER_PARAMETERS Parameters;
|
||||||
|
|
||||||
|
Parameters.Function = Function;
|
||||||
|
Parameters.Header = Header;
|
||||||
|
|
||||||
|
return CallSoundThread(SoundDeviceInstance,
|
||||||
|
WaveHeaderOperationInSoundThread,
|
||||||
|
&Parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following routines are basically handlers for:
|
||||||
|
- WODM_PREPARE
|
||||||
|
- WODM_UNPREPARE
|
||||||
|
- WODM_WRITE
|
||||||
|
|
||||||
|
All of these calls are ultimately dealt with in the context of the
|
||||||
|
appropriate sound thread, so the implementation should expect itself to
|
||||||
|
be running in this other thread when any of these operations take place.
|
||||||
|
*/
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
PrepareWaveHeader(
|
PrepareWaveHeader(
|
||||||
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
|
||||||
|
@ -39,7 +95,9 @@ PrepareWaveHeader(
|
||||||
if ( ! FunctionTable->PrepareWaveHeader )
|
if ( ! FunctionTable->PrepareWaveHeader )
|
||||||
return MMSYSERR_NOTSUPPORTED;
|
return MMSYSERR_NOTSUPPORTED;
|
||||||
|
|
||||||
return FunctionTable->PrepareWaveHeader(SoundDeviceInstance, Header);
|
return WaveHeaderOperation(FunctionTable->PrepareWaveHeader,
|
||||||
|
SoundDeviceInstance,
|
||||||
|
Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
|
@ -67,7 +125,9 @@ UnprepareWaveHeader(
|
||||||
if ( ! FunctionTable->UnprepareWaveHeader )
|
if ( ! FunctionTable->UnprepareWaveHeader )
|
||||||
return MMSYSERR_NOTSUPPORTED;
|
return MMSYSERR_NOTSUPPORTED;
|
||||||
|
|
||||||
return FunctionTable->UnprepareWaveHeader(SoundDeviceInstance, Header);
|
return WaveHeaderOperation(FunctionTable->UnprepareWaveHeader,
|
||||||
|
SoundDeviceInstance,
|
||||||
|
Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT
|
MMRESULT
|
||||||
|
@ -95,6 +155,8 @@ SubmitWaveHeader(
|
||||||
if ( ! FunctionTable->SubmitWaveHeader )
|
if ( ! FunctionTable->SubmitWaveHeader )
|
||||||
return MMSYSERR_NOTSUPPORTED;
|
return MMSYSERR_NOTSUPPORTED;
|
||||||
|
|
||||||
return FunctionTable->SubmitWaveHeader(SoundDeviceInstance, Header);
|
return WaveHeaderOperation(FunctionTable->SubmitWaveHeader,
|
||||||
|
SoundDeviceInstance,
|
||||||
|
Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue