dsound: Remove state machine from render buffer.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2fb97be187
commit
5b0914ece9
|
@ -135,7 +135,7 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
|
|||
|
||||
device->ref = 1;
|
||||
device->priolevel = DSSCL_NORMAL;
|
||||
device->state = STATE_STOPPED;
|
||||
device->stopped = 1;
|
||||
device->speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
|
||||
|
||||
DSOUND_ParseSpeakerConfig(device);
|
||||
|
|
|
@ -76,7 +76,7 @@ struct DirectSoundDevice
|
|||
DWORD priolevel, sleeptime;
|
||||
PWAVEFORMATEX pwfx, primary_pwfx;
|
||||
LPBYTE buffer;
|
||||
DWORD writelead, buflen, aclen, fraglen, state, playpos, pad;
|
||||
DWORD writelead, buflen, aclen, fraglen, playpos, pad, stopped;
|
||||
int nrofbuffers;
|
||||
IDirectSoundBufferImpl** buffers;
|
||||
RTL_RWLOCK buffer_list_lock;
|
||||
|
|
|
@ -694,10 +694,6 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
|
|||
* also wipe out just-played sound data */
|
||||
if (!pad)
|
||||
WARN("Probable buffer underrun\n");
|
||||
else if (device->state == STATE_STOPPED ||
|
||||
device->state == STATE_STARTING) {
|
||||
TRACE("Buffer restarting\n");
|
||||
}
|
||||
|
||||
hr = IAudioRenderClient_GetBuffer(device->render, maxq / block, (void*)&buffer);
|
||||
if(FAILED(hr)){
|
||||
|
@ -724,23 +720,7 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
|
|||
ERR("ReleaseBuffer failed: %08x\n", hr);
|
||||
|
||||
device->pad += maxq;
|
||||
|
||||
if (maxq) {
|
||||
if (device->state == STATE_STARTING ||
|
||||
device->state == STATE_STOPPED) {
|
||||
if(DSOUND_PrimaryPlay(device) != DS_OK)
|
||||
WARN("DSOUND_PrimaryPlay failed\n");
|
||||
else if (device->state == STATE_STARTING)
|
||||
device->state = STATE_PLAYING;
|
||||
else
|
||||
device->state = STATE_STOPPING;
|
||||
}
|
||||
} else if (!pad && !maxq && (all_stopped == TRUE) &&
|
||||
(device->state == STATE_STOPPING)) {
|
||||
device->state = STATE_STOPPED;
|
||||
DSOUND_PrimaryStop(device);
|
||||
}
|
||||
} else if (device->state != STATE_STOPPED) {
|
||||
} else if (!device->stopped) {
|
||||
if (maxq > device->buflen)
|
||||
maxq = device->buflen;
|
||||
if (writepos + maxq > device->buflen) {
|
||||
|
@ -748,20 +728,6 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
|
|||
DSOUND_WaveQueue(device, device->buffer, writepos + maxq - device->buflen);
|
||||
} else
|
||||
DSOUND_WaveQueue(device, device->buffer + writepos, maxq);
|
||||
|
||||
/* in the DSSCL_WRITEPRIMARY mode, the app is totally in charge... */
|
||||
if (device->state == STATE_STARTING) {
|
||||
if (DSOUND_PrimaryPlay(device) != DS_OK)
|
||||
WARN("DSOUND_PrimaryPlay failed\n");
|
||||
else
|
||||
device->state = STATE_PLAYING;
|
||||
}
|
||||
else if (device->state == STATE_STOPPING) {
|
||||
if (DSOUND_PrimaryStop(device) != DS_OK)
|
||||
WARN("DSOUND_PrimaryStop failed\n");
|
||||
else
|
||||
device->state = STATE_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&(device->mixlock));
|
||||
|
|
|
@ -272,11 +272,6 @@ static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device, WAVEFORMATEX *wfx,
|
|||
HeapFree(GetProcessHeap(), 0, device->pwfx);
|
||||
device->pwfx = wfx;
|
||||
|
||||
if (device->state == STATE_PLAYING)
|
||||
device->state = STATE_STARTING;
|
||||
else if (device->state == STATE_STOPPING)
|
||||
device->state = STATE_STOPPED;
|
||||
|
||||
device->writelead = (wfx->nSamplesPerSec / 100) * wfx->nBlockAlign;
|
||||
|
||||
TRACE("buflen: %u, fraglen: %u\n", device->buflen, device->fraglen);
|
||||
|
@ -384,7 +379,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
|
|||
return S_OK;
|
||||
|
||||
err_service:
|
||||
ERR("GetService failed: %08x\n", hres);
|
||||
WARN("GetService failed: %08x\n", hres);
|
||||
err:
|
||||
device->speaker_config = oldspeakerconfig;
|
||||
DSOUND_ParseSpeakerConfig(device);
|
||||
|
@ -421,36 +416,6 @@ HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device)
|
|||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)\n", device);
|
||||
|
||||
hr = IAudioClient_Start(device->client);
|
||||
if(FAILED(hr) && hr != AUDCLNT_E_NOT_STOPPED){
|
||||
WARN("Start failed: %08x\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)\n", device);
|
||||
|
||||
hr = IAudioClient_Stop(device->client);
|
||||
if(FAILED(hr)){
|
||||
WARN("Stop failed: %08x\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
WAVEFORMATEX *DSOUND_CopyFormat(const WAVEFORMATEX *wfex)
|
||||
{
|
||||
WAVEFORMATEX *pwfx;
|
||||
|
@ -698,16 +663,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Play(IDirectSoundBuffer *iface, DWORD re
|
|||
return DSERR_INVALIDPARAM;
|
||||
}
|
||||
|
||||
/* **** */
|
||||
EnterCriticalSection(&(device->mixlock));
|
||||
|
||||
if (device->state == STATE_STOPPED)
|
||||
device->state = STATE_STARTING;
|
||||
else if (device->state == STATE_STOPPING)
|
||||
device->state = STATE_PLAYING;
|
||||
|
||||
LeaveCriticalSection(&(device->mixlock));
|
||||
/* **** */
|
||||
device->stopped = 0;
|
||||
|
||||
return DS_OK;
|
||||
}
|
||||
|
@ -718,16 +674,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Stop(IDirectSoundBuffer *iface)
|
|||
DirectSoundDevice *device = This->device;
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
/* **** */
|
||||
EnterCriticalSection(&(device->mixlock));
|
||||
|
||||
if (device->state == STATE_PLAYING)
|
||||
device->state = STATE_STOPPING;
|
||||
else if (device->state == STATE_STARTING)
|
||||
device->state = STATE_STOPPED;
|
||||
|
||||
LeaveCriticalSection(&(device->mixlock));
|
||||
/* **** */
|
||||
device->stopped = 1;
|
||||
|
||||
return DS_OK;
|
||||
}
|
||||
|
@ -795,7 +742,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetCurrentPosition(IDirectSoundBuffer *i
|
|||
*playpos = mixpos;
|
||||
if (writepos) {
|
||||
*writepos = mixpos;
|
||||
if (device->state != STATE_STOPPED) {
|
||||
if (!device->stopped) {
|
||||
/* apply the documented 10ms lead to writepos */
|
||||
*writepos += device->writelead;
|
||||
*writepos %= device->buflen;
|
||||
|
@ -821,8 +768,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetStatus(IDirectSoundBuffer *iface, DWO
|
|||
}
|
||||
|
||||
*status = 0;
|
||||
if ((device->state == STATE_STARTING) ||
|
||||
(device->state == STATE_PLAYING))
|
||||
if (!device->stopped)
|
||||
*status |= DSBSTATUS_PLAYING | DSBSTATUS_LOOPING;
|
||||
|
||||
TRACE("status=%x\n", *status);
|
||||
|
|
Loading…
Reference in New Issue