output_all: audio_output_all_update() returns bool

audio_output_all_update() returns true when there is at least open
output device which is open.
This commit is contained in:
Max Kellermann 2009-03-07 19:55:57 +01:00
parent 498ec26f25
commit b13cd03f75
3 changed files with 19 additions and 6 deletions

View File

@ -163,16 +163,25 @@ audio_output_all_reset_reopen(void)
} }
} }
static void /**
* Opens all output devices which are enabled, but closed.
*
* @return true if there is at least open output device which is open
*/
static bool
audio_output_all_update(void) audio_output_all_update(void)
{ {
unsigned int i; unsigned int i;
bool ret = false;
if (!audio_format_defined(&input_audio_format)) if (!audio_format_defined(&input_audio_format))
return; return false;
for (i = 0; i < num_audio_outputs; ++i) for (i = 0; i < num_audio_outputs; ++i)
audio_output_update(&audio_outputs[i], &input_audio_format); ret = ret || audio_output_update(&audio_outputs[i],
&input_audio_format);
return ret;
} }
bool bool

View File

@ -94,16 +94,18 @@ audio_output_open(struct audio_output *ao,
return ao->open; return ao->open;
} }
void bool
audio_output_update(struct audio_output *ao, audio_output_update(struct audio_output *ao,
const struct audio_format *audio_format) const struct audio_format *audio_format)
{ {
if (ao->enabled) { if (ao->enabled) {
if (ao->fail_timer == NULL || if (ao->fail_timer == NULL ||
g_timer_elapsed(ao->fail_timer, NULL) > REOPEN_AFTER) g_timer_elapsed(ao->fail_timer, NULL) > REOPEN_AFTER)
audio_output_open(ao, audio_format); return audio_output_open(ao, audio_format);
} else if (audio_output_is_open(ao)) } else if (audio_output_is_open(ao))
audio_output_close(ao); audio_output_close(ao);
return false;
} }
void void

View File

@ -45,8 +45,10 @@ audio_output_open(struct audio_output *ao,
/** /**
* Opens or closes the device, depending on the "enabled" flag. * Opens or closes the device, depending on the "enabled" flag.
*
* @return true if the device is open
*/ */
void bool
audio_output_update(struct audio_output *ao, audio_output_update(struct audio_output *ao,
const struct audio_format *audio_format); const struct audio_format *audio_format);