/* now that we are here, mark AO device as dead */
XAUDIO_DEVICE_STATE(device) = ASTATE_DEAD;
return;
- }
+ }
/* info about the connected output plugin */
write_c_string(" :driver \"", pcfun);
/* -- initialise -- */
ao_initialize();
- fmt = xmalloc(sizeof(ao_sample_format));
+ fmt = xmalloc_and_zero(sizeof(ao_sample_format));
/* -- Setup for driver -- */
if (optext_driver != NULL)
/* ... and play it */
SXE_MUTEX_LOCK(&aj->mtx);
+ mtp = aj->play_state;
if (aj->buffer_alloc_size < SOUND_MAX_AUDIO_FRAME_SIZE) {
alloced_myself = 1;
aj->buffer = xmalloc_atomic(SOUND_MAX_AUDIO_FRAME_SIZE);
SXE_MUTEX_UNLOCK(&aj->mtx);
resolution = (sasd->mtap->samplerate * MTPSTATE_REACT_TIME) / 1000000;
- while (aj->play_state != MTPSTATE_STOP) {
+ while (mtp != MTPSTATE_STOP) {
#ifdef EF_USE_ASYNEQ
/* events are there? */
#endif
SXE_MUTEX_LOCK(&aj->mtx);
- mtp = aj->play_state;
- SXE_MUTEX_UNLOCK(&aj->mtx);
- switch (mtp) {
+ switch (aj->play_state) {
case MTPSTATE_RUN:
if (!ao_push(aj, resolution))
aj->play_state = MTPSTATE_STOP;
break;
case MTPSTATE_PAUSE:
- AO_DEBUG("sleeping for %d\n", resolution);
- usleep(resolution);
- break;
+ /* must sleep resolution outside of lock */
case MTPSTATE_UNKNOWN:
case MTPSTATE_STOP:
case NUMBER_OF_MEDIA_THREAD_PLAY_STATES:
default:
AO_DEBUG("ACK, quit\n");
- SXE_MUTEX_LOCK(&aj->mtx);
aj->play_state = MTPSTATE_STOP;
- SXE_MUTEX_UNLOCK(&aj->mtx);
+ break;
+ }
+ mtp = aj->play_state;
+ SXE_MUTEX_UNLOCK(&aj->mtx);
+ if (mtp == MTPSTATE_PAUSE) {
+ AO_DEBUG("sleeping for %d\n", resolution);
+ usleep(resolution);
break;
}
}
aj->buffer_alloc_size = 0;
SXE_MUTEX_UNLOCK(&aj->mtx);
- if (sasd && sasd->dev) {
+ /* sasd is always != NULL here per its initialization */
+ if (sasd->dev) {
ao_close(sasd->dev);
sasd->dev = NULL;
}