Skip to content

Commit f0e7172

Browse files
committed
Remove PA_WIN_DS_USE_WMME_TIMER
This build flag was introduced 13 years ago to allow PortAudio users to roll back to some previous MME timer-based DirectSound implementation. As far as I can tell no-one has ever used that flag (Google returns ~0 hits for it), and presumably no-one is going to bother testing with this flag in place. Get rid of it to simplify the DS code which currently looks like an #ifdef fest.
1 parent 18a606e commit f0e7172

File tree

1 file changed

+0
-62
lines changed

1 file changed

+0
-62
lines changed

src/hostapi/dsound/pa_win_ds.c

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@
4141
@ingroup hostapi_src
4242
*/
4343

44-
/* Until May 2011 PA/DS has used a multimedia timer to perform the callback.
45-
We're replacing this with a new implementation using a thread and a different timer mechanism.
46-
Defining PA_WIN_DS_USE_WMME_TIMER uses the old (pre-May 2011) behavior.
47-
*/
48-
//#define PA_WIN_DS_USE_WMME_TIMER
49-
5044
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0400)
5145
#undef _WIN32_WINNT
5246
#define _WIN32_WINNT 0x0400 /* required to get waitable timer APIs */
@@ -73,11 +67,9 @@
7367
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
7468
#include <dsconf.h>
7569
#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
76-
#ifndef PA_WIN_DS_USE_WMME_TIMER
7770
#ifndef UNDER_CE
7871
#include <process.h>
7972
#endif
80-
#endif
8173

8274
#include "pa_util.h"
8375
#include "pa_allocation.h"
@@ -101,9 +93,6 @@
10193
#pragma comment( lib, "kernel32.lib" )
10294
#endif
10395

104-
/* use CreateThread for CYGWIN, _beginthreadex for all others */
105-
#ifndef PA_WIN_DS_USE_WMME_TIMER
106-
10796
#if !defined(__CYGWIN__) && !defined(UNDER_CE)
10897
#define CREATE_THREAD (HANDLE)_beginthreadex
10998
#undef CLOSE_THREAD_HANDLE /* as per documentation we don't call CloseHandle on a thread created with _beginthreadex */
@@ -128,8 +117,6 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg );
128117
#define PA_WIN_DS_USE_WAITABLE_TIMER_OBJECT /* use waitable timer where possible, otherwise we use a WaitForSingleObject timeout */
129118
#endif
130119

131-
#endif /* !PA_WIN_DS_USE_WMME_TIMER */
132-
133120

134121
/*
135122
provided in newer platform sdks and x64
@@ -309,17 +296,12 @@ typedef struct PaWinDsStream
309296

310297
UINT systemTimerResolutionPeriodMs; /* set to 0 if we were unable to set the timer period */
311298

312-
#ifdef PA_WIN_DS_USE_WMME_TIMER
313-
MMRESULT timerID;
314-
#else
315-
316299
#ifdef PA_WIN_DS_USE_WAITABLE_TIMER_OBJECT
317300
HANDLE waitableTimer;
318301
#endif
319302
HANDLE processingThread;
320303
PA_THREAD_ID processingThreadId;
321304
HANDLE processingThreadCompleted;
322-
#endif
323305

324306
} PaWinDsStream;
325307

@@ -2078,10 +2060,6 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
20782060
goto error;
20792061
}
20802062

2081-
#ifdef PA_WIN_DS_USE_WMME_TIMER
2082-
stream->timerID = 0;
2083-
#endif
2084-
20852063
#ifdef PA_WIN_DS_USE_WAITABLE_TIMER_OBJECT
20862064
stream->waitableTimer = (HANDLE)CreateWaitableTimer( 0, FALSE, NULL );
20872065
if( stream->waitableTimer == NULL )
@@ -2092,15 +2070,13 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
20922070
}
20932071
#endif
20942072

2095-
#ifndef PA_WIN_DS_USE_WMME_TIMER
20962073
stream->processingThreadCompleted = CreateEvent( NULL, /* bManualReset = */ TRUE, /* bInitialState = */ FALSE, NULL );
20972074
if( stream->processingThreadCompleted == NULL )
20982075
{
20992076
result = paUnanticipatedHostError;
21002077
PA_DS_SET_LAST_DIRECTSOUND_ERROR( GetLastError() );
21012078
goto error;
21022079
}
2103-
#endif
21042080

21052081
/* set up i/o parameters */
21062082

@@ -2294,10 +2270,8 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
22942270
CloseHandle( stream->waitableTimer );
22952271
#endif
22962272

2297-
#ifndef PA_WIN_DS_USE_WMME_TIMER
22982273
if( stream->processingThreadCompleted != NULL )
22992274
CloseHandle( stream->processingThreadCompleted );
2300-
#endif
23012275

