Commit be4a1787 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winecoreaudio: Specialize wodHelper_BeginWaveHdr for its two callers and simplify.

wodHelper_PlayPtrNext is only called when state == WINE_WS_PLAYING. Also, it clears dwPartialOffset itself. wodWrite only calls wodHelper_BeginWaveHdr[Write] with a non-NULL lpWaveHdr parameter. wodWrite is not called from the Audio Unit render callback, so it can use Wine debug channels.
parent 551f7d94
...@@ -883,39 +883,47 @@ static void wodHelper_CheckForLoopBegin(WINE_WAVEOUT* wwo) ...@@ -883,39 +883,47 @@ static void wodHelper_CheckForLoopBegin(WINE_WAVEOUT* wwo)
/************************************************************************** /**************************************************************************
* wodHelper_BeginWaveHdr [internal] * wodHelper_BeginWaveHdrPlay [internal]
* *
* Makes the specified lpWaveHdr the currently playing wave header. * Makes the specified lpWaveHdr the currently playing wave header.
* If the specified wave header is a begin loop and we're not already in * If the specified wave header is a begin loop and we're not already in
* a loop, setup the loop. * a loop, setup the loop.
* Call from AudioUnit IO thread can't use Wine debug channels. * Call from AudioUnit IO thread can't use Wine debug channels.
*/ */
static void wodHelper_BeginWaveHdr(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr) static void wodHelper_BeginWaveHdrPlay(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr)
{ {
OSStatus status;
wwo->lpPlayPtr = lpWaveHdr; wwo->lpPlayPtr = lpWaveHdr;
if (!lpWaveHdr) if (!lpWaveHdr)
{ {
if (wwo->state == WINE_WS_PLAYING) OSStatus status;
{ wwo->state = WINE_WS_STOPPED;
wwo->state = WINE_WS_STOPPED; status = AudioOutputUnitStop(wwo->audioUnit);
status = AudioOutputUnitStop(wwo->audioUnit); if (status && wwo->err_on)
if (status && wwo->err_on) fprintf(stderr, "err:winecoreaudio:wodHelper_BeginWaveHdrPlay AudioOutputUnitStop return %c%c%c%c\n",
fprintf(stderr, "err:winecoreaudio:wodHelper_BeginWaveHdr AudioOutputUnitStop return %c%c%c%c\n", (char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
(char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
}
return;
} }
else
wodHelper_CheckForLoopBegin(wwo);
}
/**************************************************************************
* wodHelper_BeginWaveHdrWrite [internal]
*
* Makes the specified lpWaveHdr the currently playing wave header.
* If the specified wave header is a begin loop and we're not already in
* a loop, setup the loop.
*/
static void wodHelper_BeginWaveHdrWrite(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr)
{
wwo->lpPlayPtr = lpWaveHdr;
if (wwo->state == WINE_WS_STOPPED) if (wwo->state == WINE_WS_STOPPED)
{ {
status = AudioOutputUnitStart(wwo->audioUnit); OSStatus status = AudioOutputUnitStart(wwo->audioUnit);
if (status) { if (status) {
if (wwo->err_on) ERR("AudioOutputUnitStart return %c%c%c%c\n", (char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
fprintf(stderr, "err:winecoreaudio:AudioOutputUnitStart return %c%c%c%c\n",
(char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
} }
else wwo->state = WINE_WS_PLAYING; else wwo->state = WINE_WS_PLAYING;
} }
...@@ -965,9 +973,9 @@ static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo) ...@@ -965,9 +973,9 @@ static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo)
if (!didLoopBack) if (!didLoopBack)
{ {
/* We didn't loop back. Advance to the next wave header */ /* We didn't loop back. Advance to the next wave header */
wodHelper_BeginWaveHdr(wwo, lpWaveHdr = lpWaveHdr->lpNext); wodHelper_BeginWaveHdrPlay(wwo, lpWaveHdr = lpWaveHdr->lpNext);
} }
pthread_mutex_unlock(&wwo->lock); pthread_mutex_unlock(&wwo->lock);
return lpWaveHdr; return lpWaveHdr;
...@@ -1120,11 +1128,11 @@ static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize) ...@@ -1120,11 +1128,11 @@ static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext)) for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext))
/* Do nothing */; /* Do nothing */;
*wh = lpWaveHdr; *wh = lpWaveHdr;
if (!wwo->lpPlayPtr) if (!wwo->lpPlayPtr)
wodHelper_BeginWaveHdr(wwo,lpWaveHdr); wodHelper_BeginWaveHdrWrite(wwo,lpWaveHdr);
pthread_mutex_unlock(&wwo->lock); pthread_mutex_unlock(&wwo->lock);
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment