Skip to content

Commit b500c2e

Browse files
committed
[MMEBUDDY]
- Directly invoke streaming
1 parent 5a4484a commit b500c2e

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

sdk/include/reactos/libs/sound/mmebuddy.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,33 @@ struct _SOUND_DEVICE_INSTANCE;
117117

118118
typedef struct _SOUND_OVERLAPPED
119119
{
120+
LONG Status;
121+
ULONG_PTR Information;
120122
OVERLAPPED Standard;
121123
struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance;
122124
PWAVEHDR Header;
123125

124-
LPOVERLAPPED_COMPLETION_ROUTINE OriginalCompletionRoutine;
126+
PVOID OriginalCompletionRoutine;
125127
PVOID CompletionContext;
126128

127129
} SOUND_OVERLAPPED, *PSOUND_OVERLAPPED;
128130

131+
132+
typedef
133+
VOID
134+
(WINAPI *LPSOUND_OVERLAPPED_COMPLETION_ROUTINE)(
135+
_In_ DWORD dwErrorCode,
136+
_In_ DWORD dwNumberOfBytesTransfered,
137+
_Inout_ PSOUND_OVERLAPPED lpOverlapped
138+
);
139+
140+
129141
typedef MMRESULT (*WAVE_COMMIT_FUNC)(
130142
IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
131143
IN PVOID OffsetPtr,
132144
IN DWORD Bytes,
133145
IN PSOUND_OVERLAPPED Overlap,
134-
IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine);
146+
IN LPSOUND_OVERLAPPED_COMPLETION_ROUTINE CompletionRoutine);
135147

136148
typedef MMRESULT (*MMMIXERQUERY_FUNC) (
137149
IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
@@ -342,6 +354,9 @@ typedef struct _SOUND_DEVICE_INSTANCE
342354

343355
BOOL ResetInProgress;
344356
BOOL bPaused;
357+
358+
HANDLE hSoundThread;
359+
345360
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
346361

347362
/* This lives in WAVEHDR.reserved */
@@ -672,7 +687,7 @@ VOID CALLBACK
672687
CompleteIO(
673688
IN DWORD dwErrorCode,
674689
IN DWORD dwNumberOfBytesTransferred,
675-
IN LPOVERLAPPED lpOverlapped);
690+
IN PSOUND_OVERLAPPED lpOverlapped);
676691

677692
MMRESULT
678693
CommitWaveHeaderToKernelDevice(

sdk/lib/drivers/sound/mmebuddy/mmewrap.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ MmeSetState(
6161

6262
/* Store audio stream pause state */
6363
SoundDeviceInstance->bPaused = !bStart;
64-
65-
if (SoundDeviceInstance->bPaused == FALSE && (OldState || DeviceType == WAVE_IN_DEVICE_TYPE))
66-
{
67-
InitiateSoundStreaming(SoundDeviceInstance);
68-
}
6964
}
7065

7166
return Result;

sdk/lib/drivers/sound/mmebuddy/wave/header.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,11 @@ EnqueueWaveHeader(
271271
DoWaveStreaming(SoundDeviceInstance);
272272
}
273273
}
274-
} else if (DeviceType == WAVE_IN_DEVICE_TYPE)
274+
}
275+
else if (DeviceType == WAVE_IN_DEVICE_TYPE)
275276
{
276-
if (SoundDeviceInstance->RTStreamingStarted)
277-
{
278-
DoWaveStreaming(SoundDeviceInstance);
279-
}
277+
DoWaveStreaming(SoundDeviceInstance);
280278
}
281-
282279
}
283280
else
284281
{
@@ -297,7 +294,10 @@ EnqueueWaveHeader(
297294
/* Only do wave streaming when the stream has not been paused */
298295
if ( SoundDeviceInstance->LegacyStreaming && SoundDeviceInstance->bPaused == FALSE && SoundDeviceInstance->bClosed == FALSE )
299296
{
300-
DoWaveStreaming(SoundDeviceInstance);
297+
if (DeviceType == WAVE_OUT_DEVICE_TYPE)
298+
{
299+
DoWaveStreaming(SoundDeviceInstance);
300+
}
301301
}
302302
}
303303
}

sdk/lib/drivers/sound/mmebuddy/wave/streaming.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ DoWaveStreaming(
180180
Commit buffers using the WriteFileEx API.
181181
*/
182182

183-
VOID CALLBACK
183+
VOID WINAPI
184184
CompleteIO(
185185
IN DWORD dwErrorCode,
186186
IN DWORD dwNumberOfBytesTransferred,
187-
IN LPOVERLAPPED lpOverlapped)
187+
IN PSOUND_OVERLAPPED lpOverlapped)
188188
{
189189
MMDEVICE_TYPE DeviceType;
190190
PSOUND_DEVICE SoundDevice;
@@ -418,21 +418,17 @@ WINAPI
418418
WaveActivateSoundStreaming(
419419
IN PVOID lpParameter)
420420
{
421-
CallSoundThread((PSOUND_DEVICE_INSTANCE)lpParameter,
422-
PerformWaveStreaming,
423-
NULL);
421+
PSOUND_DEVICE_INSTANCE SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE)lpParameter;
424422

423+
PerformWaveStreaming(SoundDeviceInstance, NULL);
424+
CloseHandle(SoundDeviceInstance->hSoundThread);
425+
SoundDeviceInstance->hSoundThread = NULL;
425426
ExitThread(0);
426427
}
427428

428429
VOID
429430
InitiateSoundStreaming(
430431
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
431432
{
432-
HANDLE hThread;
433-
434-
hThread = CreateThread(NULL, 0, WaveActivateSoundStreaming, (PVOID)SoundDeviceInstance, 0, NULL);
435-
436-
if (hThread != NULL)
437-
CloseHandle(hThread);
433+
SoundDeviceInstance->hSoundThread = CreateThread(NULL, 0, WaveActivateSoundStreaming, (PVOID)SoundDeviceInstance, 0, NULL);
438434
}

0 commit comments

Comments
 (0)