23022276
if( stream->pDirectSoundOutputBuffer )
23032277
{
@@ -2726,8 +2700,6 @@ static void CALLBACK TimerCallback(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD
27262700
}
27272701
}
27282702

2729-
#ifndef PA_WIN_DS_USE_WMME_TIMER
2730-
27312703
#ifdef PA_WIN_DS_USE_WAITABLE_TIMER_OBJECT
27322704

27332705
static void CALLBACK WaitableTimerAPCProc(
@@ -2790,8 +2762,6 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
27902762
return 0;
27912763
}
27922764

2793-
#endif /* !PA_WIN_DS_USE_WMME_TIMER */
2794-
27952765
/***********************************************************************************
27962766
When CloseStream() is called, the multi-api layer ensures that
27972767
the stream has already been stopped or aborted.
@@ -2808,9 +2778,7 @@ static PaError CloseStream( PaStream* s )
28082778
CloseHandle( stream->waitableTimer );
28092779
#endif
28102780

2811-
#ifndef PA_WIN_DS_USE_WMME_TIMER
28122781
CloseHandle( stream->processingThreadCompleted );
2813-
#endif
28142782

28152783
// Cleanup the sound buffers
28162784
if( stream->pDirectSoundOutputBuffer )
@@ -2906,9 +2874,7 @@ static PaError StartStream( PaStream *s )
29062874

29072875
ResetEvent( stream->processingCompleted );
29082876

2909-
#ifndef PA_WIN_DS_USE_WMME_TIMER
29102877
ResetEvent( stream->processingThreadCompleted );
2911-
#endif
29122878

29132879
if( stream->bufferProcessor.inputChannelCount > 0 )
29142880
{
@@ -3000,23 +2966,6 @@ static PaError StartStream( PaStream *s )
30002966
}
30012967

30022968

3003-
#ifdef PA_WIN_DS_USE_WMME_TIMER
3004-
/* Create timer that will wake us up so we can fill the DSound buffer. */
3005-
/* We have deprecated timeSetEvent because all MM timer callbacks
3006-
are serialised onto a single thread. Which creates problems with multiple
3007-
PA streams, or when also using timers for other time critical tasks
3008-
*/
3009-
stream->timerID = timeSetEvent( timerPeriodMs, stream->systemTimerResolutionPeriodMs, (LPTIMECALLBACK) TimerCallback,
3010-
(DWORD_PTR) stream, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS );
3011-
3012-
if( stream->timerID == 0 )
3013-
{
3014-
stream->isActive = 0;
3015-
result = paUnanticipatedHostError;
3016-
PA_DS_SET_LAST_DIRECTSOUND_ERROR( GetLastError() );
3017-
goto error;
3018-
}
3019-
#else
30202969
/* Create processing thread which calls TimerCallback */
30212970

30222971
stream->processingThread = CREATE_THREAD( 0, 0, ProcessingThreadProc, stream, 0, &stream->processingThreadId );
@@ -3033,7 +2982,6 @@ static PaError StartStream( PaStream *s )
30332982
PA_DS_SET_LAST_DIRECTSOUND_ERROR( GetLastError() );
30342983
goto error;
30352984
}
3036-
#endif
30372985
}
30382986

30392987
stream->isActive = 1;
@@ -3048,15 +2996,13 @@ static PaError StartStream( PaStream *s )
30482996
IDirectSoundBuffer_Stop( stream->pDirectSoundOutputBuffer );
30492997
stream->outputIsRunning = FALSE;
30502998

3051-
#ifndef PA_WIN_DS_USE_WMME_TIMER
30522999
if( stream->processingThread )
30533000
{
30543001
#ifdef CLOSE_THREAD_HANDLE
30553002
CLOSE_THREAD_HANDLE( stream->processingThread ); /* Delete thread. */
30563003
#endif
30573004
stream->processingThread = NULL;
30583005
}
3059-
#endif
30603006

30613007
return result;
30623008
}
@@ -3080,13 +3026,6 @@ static PaError StopStream( PaStream *s )
30803026
WaitForSingleObject( stream->processingCompleted, timeoutMsec );
30813027
}
30823028

3083-
#ifdef PA_WIN_DS_USE_WMME_TIMER
3084-
if( stream->timerID != 0 )
3085-
{
3086-
timeKillEvent(stream->timerID); /* Stop callback timer. */
3087-
stream->timerID = 0;
3088-
}
3089-
#else
30903029
if( stream->processingThread )
30913030
{
30923031
if( WaitForSingleObject( stream->processingThreadCompleted, 30*100 ) == WAIT_TIMEOUT )
@@ -3098,7 +3037,6 @@ static PaError StopStream( PaStream *s )
30983037
#endif
30993038

31003039
}
3101-
#endif
31023040

31033041
if( stream->systemTimerResolutionPeriodMs > 0 ){
31043042
timeEndPeriod( stream->systemTimerResolutionPeriodMs );

0 commit comments

Comments
 (0)