diff options
author | Max Kellermann <max@duempel.org> | 2013-04-17 01:19:25 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-04-17 01:41:56 +0200 |
commit | a28df6123fef2047ec631d13c91156def6f7ab83 (patch) | |
tree | ba5690ea9747629874f2f36ebacfb9eab17f4fd5 /src/OutputControl.cxx | |
parent | c5c43c4541f4434b4c5a5bc5914d6bc08f75ea94 (diff) | |
download | mpd-a28df6123fef2047ec631d13c91156def6f7ab83.tar.gz mpd-a28df6123fef2047ec631d13c91156def6f7ab83.tar.xz mpd-a28df6123fef2047ec631d13c91156def6f7ab83.zip |
OutputInternal: use Mutex instead of GMutex
Diffstat (limited to '')
-rw-r--r-- | src/OutputControl.cxx | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/src/OutputControl.cxx b/src/OutputControl.cxx index 3fe4b1e79..a11b66116 100644 --- a/src/OutputControl.cxx +++ b/src/OutputControl.cxx @@ -47,9 +47,9 @@ struct notify audio_output_client_notify; static void ao_command_wait(struct audio_output *ao) { while (ao->command != AO_COMMAND_NONE) { - g_mutex_unlock(ao->mutex); + ao->mutex.unlock(); audio_output_client_notify.Wait(); - g_mutex_lock(ao->mutex); + ao->mutex.lock(); } } @@ -64,7 +64,7 @@ static void ao_command_async(struct audio_output *ao, { assert(ao->command == AO_COMMAND_NONE); ao->command = cmd; - g_cond_signal(ao->cond); + ao->cond.signal(); } /** @@ -87,9 +87,8 @@ ao_command(struct audio_output *ao, enum audio_output_command cmd) static void ao_lock_command(struct audio_output *ao, enum audio_output_command cmd) { - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); ao_command(ao, cmd); - g_mutex_unlock(ao->mutex); } void @@ -231,33 +230,28 @@ audio_output_update(struct audio_output *ao, { assert(mp != NULL); - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); if (ao->enabled && ao->really_enabled) { if (ao->fail_timer == NULL || g_timer_elapsed(ao->fail_timer, NULL) > REOPEN_AFTER) { - bool success = audio_output_open(ao, audio_format, mp); - g_mutex_unlock(ao->mutex); - return success; + return audio_output_open(ao, audio_format, mp); } } else if (audio_output_is_open(ao)) audio_output_close_locked(ao); - g_mutex_unlock(ao->mutex); return false; } void audio_output_play(struct audio_output *ao) { - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); assert(ao->allow_play); if (audio_output_is_open(ao)) - g_cond_signal(ao->cond); - - g_mutex_unlock(ao->mutex); + ao->cond.signal(); } void audio_output_pause(struct audio_output *ao) @@ -268,45 +262,41 @@ void audio_output_pause(struct audio_output *ao) mixer_auto_close()) */ mixer_auto_close(ao->mixer); - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); + assert(ao->allow_play); if (audio_output_is_open(ao)) ao_command_async(ao, AO_COMMAND_PAUSE); - g_mutex_unlock(ao->mutex); } void audio_output_drain_async(struct audio_output *ao) { - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); + assert(ao->allow_play); if (audio_output_is_open(ao)) ao_command_async(ao, AO_COMMAND_DRAIN); - g_mutex_unlock(ao->mutex); } void audio_output_cancel(struct audio_output *ao) { - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); if (audio_output_is_open(ao)) { ao->allow_play = false; ao_command_async(ao, AO_COMMAND_CANCEL); } - - g_mutex_unlock(ao->mutex); } void audio_output_allow_play(struct audio_output *ao) { - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); ao->allow_play = true; if (audio_output_is_open(ao)) - g_cond_signal(ao->cond); - - g_mutex_unlock(ao->mutex); + ao->cond.signal(); } void @@ -323,9 +313,8 @@ void audio_output_close(struct audio_output *ao) assert(ao != NULL); assert(!ao->open || ao->fail_timer == NULL); - g_mutex_lock(ao->mutex); + const ScopeLock protect(ao->mutex); audio_output_close_locked(ao); - g_mutex_unlock(ao->mutex); } void audio_output_finish(struct audio_output *ao) |