aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control-pulse.vala
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2015-12-20 11:52:28 -0600
committercharles kerr <charlesk@canonical.com>2015-12-20 11:52:28 -0600
commitbba1bfdff435db14bc18d256b3957c68e0c8cbdd (patch)
treea958aa89c46e5c0c7af12d425725f30786d1d7c2 /src/volume-control-pulse.vala
parent08993677a2af7f6dd60e82bd600a7f6628503556 (diff)
downloadayatana-indicator-sound-bba1bfdff435db14bc18d256b3957c68e0c8cbdd.tar.gz
ayatana-indicator-sound-bba1bfdff435db14bc18d256b3957c68e0c8cbdd.tar.bz2
ayatana-indicator-sound-bba1bfdff435db14bc18d256b3957c68e0c8cbdd.zip
start making volume-control-pulse's pulse functions public static for reuse.
calculate_active_output() and create_pulse_dbus_connection() are now 'public static' so volume-warning can use them too.
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r--src/volume-control-pulse.vala29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 2ecf7d0..b1b7c73 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -121,7 +121,7 @@ public class VolumeControlPulse : VolumeControl
stop_account_service_volume_timer();
}
- private VolumeControl.ActiveOutput calculate_active_output (SinkInfo? sink) {
+ public static VolumeControl.ActiveOutput calculate_active_output (SinkInfo? sink) {
VolumeControl.ActiveOutput ret_output = VolumeControl.ActiveOutput.SPEAKERS;
/* Check if the current active port is headset/headphone */
@@ -693,16 +693,11 @@ public class VolumeControlPulse : VolumeControl
}
}
- /* PulseAudio Dbus (Stream Restore) logic */
- private void reconnect_pulse_dbus ()
+ public static DBusConnection create_pulse_dbus_connection()
{
unowned string pulse_dbus_server_env = Environment.get_variable ("PULSE_DBUS_SERVER");
string address;
- /* In case of a reconnect */
- _pulse_use_stream_restore = false;
- _pa_volume_sig_count = 0;
-
if (pulse_dbus_server_env != null) {
address = pulse_dbus_server_env;
} else {
@@ -713,7 +708,7 @@ public class VolumeControlPulse : VolumeControl
conn = Bus.get_sync (BusType.SESSION);
} catch (GLib.IOError e) {
warning ("unable to get the dbus session bus: %s", e.message);
- return;
+ return null;
}
try {
@@ -725,17 +720,29 @@ public class VolumeControlPulse : VolumeControl
address = props.get_string ();
} catch (GLib.Error e) {
warning ("unable to get pulse unix socket: %s", e.message);
- return;
+ return null;
}
}
debug ("PulseAudio dbus unix socket: %s", address);
try {
- _pconn = new DBusConnection.for_address_sync (address, DBusConnectionFlags.AUTHENTICATION_CLIENT);
+ return new DBusConnection.for_address_sync (address, DBusConnectionFlags.AUTHENTICATION_CLIENT);
} catch (GLib.Error e) {
/* If it fails, it means the dbus pulse extension is not available */
- return;
+ return null;
}
+ }
+
+ /* PulseAudio Dbus (Stream Restore) logic */
+ private void reconnect_pulse_dbus ()
+ {
+ /* In case of a reconnect */
+ _pulse_use_stream_restore = false;
+ _pa_volume_sig_count = 0;
+
+ _pconn = create_pulse_dbus_connection();
+ if (_pconn == null)
+ return;
/* For pulse dbus related events */
_pconn.add_filter (pulse_dbus_filter);