aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-03 21:08:48 +0100
committerMax Kellermann <max@duempel.org>2011-01-10 19:46:23 +0100
commitb6995ca0113611613d311250eabfc354658d46a7 (patch)
tree713bff7fe8b8dcbd48b2ea67f95e3ec9e018104b /src/output
parent715844fd089d3baf17d7080b47434fca8fb60b1d (diff)
downloadmpd-b6995ca0113611613d311250eabfc354658d46a7.tar.gz
mpd-b6995ca0113611613d311250eabfc354658d46a7.tar.xz
mpd-b6995ca0113611613d311250eabfc354658d46a7.zip
player_control: removed the global variable "pc"
Allocate a player_control object where needed, and pass it around. Each "client" object is associated with a "player_control" instance. This prepares multi-player support.
Diffstat (limited to '')
-rw-r--r--src/output_all.c14
-rw-r--r--src/output_all.h5
-rw-r--r--src/output_command.c4
-rw-r--r--src/output_control.h2
-rw-r--r--src/output_init.c5
-rw-r--r--src/output_internal.h6
-rw-r--r--src/output_thread.c2
7 files changed, 26 insertions, 12 deletions
diff --git a/src/output_all.c b/src/output_all.c
index 19c0f0166..8dce9192b 100644
--- a/src/output_all.c
+++ b/src/output_all.c
@@ -100,7 +100,7 @@ audio_output_config_count(void)
}
void
-audio_output_all_init(void)
+audio_output_all_init(struct player_control *pc)
{
const struct config_param *param = NULL;
unsigned int i;
@@ -121,7 +121,7 @@ audio_output_all_init(void)
/* only allow param to be NULL if there just one audioOutput */
assert(param || (num_audio_outputs == 1));
- if (!audio_output_init(output, param, &error)) {
+ if (!audio_output_init(output, param, pc, &error)) {
if (param != NULL)
MPD_ERROR("line %i: %s",
param->line, error->message);
@@ -473,17 +473,17 @@ audio_output_all_check(void)
}
bool
-audio_output_all_wait(unsigned threshold)
+audio_output_all_wait(struct player_control *pc, unsigned threshold)
{
- player_lock();
+ player_lock(pc);
if (audio_output_all_check() < threshold) {
- player_unlock();
+ player_unlock(pc);
return true;
}
- player_wait();
- player_unlock();
+ player_wait(pc);
+ player_unlock(pc);
return audio_output_all_check() < threshold;
}
diff --git a/src/output_all.h b/src/output_all.h
index a579bf5f1..8861d0149 100644
--- a/src/output_all.h
+++ b/src/output_all.h
@@ -32,13 +32,14 @@
struct audio_format;
struct music_buffer;
struct music_chunk;
+struct player_control;
/**
* Global initialization: load audio outputs from the configuration
* file and initialize them.
*/
void
-audio_output_all_init(void);
+audio_output_all_init(struct player_control *pc);
/**
* Global finalization: free memory occupied by audio outputs. All
@@ -127,7 +128,7 @@ audio_output_all_check(void);
* @return true if there are less than #threshold chunks in the pipe
*/
bool
-audio_output_all_wait(unsigned threshold);
+audio_output_all_wait(struct player_control *pc, unsigned threshold);
/**
* Puts all audio outputs into pause mode. Most implementations will
diff --git a/src/output_command.c b/src/output_command.c
index 825884e8e..09733cc2f 100644
--- a/src/output_command.c
+++ b/src/output_command.c
@@ -50,7 +50,7 @@ audio_output_enable_index(unsigned idx)
ao->enabled = true;
idle_add(IDLE_OUTPUT);
- pc_update_audio();
+ pc_update_audio(ao->player_control);
++audio_output_state_version;
@@ -79,7 +79,7 @@ audio_output_disable_index(unsigned idx)
idle_add(IDLE_MIXER);
}
- pc_update_audio();
+ pc_update_audio(ao->player_control);
++audio_output_state_version;
diff --git a/src/output_control.h b/src/output_control.h
index 7f4f4a53c..a6477d008 100644
--- a/src/output_control.h
+++ b/src/output_control.h
@@ -29,6 +29,7 @@ struct audio_output;
struct audio_format;
struct config_param;
struct music_pipe;
+struct player_control;
static inline GQuark
audio_output_quark(void)
@@ -38,6 +39,7 @@ audio_output_quark(void)
bool
audio_output_init(struct audio_output *ao, const struct config_param *param,
+ struct player_control *pc,
GError **error_r);
/**
diff --git a/src/output_init.c b/src/output_init.c
index f4700dfb2..0f02344fb 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -127,8 +127,12 @@ audio_output_load_mixer(void *ao, const struct config_param *param,
bool
audio_output_init(struct audio_output *ao, const struct config_param *param,
+ struct player_control *pc,
GError **error_r)
{
+ assert(ao != NULL);
+ assert(pc != NULL);
+
const struct audio_output_plugin *plugin = NULL;
GError *error = NULL;
@@ -249,6 +253,7 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
ao->command = AO_COMMAND_NONE;
ao->mutex = g_mutex_new();
ao->cond = g_cond_new();
+ ao->player_control = pc;
ao->data = ao_plugin_init(plugin,
&ao->config_audio_format,
diff --git a/src/output_internal.h b/src/output_internal.h
index 18d431352..a548b8c01 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -208,6 +208,12 @@ struct audio_output {
GCond *cond;
/**
+ * The player_control object which "owns" this output. This
+ * object is needed to signal command completion.
+ */
+ struct player_control *player_control;
+
+ /**
* The #music_chunk which is currently being played. All
* chunks before this one may be returned to the
* #music_buffer, because they are not going to be used by
diff --git a/src/output_thread.c b/src/output_thread.c
index a5244c693..3e1cd4a25 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -530,7 +530,7 @@ ao_play(struct audio_output *ao)
ao->chunk_finished = true;
g_mutex_unlock(ao->mutex);
- player_lock_signal();
+ player_lock_signal(ao->player_control);
g_mutex_lock(ao->mutex);
return true;