diff options
author | Max Kellermann <max@duempel.org> | 2009-02-10 22:09:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-10 22:09:07 +0100 |
commit | e8aee4d992004e21e3862417e9ce0d1421073bb2 (patch) | |
tree | 25e2306e640317ba6d201edf986404c9cf074bd3 /src/output_thread.c | |
parent | a96993f65500dfbbf5104685a375c712208f9fc8 (diff) | |
download | mpd-e8aee4d992004e21e3862417e9ce0d1421073bb2.tar.gz mpd-e8aee4d992004e21e3862417e9ce0d1421073bb2.tar.xz mpd-e8aee4d992004e21e3862417e9ce0d1421073bb2.zip |
output_thread: moved code to ao_close()
Merge some duplicate code into one function.
Diffstat (limited to '')
-rw-r--r-- | src/output_thread.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/output_thread.c b/src/output_thread.c index 76f090c31..196aaf142 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -38,6 +38,16 @@ static void ao_command_finished(struct audio_output *ao) notify_signal(&audio_output_client_notify); } +static void +ao_close(struct audio_output *ao) +{ + assert(ao->open); + + ao->plugin->close(ao->data); + pcm_convert_deinit(&ao->convert_state); + ao->open = false; +} + static void ao_play(struct audio_output *ao) { const char *data = ao->args.play.data; @@ -62,9 +72,7 @@ static void ao_play(struct audio_output *ao) ret = ao->plugin->play(ao->data, data, size); if (!ret) { ao->plugin->cancel(ao->data); - ao->plugin->close(ao->data); - pcm_convert_deinit(&ao->convert_state); - ao->open = false; + ao_close(ao); } ao_command_finished(ao); @@ -83,17 +91,13 @@ static void ao_pause(struct audio_output *ao) ret = ao->plugin->pause(ao->data); if (!ret) { - ao->plugin->close(ao->data); - pcm_convert_deinit(&ao->convert_state); - ao->open = false; + ao_close(ao); break; } } while (ao->command == AO_COMMAND_NONE); } else { /* pause is not supported - simply close the device */ - ao->plugin->close(ao->data); - pcm_convert_deinit(&ao->convert_state); - ao->open = false; + ao_close(ao); ao_command_finished(ao); } } @@ -127,10 +131,8 @@ static gpointer audio_output_task(gpointer arg) case AO_COMMAND_CLOSE: assert(ao->open); ao->plugin->cancel(ao->data); - ao->plugin->close(ao->data); - pcm_convert_deinit(&ao->convert_state); - ao->open = false; + ao_close(ao); ao_command_finished(ao); break; |