aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-26 21:40:22 +0100
committerMax Kellermann <max@duempel.org>2009-02-26 21:40:22 +0100
commit9dc966041d9a3bba82a9e9f72db6fe261ac82195 (patch)
tree0e27191c3c1977da2d94b7df15890782e52d5bd7
parentfb5ca6aa29636b4da14405341ff543edaaff4f2b (diff)
downloadmpd-9dc966041d9a3bba82a9e9f72db6fe261ac82195.tar.gz
mpd-9dc966041d9a3bba82a9e9f72db6fe261ac82195.tar.xz
mpd-9dc966041d9a3bba82a9e9f72db6fe261ac82195.zip
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.
-rw-r--r--src/output/osx_plugin.c25
1 files changed, 8 insertions, 17 deletions
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)