Commit 9dc96604 authored by Max Kellermann's avatar Max Kellermann

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.
parent fb5ca6aa
......@@ -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)
......
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