Commit f8722913 authored by Max Kellermann's avatar Max Kellermann

output: removed audio_output.result

Since open() and play() close the device on error, we can simply check audio_output.open instead of audio_output.result after a call.
parent 7da0e005
...@@ -247,11 +247,9 @@ bool playAudio(const char *buffer, size_t length) ...@@ -247,11 +247,9 @@ bool playAudio(const char *buffer, size_t length)
if (!audio_output_is_open(ao)) if (!audio_output_is_open(ao))
continue; continue;
if (audio_output_command_is_finished(ao)) { if (audio_output_command_is_finished(ao))
bool success = audio_output_get_result(ao);
if (success)
ret = true; ret = true;
} else { else {
finished = false; finished = false;
audio_output_signal(ao); audio_output_signal(ao);
} }
......
...@@ -55,8 +55,6 @@ bool ...@@ -55,8 +55,6 @@ bool
audio_output_open(struct audio_output *audioOutput, audio_output_open(struct audio_output *audioOutput,
const struct audio_format *audioFormat) const struct audio_format *audioFormat)
{ {
bool ret = true;
audioOutput->reopen_after = 0; audioOutput->reopen_after = 0;
if (audioOutput->open && if (audioOutput->open &&
...@@ -83,12 +81,10 @@ audio_output_open(struct audio_output *audioOutput, ...@@ -83,12 +81,10 @@ audio_output_open(struct audio_output *audioOutput,
if (audioOutput->thread == 0) if (audioOutput->thread == 0)
audio_output_thread_start(audioOutput); audio_output_thread_start(audioOutput);
if (!audioOutput->open) { if (!audioOutput->open)
ao_command(audioOutput, AO_COMMAND_OPEN); ao_command(audioOutput, AO_COMMAND_OPEN);
ret = audioOutput->result;
}
return ret; return audioOutput->open;
} }
void void
......
...@@ -109,11 +109,6 @@ struct audio_output { ...@@ -109,11 +109,6 @@ struct audio_output {
const struct tag *tag; const struct tag *tag;
} args; } args;
/**
* Result value of the command. true means success.
*/
bool result;
}; };
/** /**
...@@ -134,10 +129,4 @@ audio_output_command_is_finished(const struct audio_output *ao) ...@@ -134,10 +129,4 @@ audio_output_command_is_finished(const struct audio_output *ao)
return ao->command == AO_COMMAND_NONE; return ao->command == AO_COMMAND_NONE;
} }
static inline bool
audio_output_get_result(const struct audio_output *ao)
{
return ao->result;
}
#endif #endif
...@@ -63,12 +63,13 @@ static void ao_play(struct audio_output *ao) ...@@ -63,12 +63,13 @@ static void ao_play(struct audio_output *ao)
{ {
const char *data = ao->args.play.data; const char *data = ao->args.play.data;
size_t size = ao->args.play.size; size_t size = ao->args.play.size;
bool ret;
if (!audio_format_equals(&ao->inAudioFormat, &ao->outAudioFormat)) if (!audio_format_equals(&ao->inAudioFormat, &ao->outAudioFormat))
convertAudioFormat(ao, &data, &size); convertAudioFormat(ao, &data, &size);
ao->result = ao->plugin->play(ao->data, data, size); ret = ao->plugin->play(ao->data, data, size);
if (!ao->result) { if (!ret) {
ao->plugin->cancel(ao->data); ao->plugin->cancel(ao->data);
ao->plugin->close(ao->data); ao->plugin->close(ao->data);
ao->open = false; ao->open = false;
...@@ -96,6 +97,7 @@ static void ao_pause(struct audio_output *ao) ...@@ -96,6 +97,7 @@ static void ao_pause(struct audio_output *ao)
static void *audio_output_task(void *arg) static void *audio_output_task(void *arg)
{ {
struct audio_output *ao = arg; struct audio_output *ao = arg;
bool ret;
while (1) { while (1) {
switch (ao->command) { switch (ao->command) {
...@@ -104,11 +106,11 @@ static void *audio_output_task(void *arg) ...@@ -104,11 +106,11 @@ static void *audio_output_task(void *arg)
case AO_COMMAND_OPEN: case AO_COMMAND_OPEN:
assert(!ao->open); assert(!ao->open);
ao->result = ao->plugin->open(ao->data, ret = ao->plugin->open(ao->data,
&ao->outAudioFormat); &ao->outAudioFormat);
assert(!ao->open); assert(!ao->open);
if (ao->result == true) if (ret == true)
ao->open = true; ao->open = true;
else else
ao->reopen_after = time(NULL) + REOPEN_AFTER; ao->reopen_after = time(NULL) + REOPEN_AFTER;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment