summaryrefslogtreecommitdiff
path: root/backends/pulse
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2016-01-04 21:50:08 +0100
committerMichal Ratajsky <[email protected]>2016-01-05 11:18:38 +0100
commitc03e76c83ed49335390cdb9e3a8e63df4d73e0c5 (patch)
treede057f689b582f23f63d348530c0d27a0c9518cb /backends/pulse
parent299e1a26e5eb5d6625feba2a9db017f43d9d853c (diff)
downloadlibmatemixer-c03e76c83ed49335390cdb9e3a8e63df4d73e0c5.tar.bz2
libmatemixer-c03e76c83ed49335390cdb9e3a8e63df4d73e0c5.tar.xz
pulse: Use own PulseAudio connection in stream controls
Diffstat (limited to 'backends/pulse')
-rw-r--r--backends/pulse/pulse-sink-control.c19
-rw-r--r--backends/pulse/pulse-sink-control.h5
-rw-r--r--backends/pulse/pulse-sink-input.c16
-rw-r--r--backends/pulse/pulse-sink-input.h5
-rw-r--r--backends/pulse/pulse-sink.c9
-rw-r--r--backends/pulse/pulse-source-control.c17
-rw-r--r--backends/pulse/pulse-source-control.h5
-rw-r--r--backends/pulse/pulse-source-output.c17
-rw-r--r--backends/pulse/pulse-source-output.h5
-rw-r--r--backends/pulse/pulse-source.c8
-rw-r--r--backends/pulse/pulse-stream-control.h2
11 files changed, 66 insertions, 42 deletions
diff --git a/backends/pulse/pulse-sink-control.c b/backends/pulse/pulse-sink-control.c
index 500cef0..d511208 100644
--- a/backends/pulse/pulse-sink-control.c
+++ b/backends/pulse/pulse-sink-control.c
@@ -56,8 +56,9 @@ pulse_sink_control_init (PulseSinkControl *control)
}
PulseSinkControl *
-pulse_sink_control_new (PulseSink *sink,
- const pa_sink_info *info)
+pulse_sink_control_new (PulseConnection *connection,
+ const pa_sink_info *info,
+ PulseSink *parent)
{
PulseSinkControl *control;
MateMixerStreamControlFlags flags = MATE_MIXER_STREAM_CONTROL_MUTE_READABLE |
@@ -67,8 +68,9 @@ pulse_sink_control_new (PulseSink *sink,
MateMixerStreamControlRole role;
guint32 index;
- g_return_val_if_fail (PULSE_IS_SINK (sink), NULL);
+ g_return_val_if_fail (PULSE_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (PULSE_IS_SINK (parent), NULL);
if (info->active_port != NULL)
role = MATE_MIXER_STREAM_CONTROL_ROLE_PORT;
@@ -79,7 +81,7 @@ pulse_sink_control_new (PulseSink *sink,
if (info->flags & PA_SINK_DECIBEL_VOLUME)
flags |= MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL;
- index = pulse_sink_get_index_monitor (sink);
+ index = pulse_sink_get_index_monitor (parent);
if (index != PA_INVALID_INDEX)
flags |= MATE_MIXER_STREAM_CONTROL_HAS_MONITOR;
@@ -88,7 +90,8 @@ pulse_sink_control_new (PulseSink *sink,
"label", info->description,
"flags", flags,
"role", role,
- "stream", sink,
+ "stream", parent,
+ "connection", connection,
NULL);
pulse_sink_control_update (control, info);
@@ -122,7 +125,7 @@ pulse_sink_control_set_mute (PulseStreamControl *psc, gboolean mute)
{
g_return_val_if_fail (PULSE_IS_SINK_CONTROL (psc), FALSE);
- return pulse_connection_set_sink_mute (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_sink_mute (pulse_stream_control_get_connection (psc),
PULSE_STREAM_CONTROL_GET_STREAM_INDEX (psc),
mute);
}
@@ -133,7 +136,7 @@ pulse_sink_control_set_volume (PulseStreamControl *psc, pa_cvolume *cvolume)
g_return_val_if_fail (PULSE_IS_SINK_CONTROL (psc), FALSE);
g_return_val_if_fail (cvolume != NULL, FALSE);
- return pulse_connection_set_sink_volume (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_sink_volume (pulse_stream_control_get_connection (psc),
PULSE_STREAM_CONTROL_GET_STREAM_INDEX (psc),
cvolume);
}
@@ -155,7 +158,7 @@ pulse_sink_control_create_monitor (PulseStreamControl *psc)
return NULL;
}
- return pulse_connection_create_monitor (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_create_monitor (pulse_stream_control_get_connection (psc),
index,
PA_INVALID_INDEX);
}
diff --git a/backends/pulse/pulse-sink-control.h b/backends/pulse/pulse-sink-control.h
index e9570f4..573b3e5 100644
--- a/backends/pulse/pulse-sink-control.h
+++ b/backends/pulse/pulse-sink-control.h
@@ -56,8 +56,9 @@ struct _PulseSinkControlClass
GType pulse_sink_control_get_type (void) G_GNUC_CONST;
-PulseSinkControl *pulse_sink_control_new (PulseSink *sink,
- const pa_sink_info *info);
+PulseSinkControl *pulse_sink_control_new (PulseConnection *connection,
+ const pa_sink_info *info,
+ PulseSink *sink);
void pulse_sink_control_update (PulseSinkControl *control,
const pa_sink_info *info);
diff --git a/backends/pulse/pulse-sink-input.c b/backends/pulse/pulse-sink-input.c
index c20a820..16637c8 100644
--- a/backends/pulse/pulse-sink-input.c
+++ b/backends/pulse/pulse-sink-input.c
@@ -64,7 +64,9 @@ pulse_sink_input_init (PulseSinkInput *input)
}
PulseSinkInput *
-pulse_sink_input_new (PulseSink *sink, const pa_sink_input_info *info)
+pulse_sink_input_new (PulseConnection *connection,
+ const pa_sink_input_info *info,
+ PulseSink *parent)
{
PulseSinkInput *input;
gchar *name;
@@ -79,8 +81,9 @@ pulse_sink_input_new (PulseSink *sink, const pa_sink_input_info *info)
MateMixerStreamControlMediaRole media_role = MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN;
- g_return_val_if_fail (PULSE_IS_SINK (sink), NULL);
+ g_return_val_if_fail (PULSE_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (PULSE_IS_SINK (parent), NULL);
/* Many mixer applications query the Pulse client list and use the client
* name here, but we use the name only as an identifier, so let's avoid
@@ -141,8 +144,9 @@ pulse_sink_input_new (PulseSink *sink, const pa_sink_input_info *info)
"flags", flags,
"role", role,
"media-role", media_role,
+ "stream", parent,
+ "connection", connection,
"index", info->index,
- "stream", sink,
NULL);
g_free (name);
@@ -197,7 +201,7 @@ pulse_sink_input_set_mute (PulseStreamControl *psc, gboolean mute)
{
g_return_val_if_fail (PULSE_IS_SINK_INPUT (psc), FALSE);
- return pulse_connection_set_sink_input_mute (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_sink_input_mute (pulse_stream_control_get_connection (psc),
pulse_stream_control_get_index (psc),
mute);
}
@@ -208,7 +212,7 @@ pulse_sink_input_set_volume (PulseStreamControl *psc, pa_cvolume *cvolume)
g_return_val_if_fail (PULSE_IS_SINK_INPUT (psc), FALSE);
g_return_val_if_fail (cvolume != NULL, FALSE);
- return pulse_connection_set_sink_input_volume (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_sink_input_volume (pulse_stream_control_get_connection (psc),
pulse_stream_control_get_index (psc),
cvolume);
}
@@ -230,7 +234,7 @@ pulse_sink_input_create_monitor (PulseStreamControl *psc)
return NULL;
}
- return pulse_connection_create_monitor (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_create_monitor (pulse_stream_control_get_connection (psc),
index,
pulse_stream_control_get_index (psc));
}
diff --git a/backends/pulse/pulse-sink-input.h b/backends/pulse/pulse-sink-input.h
index 127eab6..92b3897 100644
--- a/backends/pulse/pulse-sink-input.h
+++ b/backends/pulse/pulse-sink-input.h
@@ -55,8 +55,9 @@ struct _PulseSinkInputClass
GType pulse_sink_input_get_type (void) G_GNUC_CONST;
-PulseSinkInput *pulse_sink_input_new (PulseSink *sink,
- const pa_sink_input_info *info);
+PulseSinkInput *pulse_sink_input_new (PulseConnection *connection,
+ const pa_sink_input_info *info,
+ PulseSink *sink);
void pulse_sink_input_update (PulseSinkInput *input,
const pa_sink_input_info *info);
diff --git a/backends/pulse/pulse-sink.c b/backends/pulse/pulse-sink.c
index 616331b..3f9573d 100644
--- a/backends/pulse/pulse-sink.c
+++ b/backends/pulse/pulse-sink.c
@@ -141,7 +141,7 @@ pulse_sink_new (PulseConnection *connection,
"index", info->index,
NULL);
- sink->priv->control = pulse_sink_control_new (sink, info);
+ sink->priv->control = pulse_sink_control_new (connection, info, sink);
if (info->n_ports > 0) {
pa_sink_port_info **ports = info->ports;
@@ -197,8 +197,13 @@ pulse_sink_add_input (PulseSink *sink, const pa_sink_input_info *info)
input = g_hash_table_lookup (sink->priv->inputs, GUINT_TO_POINTER (info->index));
if (input == NULL) {
const gchar *name;
+ PulseConnection *connection;
+
+ connection = pulse_stream_get_connection (PULSE_STREAM (sink));
+ input = pulse_sink_input_new (connection,
+ info,
+ sink);
- input = pulse_sink_input_new (sink, info);
g_hash_table_insert (sink->priv->inputs,
GUINT_TO_POINTER (info->index),
input);
diff --git a/backends/pulse/pulse-source-control.c b/backends/pulse/pulse-source-control.c
index 3ed1573..1cff6b5 100644
--- a/backends/pulse/pulse-source-control.c
+++ b/backends/pulse/pulse-source-control.c
@@ -56,8 +56,9 @@ pulse_source_control_init (PulseSourceControl *control)
}
PulseSourceControl *
-pulse_source_control_new (PulseSource *source,
- const pa_source_info *info)
+pulse_source_control_new (PulseConnection *connection,
+ const pa_source_info *info,
+ PulseSource *parent)
{
PulseSourceControl *control;
MateMixerStreamControlFlags flags = MATE_MIXER_STREAM_CONTROL_MUTE_READABLE |
@@ -67,8 +68,9 @@ pulse_source_control_new (PulseSource *source,
MATE_MIXER_STREAM_CONTROL_HAS_MONITOR;
MateMixerStreamControlRole role;
- g_return_val_if_fail (PULSE_IS_SOURCE (source), NULL);
+ g_return_val_if_fail (PULSE_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (PULSE_IS_SOURCE (parent), NULL);
if (info->active_port != NULL)
role = MATE_MIXER_STREAM_CONTROL_ROLE_PORT;
@@ -84,7 +86,8 @@ pulse_source_control_new (PulseSource *source,
"label", info->description,
"flags", flags,
"role", role,
- "stream", source,
+ "stream", parent,
+ "connection", connection,
NULL);
pulse_source_control_update (control, info);
@@ -118,7 +121,7 @@ pulse_source_control_set_mute (PulseStreamControl *psc, gboolean mute)
{
g_return_val_if_fail (PULSE_IS_SOURCE_CONTROL (psc), FALSE);
- return pulse_connection_set_source_mute (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_source_mute (pulse_stream_control_get_connection (psc),
PULSE_STREAM_CONTROL_GET_STREAM_INDEX (psc),
mute);
}
@@ -129,7 +132,7 @@ pulse_source_control_set_volume (PulseStreamControl *psc, pa_cvolume *cvolume)
g_return_val_if_fail (PULSE_IS_SOURCE_CONTROL (psc), FALSE);
g_return_val_if_fail (cvolume != NULL, FALSE);
- return pulse_connection_set_source_volume (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_source_volume (pulse_stream_control_get_connection (psc),
PULSE_STREAM_CONTROL_GET_STREAM_INDEX (psc),
cvolume);
}
@@ -148,7 +151,7 @@ pulse_source_control_create_monitor (PulseStreamControl *psc)
return NULL;
}
- return pulse_connection_create_monitor (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_create_monitor (pulse_stream_control_get_connection (psc),
index,
PA_INVALID_INDEX);
}
diff --git a/backends/pulse/pulse-source-control.h b/backends/pulse/pulse-source-control.h
index a8d659f..4cf78a3 100644
--- a/backends/pulse/pulse-source-control.h
+++ b/backends/pulse/pulse-source-control.h
@@ -56,8 +56,9 @@ struct _PulseSourceControlClass
GType pulse_source_control_get_type (void) G_GNUC_CONST;
-PulseSourceControl *pulse_source_control_new (PulseSource *source,
- const pa_source_info *info);
+PulseSourceControl *pulse_source_control_new (PulseConnection *connection,
+ const pa_source_info *info,
+ PulseSource *source);
void pulse_source_control_update (PulseSourceControl *control,
const pa_source_info *info);
diff --git a/backends/pulse/pulse-source-output.c b/backends/pulse/pulse-source-output.c
index 9a38250..6d7fad8 100644
--- a/backends/pulse/pulse-source-output.c
+++ b/backends/pulse/pulse-source-output.c
@@ -64,8 +64,9 @@ pulse_source_output_init (PulseSourceOutput *output)
}
PulseSourceOutput *
-pulse_source_output_new (PulseSource *source,
- const pa_source_output_info *info)
+pulse_source_output_new (PulseConnection *connection,
+ const pa_source_output_info *info,
+ PulseSource *parent)
{
PulseSourceOutput *output;
gchar *name;
@@ -79,8 +80,9 @@ pulse_source_output_new (PulseSource *source,
MateMixerStreamControlMediaRole media_role = MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN;
- g_return_val_if_fail (PULSE_IS_SOURCE (source), NULL);
+ g_return_val_if_fail (PULSE_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (PULSE_IS_SOURCE (parent), NULL);
/* Many mixer applications query the Pulse client list and use the client
* name here, but we use the name only as an identifier, so let's avoid
@@ -129,8 +131,9 @@ pulse_source_output_new (PulseSource *source,
"flags", flags,
"role", role,
"media-role", media_role,
+ "stream", parent,
+ "connection", connection,
"index", info->index,
- "stream", source,
NULL);
g_free (name);
@@ -186,7 +189,7 @@ pulse_source_output_set_mute (PulseStreamControl *psc, gboolean mute)
{
g_return_val_if_fail (PULSE_IS_SOURCE_OUTPUT (psc), FALSE);
- return pulse_connection_set_source_output_mute (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_source_output_mute (pulse_stream_control_get_connection (psc),
pulse_stream_control_get_index (psc),
mute);
}
@@ -197,7 +200,7 @@ pulse_source_output_set_volume (PulseStreamControl *psc, pa_cvolume *cvolume)
g_return_val_if_fail (PULSE_IS_SOURCE_OUTPUT (psc), FALSE);
g_return_val_if_fail (cvolume != NULL, FALSE);
- return pulse_connection_set_source_output_volume (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_set_source_output_volume (pulse_stream_control_get_connection (psc),
pulse_stream_control_get_index (psc),
cvolume);
}
@@ -207,7 +210,7 @@ pulse_source_output_create_monitor (PulseStreamControl *psc)
{
g_return_val_if_fail (PULSE_IS_SOURCE_OUTPUT (psc), NULL);
- return pulse_connection_create_monitor (PULSE_STREAM_CONTROL_GET_CONNECTION (psc),
+ return pulse_connection_create_monitor (pulse_stream_control_get_connection (psc),
PULSE_STREAM_CONTROL_GET_STREAM_INDEX (psc),
PA_INVALID_INDEX);
}
diff --git a/backends/pulse/pulse-source-output.h b/backends/pulse/pulse-source-output.h
index 1037f94..e11bf88 100644
--- a/backends/pulse/pulse-source-output.h
+++ b/backends/pulse/pulse-source-output.h
@@ -55,8 +55,9 @@ struct _PulseSourceOutputClass
GType pulse_source_output_get_type (void) G_GNUC_CONST;
-PulseSourceOutput *pulse_source_output_new (PulseSource *source,
- const pa_source_output_info *info);
+PulseSourceOutput *pulse_source_output_new (PulseConnection *connection,
+ const pa_source_output_info *info,
+ PulseSource *source);
void pulse_source_output_update (PulseSourceOutput *output,
const pa_source_output_info *info);
diff --git a/backends/pulse/pulse-source.c b/backends/pulse/pulse-source.c
index 570423d..b70cbe4 100644
--- a/backends/pulse/pulse-source.c
+++ b/backends/pulse/pulse-source.c
@@ -138,7 +138,7 @@ pulse_source_new (PulseConnection *connection,
"index", info->index,
NULL);
- source->priv->control = pulse_source_control_new (source, info);
+ source->priv->control = pulse_source_control_new (connection, info, source);
if (info->n_ports > 0) {
pa_source_port_info **ports = info->ports;
@@ -194,8 +194,12 @@ pulse_source_add_output (PulseSource *source, const pa_source_output_info *info)
output = g_hash_table_lookup (source->priv->outputs, GUINT_TO_POINTER (info->index));
if (output == NULL) {
const gchar *name;
+ PulseConnection *connection;
- output = pulse_source_output_new (source, info);
+ connection = pulse_stream_get_connection (PULSE_STREAM (source));
+ output = pulse_source_output_new (connection,
+ info,
+ source);
g_hash_table_insert (source->priv->outputs,
GUINT_TO_POINTER (info->index),
output);
diff --git a/backends/pulse/pulse-stream-control.h b/backends/pulse/pulse-stream-control.h
index c37d6eb..ae1bb26 100644
--- a/backends/pulse/pulse-stream-control.h
+++ b/backends/pulse/pulse-stream-control.h
@@ -41,8 +41,6 @@ G_BEGIN_DECLS
#define PULSE_STREAM_CONTROL_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), PULSE_TYPE_STREAM_CONTROL, PulseStreamControlClass))
-#define PULSE_STREAM_CONTROL_GET_CONNECTION(psc) \
- (pulse_stream_get_connection (PULSE_STREAM (mate_mixer_stream_control_get_stream (MATE_MIXER_STREAM_CONTROL (psc)))))
#define PULSE_STREAM_CONTROL_GET_STREAM_INDEX(psc) \
(pulse_stream_get_index (PULSE_STREAM (mate_mixer_stream_control_get_stream (MATE_MIXER_STREAM_CONTROL (psc)))))