From 9dc966041d9a3bba82a9e9f72db6fe261ac82195 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Feb 2009 21:40:22 +0100 Subject: osx: start the audio device in the open() method Don't call AudioOutputUnitStart() in the play() method, do it after the device has been opened. We can eliminate the "started" property now, because the device is always started when it's open. --- src/output/osx_plugin.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/output/osx_plugin.c') diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c index 08f95e83c..18a88ddce 100644 --- a/src/output/osx_plugin.c +++ b/src/output/osx_plugin.c @@ -32,7 +32,6 @@ struct osx_output { size_t buffer_size; size_t pos; size_t len; - int started; }; static bool @@ -54,7 +53,6 @@ osx_output_init(G_GNUC_UNUSED const struct audio_format *audio_format, oo->pos = 0; oo->len = 0; - oo->started = 0; oo->buffer = NULL; oo->buffer_size = 0; @@ -90,11 +88,7 @@ static void osx_output_close(void *data) } g_mutex_unlock(od->mutex); - if (od->started) { - AudioOutputUnitStop(od->au); - od->started = 0; - } - + AudioOutputUnitStop(od->au); AudioUnitUninitialize(od->au); CloseComponent(od->au); } @@ -156,6 +150,7 @@ osx_output_open(void *data, struct audio_format *audio_format) Component comp; AURenderCallbackStruct callback; AudioStreamBasicDescription stream_description; + int err; if (audio_format->bits > 16) audio_format->bits = 16; @@ -227,6 +222,12 @@ osx_output_open(void *data, struct audio_format *audio_format) od->pos = 0; od->len = 0; + err = AudioOutputUnitStart(od->au); + if (err != 0) { + g_warning("unable to start audio output: %i", err); + return false; + } + return true; } @@ -236,16 +237,6 @@ osx_output_play(void *data, const void *chunk, size_t size) struct osx_output *od = data; size_t start, nbytes; - if (!od->started) { - int err; - od->started = 1; - err = AudioOutputUnitStart(od->au); - if (err) { - g_warning("unable to start audio output: %i\n", err); - return 0; - } - } - g_mutex_lock(od->mutex); while (od->len >= od->buffer_size) -- cgit v1.2.3