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.
This commit is contained in:
parent
551f7d94a3
commit
be4a17876d
|
@ -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.
|
||||
* If the specified wave header is a begin loop and we're not already in
|
||||
* a loop, setup the loop.
|
||||
* 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;
|
||||
|
||||
|
||||
if (!lpWaveHdr)
|
||||
{
|
||||
if (wwo->state == WINE_WS_PLAYING)
|
||||
{
|
||||
wwo->state = WINE_WS_STOPPED;
|
||||
status = AudioOutputUnitStop(wwo->audioUnit);
|
||||
if (status && wwo->err_on)
|
||||
fprintf(stderr, "err:winecoreaudio:wodHelper_BeginWaveHdr AudioOutputUnitStop return %c%c%c%c\n",
|
||||
(char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
|
||||
}
|
||||
return;
|
||||
OSStatus status;
|
||||
wwo->state = WINE_WS_STOPPED;
|
||||
status = AudioOutputUnitStop(wwo->audioUnit);
|
||||
if (status && wwo->err_on)
|
||||
fprintf(stderr, "err:winecoreaudio:wodHelper_BeginWaveHdrPlay AudioOutputUnitStop return %c%c%c%c\n",
|
||||
(char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
|
||||
}
|
||||
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)
|
||||
{
|
||||
status = AudioOutputUnitStart(wwo->audioUnit);
|
||||
OSStatus status = AudioOutputUnitStart(wwo->audioUnit);
|
||||
if (status) {
|
||||
if (wwo->err_on)
|
||||
fprintf(stderr, "err:winecoreaudio:AudioOutputUnitStart return %c%c%c%c\n",
|
||||
(char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
|
||||
ERR("AudioOutputUnitStart return %c%c%c%c\n", (char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
|
||||
}
|
||||
else wwo->state = WINE_WS_PLAYING;
|
||||
}
|
||||
|
@ -965,9 +973,9 @@ static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo)
|
|||
if (!didLoopBack)
|
||||
{
|
||||
/* 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);
|
||||
|
||||
return lpWaveHdr;
|
||||
|
@ -1120,11 +1128,11 @@ static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
|
|||
for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext))
|
||||
/* Do nothing */;
|
||||
*wh = lpWaveHdr;
|
||||
|
||||
|
||||
if (!wwo->lpPlayPtr)
|
||||
wodHelper_BeginWaveHdr(wwo,lpWaveHdr);
|
||||
wodHelper_BeginWaveHdrWrite(wwo,lpWaveHdr);
|
||||
pthread_mutex_unlock(&wwo->lock);
|
||||
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue