aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_all.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/output_all.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/output_all.c b/src/output_all.c
index 7f4694a8b..f56cd04ee 100644
--- a/src/output_all.c
+++ b/src/output_all.c
@@ -41,7 +41,7 @@
static struct audio_format input_audio_format;
-static struct audio_output *audio_outputs;
+static struct audio_output **audio_outputs;
static unsigned int num_audio_outputs;
/**
@@ -70,7 +70,9 @@ audio_output_get(unsigned i)
{
assert(i < num_audio_outputs);
- return &audio_outputs[i];
+ assert(audio_outputs[i] != NULL);
+
+ return audio_outputs[i];
}
struct audio_output *
@@ -110,11 +112,10 @@ audio_output_all_init(struct player_control *pc)
notify_init(&audio_output_client_notify);
num_audio_outputs = audio_output_config_count();
- audio_outputs = g_new(struct audio_output, num_audio_outputs);
+ audio_outputs = g_new(struct audio_output *, num_audio_outputs);
for (i = 0; i < num_audio_outputs; i++)
{
- struct audio_output *output = &audio_outputs[i];
unsigned int j;
param = config_get_next_param(CONF_AUDIO_OUTPUT, param);
@@ -122,7 +123,8 @@ audio_output_all_init(struct player_control *pc)
/* only allow param to be NULL if there just one audioOutput */
assert(param || (num_audio_outputs == 1));
- if (!audio_output_init(output, param, pc, &error)) {
+ struct audio_output *output = audio_output_new(param, pc, &error);
+ if (output == NULL) {
if (param != NULL)
MPD_ERROR("line %i: %s",
param->line, error->message);
@@ -130,9 +132,11 @@ audio_output_all_init(struct player_control *pc)
MPD_ERROR("%s", error->message);
}
+ audio_outputs[i] = output;
+
/* require output names to be unique: */
for (j = 0; j < i; j++) {
- if (!strcmp(output->name, audio_outputs[j].name)) {
+ if (!strcmp(output->name, audio_outputs[j]->name)) {
MPD_ERROR("output devices with identical "
"names: %s\n", output->name);
}
@@ -146,8 +150,8 @@ audio_output_all_finish(void)
unsigned int i;
for (i = 0; i < num_audio_outputs; i++) {
- audio_output_disable(&audio_outputs[i]);
- audio_output_finish(&audio_outputs[i]);
+ audio_output_disable(audio_outputs[i]);
+ audio_output_finish(audio_outputs[i]);
}
g_free(audio_outputs);
@@ -161,7 +165,7 @@ void
audio_output_all_enable_disable(void)
{
for (unsigned i = 0; i < num_audio_outputs; i++) {
- struct audio_output *ao = &audio_outputs[i];
+ struct audio_output *ao = audio_outputs[i];
bool enabled;
g_mutex_lock(ao->mutex);
@@ -185,7 +189,7 @@ static bool
audio_output_all_finished(void)
{
for (unsigned i = 0; i < num_audio_outputs; ++i) {
- struct audio_output *ao = &audio_outputs[i];
+ struct audio_output *ao = audio_outputs[i];
bool not_finished;
g_mutex_lock(ao->mutex);
@@ -213,7 +217,7 @@ static void
audio_output_allow_play_all(void)
{
for (unsigned i = 0; i < num_audio_outputs; ++i)
- audio_output_allow_play(&audio_outputs[i]);
+ audio_output_allow_play(audio_outputs[i]);
}
static void
@@ -238,7 +242,7 @@ static void
audio_output_all_reset_reopen(void)
{
for (unsigned i = 0; i < num_audio_outputs; ++i) {
- struct audio_output *ao = &audio_outputs[i];
+ struct audio_output *ao = audio_outputs[i];
audio_output_reset_reopen(ao);
}
@@ -259,7 +263,7 @@ audio_output_all_update(void)
return false;
for (i = 0; i < num_audio_outputs; ++i)
- ret = audio_output_update(&audio_outputs[i],
+ ret = audio_output_update(audio_outputs[i],
&input_audio_format, g_mp) || ret;
return ret;
@@ -283,7 +287,7 @@ audio_output_all_play(struct music_chunk *chunk)
music_pipe_push(g_mp, chunk);
for (i = 0; i < num_audio_outputs; ++i)
- audio_output_play(&audio_outputs[i]);
+ audio_output_play(audio_outputs[i]);
return true;
}
@@ -322,10 +326,10 @@ audio_output_all_open(const struct audio_format *audio_format,
audio_output_all_update();
for (i = 0; i < num_audio_outputs; ++i) {
- if (audio_outputs[i].enabled)
+ if (audio_outputs[i]->enabled)
enabled = true;
- if (audio_outputs[i].open)
+ if (audio_outputs[i]->open)
ret = true;
}
@@ -369,7 +373,7 @@ static bool
chunk_is_consumed(const struct music_chunk *chunk)
{
for (unsigned i = 0; i < num_audio_outputs; ++i) {
- const struct audio_output *ao = &audio_outputs[i];
+ const struct audio_output *ao = audio_outputs[i];
bool consumed;
g_mutex_lock(ao->mutex);
@@ -394,7 +398,7 @@ clear_tail_chunk(G_GNUC_UNUSED const struct music_chunk *chunk, bool *locked)
assert(music_pipe_contains(g_mp, chunk));
for (unsigned i = 0; i < num_audio_outputs; ++i) {
- struct audio_output *ao = &audio_outputs[i];
+ struct audio_output *ao = audio_outputs[i];
/* this mutex will be unlocked by the caller when it's
ready */
@@ -451,7 +455,7 @@ audio_output_all_check(void)
by clear_tail_chunk() */
for (unsigned i = 0; i < num_audio_outputs; ++i)
if (locked[i])
- g_mutex_unlock(audio_outputs[i].mutex);
+ g_mutex_unlock(audio_outputs[i]->mutex);
/* return the chunk to the buffer */
music_buffer_return(g_music_buffer, shifted);
@@ -484,7 +488,7 @@ audio_output_all_pause(void)
audio_output_all_update();
for (i = 0; i < num_audio_outputs; ++i)
- audio_output_pause(&audio_outputs[i]);
+ audio_output_pause(audio_outputs[i]);
audio_output_wait_all();
}
@@ -493,7 +497,7 @@ void
audio_output_all_drain(void)
{
for (unsigned i = 0; i < num_audio_outputs; ++i)
- audio_output_drain_async(&audio_outputs[i]);
+ audio_output_drain_async(audio_outputs[i]);
audio_output_wait_all();
}
@@ -506,7 +510,7 @@ audio_output_all_cancel(void)
/* send the cancel() command to all audio outputs */
for (i = 0; i < num_audio_outputs; ++i)
- audio_output_cancel(&audio_outputs[i]);
+ audio_output_cancel(audio_outputs[i]);
audio_output_wait_all();
@@ -531,7 +535,7 @@ audio_output_all_close(void)
unsigned int i;
for (i = 0; i < num_audio_outputs; ++i)
- audio_output_close(&audio_outputs[i]);
+ audio_output_close(audio_outputs[i]);
if (g_mp != NULL) {
assert(g_music_buffer != NULL);
@@ -554,7 +558,7 @@ audio_output_all_release(void)
unsigned int i;
for (i = 0; i < num_audio_outputs; ++i)
- audio_output_release(&audio_outputs[i]);
+ audio_output_release(audio_outputs[i]);
if (g_mp != NULL) {
assert(g_music_buffer != NULL);