aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/active-sink.h84
-rw-r--r--src/device.c (renamed from src/active-sink.c)129
-rw-r--r--src/device.h84
-rw-r--r--src/pulseaudio-mgr.c86
-rw-r--r--src/pulseaudio-mgr.h4
-rw-r--r--src/slider-menu-item.c6
-rw-r--r--src/slider-menu-item.h4
-rw-r--r--src/sound-service-dbus.c10
-rw-r--r--src/voip-input-menu-item.c6
-rw-r--r--src/voip-input-menu-item.h4
11 files changed, 209 insertions, 212 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7525d71..f7dc2ef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -92,8 +92,8 @@ indicator_sound_service_SOURCES = \
sound-service.c \
pulseaudio-mgr.h \
pulseaudio-mgr.c \
- active-sink.c \
- active-sink.h \
+ device.c \
+ device.h \
sound-service-dbus.h \
sound-service-dbus.c \
slider-menu-item.h \
diff --git a/src/active-sink.h b/src/active-sink.h
deleted file mode 100644
index 7215648..0000000
--- a/src/active-sink.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2010 Canonical Ltd.
- *
- * Authors:
- * Conor Curran <conor.curran@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __ACTIVE_SINK_H__
-#define __ACTIVE_SINK_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "common-defs.h"
-#include "sound-service-dbus.h"
-
-#include <pulse/pulseaudio.h>
-
-G_BEGIN_DECLS
-
-#define ACTIVE_SINK_TYPE (active_sink_get_type ())
-#define ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ACTIVE_SINK_TYPE, ActiveSink))
-#define ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ACTIVE_SINK_TYPE, ActiveSinkClass))
-#define IS_ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ACTIVE_SINK_TYPE))
-#define IS_ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ACTIVE_SINK_TYPE))
-#define ACTIVE_SINK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ACTIVE_SINK_TYPE, ActiveSinkClass))
-
-typedef struct _ActiveSink ActiveSink;
-typedef struct _ActiveSinkClass ActiveSinkClass;
-
-struct _ActiveSink {
- GObject parent;
-};
-
-struct _ActiveSinkClass {
- GObjectClass parent_class;
-};
-
-GType active_sink_get_type (void) G_GNUC_CONST;
-
-/**
- * TODO
- * Refactor this to become a device manager obj basically acting as wrapper for
- * the communication between pulseaudio-mgr and the individual items.
- * First steps collapse slider/volume related stuff into slider-menu-item.
- */
-
-// Sink related
-void active_sink_populate (ActiveSink* sink, const pa_sink_info* update);
-void active_sink_update (ActiveSink* sink, const pa_sink_info* update);
-gboolean active_sink_is_populated (ActiveSink* sink);
-gint active_sink_get_index (ActiveSink* self);
-void active_sink_deactivate (ActiveSink* self);
-void active_sink_update_mute (ActiveSink* self, gboolean mute_update);
-void active_sink_ensure_sink_is_unmuted (ActiveSink* self);
-
-// source and sinkinput/client related for VOIP functionality
-void active_sink_update_voip_input_source (ActiveSink* sink, const pa_source_info* update);
-void active_sink_activate_voip_item (ActiveSink* sink, gint sink_input_index, gint client_index);
-gint active_sink_get_current_sink_input_index (ActiveSink* sink);
-gboolean active_sink_is_voip_source_populated (ActiveSink* sink);
-gint active_sink_get_source_index (ActiveSink* self);
-void active_sink_determine_blocking_state (ActiveSink* self);
-void active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible);
-void active_sink_deactivate_voip_client (ActiveSink* self);
-SoundState active_sink_get_state (ActiveSink* self);
-
-ActiveSink* active_sink_new (SoundServiceDbus* service);
-
-G_END_DECLS
-
-#endif
diff --git a/src/active-sink.c b/src/device.c
index 9d6e223..2f38beb 100644
--- a/src/active-sink.c
+++ b/src/device.c
@@ -18,15 +18,15 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libdbusmenu-glib/menuitem.h>
-#include "active-sink.h"
+#include "device.h"
#include "slider-menu-item.h"
#include "mute-menu-item.h"
#include "voip-input-menu-item.h"
#include "pulseaudio-mgr.h"
-typedef struct _ActiveSinkPrivate ActiveSinkPrivate;
+typedef struct _DevicePrivate DevicePrivate;
-struct _ActiveSinkPrivate
+struct _DevicePrivate
{
SliderMenuItem* volume_slider_menuitem;
MuteMenuItem* mute_menuitem;
@@ -35,35 +35,34 @@ struct _ActiveSinkPrivate
SoundServiceDbus* service;
};
-#define ACTIVE_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACTIVE_SINK_TYPE, ActiveSinkPrivate))
+#define DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEVICE_TYPE, DevicePrivate))
/* Prototypes */
-static void active_sink_class_init (ActiveSinkClass *klass);
-static void active_sink_init (ActiveSink *self);
-static void active_sink_dispose (GObject *object);
-static void active_sink_finalize (GObject *object);
+static void device_class_init (DeviceClass *klass);
+static void device_init (Device *self);
+static void device_dispose (GObject *object);
+static void device_finalize (GObject *object);
-static SoundState active_sink_get_state_from_volume (ActiveSink* self);
-static void active_sink_volume_update (ActiveSink* self, gdouble percent);
-static void active_sink_mute_update (ActiveSink* self, gboolean muted);
+static SoundState device_get_state_from_volume (Device* self);
+static void device_mute_update (Device* self, gboolean muted);
-G_DEFINE_TYPE (ActiveSink, active_sink, G_TYPE_OBJECT);
+G_DEFINE_TYPE (Device, device, G_TYPE_OBJECT);
static void
-active_sink_class_init (ActiveSinkClass *klass)
+device_class_init (DeviceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (ActiveSinkPrivate));
+ g_type_class_add_private (klass, sizeof (DevicePrivate));
- gobject_class->dispose = active_sink_dispose;
- gobject_class->finalize = active_sink_finalize;
+ gobject_class->dispose = device_dispose;
+ gobject_class->finalize = device_finalize;
}
static void
-active_sink_init (ActiveSink *self)
+device_init (Device *self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
priv->mute_menuitem = NULL;
priv->volume_slider_menuitem = NULL;
priv->voip_input_menu_item = NULL;
@@ -79,26 +78,26 @@ active_sink_init (ActiveSink *self)
}
static void
-active_sink_dispose (GObject *object)
+device_dispose (GObject *object)
{
- G_OBJECT_CLASS (active_sink_parent_class)->dispose (object);
+ G_OBJECT_CLASS (device_parent_class)->dispose (object);
}
static void
-active_sink_finalize (GObject *object)
+device_finalize (GObject *object)
{
- G_OBJECT_CLASS (active_sink_parent_class)->finalize (object);
+ G_OBJECT_CLASS (device_parent_class)->finalize (object);
}
void
-active_sink_populate (ActiveSink* sink,
+device_populate (Device* self,
const pa_sink_info* update)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink);
- active_sink_mute_update (sink, update->mute);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
+ device_mute_update (self, update->mute);
mute_menu_item_enable (priv->mute_menuitem, TRUE);
slider_menu_item_populate (priv->volume_slider_menuitem, update);
- SoundState state = active_sink_get_state_from_volume (sink);
+ SoundState state = device_get_state_from_volume (self);
if (priv->current_sound_state != state){
priv->current_sound_state = state;
sound_service_dbus_update_sound_state (priv->service,
@@ -108,9 +107,9 @@ active_sink_populate (ActiveSink* sink,
}
void
-active_sink_activate_voip_item (ActiveSink* self, gint sink_input_index, gint client_index)
+device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
sink_input_index,
client_index)){
@@ -119,50 +118,50 @@ active_sink_activate_voip_item (ActiveSink* self, gint sink_input_index, gint cl
}
void
-active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible)
+device_deactivate_voip_source (Device* self, gboolean visible)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
}
void
-active_sink_deactivate_voip_client (ActiveSink* self)
+device_deactivate_voip_client (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
}
void
-active_sink_update (ActiveSink* sink,
+device_update (Device* self,
const pa_sink_info* update)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
slider_menu_item_update (priv->volume_slider_menuitem, update);
- SoundState state = active_sink_get_state_from_volume (sink);
+ SoundState state = device_get_state_from_volume (self);
if (priv->current_sound_state != state){
priv->current_sound_state = state;
sound_service_dbus_update_sound_state (priv->service,
priv->current_sound_state);
}
- active_sink_mute_update (sink, update->mute);
+ device_mute_update (self, update->mute);
}
gint
-active_sink_get_current_sink_input_index (ActiveSink* sink)
+device_get_current_sink_input_index (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item);
}
static void
-active_sink_mute_update (ActiveSink* self, gboolean muted)
+device_mute_update (Device* self, gboolean muted)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
mute_menu_item_update (priv->mute_menuitem, muted);
- SoundState state = active_sink_get_state_from_volume (self);
+ SoundState state = device_get_state_from_volume (self);
if (muted == TRUE){
state = MUTED;
@@ -175,9 +174,9 @@ active_sink_mute_update (ActiveSink* self, gboolean muted)
}
void
-active_sink_ensure_sink_is_unmuted (ActiveSink* self)
+device_ensure_sink_is_unmuted (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
if (mute_menu_item_is_muted (priv->mute_menuitem)){
pm_update_mute (FALSE);
}
@@ -185,9 +184,9 @@ active_sink_ensure_sink_is_unmuted (ActiveSink* self)
static SoundState
-active_sink_get_state_from_volume (ActiveSink* self)
+device_get_state_from_volume (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem),
DBUSMENU_VOLUME_MENUITEM_LEVEL);
gdouble volume_percent = g_variant_get_double (v);
@@ -210,9 +209,9 @@ active_sink_get_state_from_volume (ActiveSink* self)
}
void
-active_sink_determine_blocking_state (ActiveSink* self)
+device_determine_blocking_state (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
if (mute_menu_item_is_muted (priv->mute_menuitem)){
/**
We don't want to set the current state to blocking
@@ -224,24 +223,24 @@ active_sink_determine_blocking_state (ActiveSink* self)
}
gint
-active_sink_get_index (ActiveSink* self)
+device_get_index (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return slider_menu_item_get_sink_index (priv->volume_slider_menuitem);
}
gboolean
-active_sink_is_populated (ActiveSink* sink)
+device_is_populated (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_ENABLED);
}
void
-active_sink_deactivate (ActiveSink* self)
+device_deactivate (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
priv->current_sound_state = UNAVAILABLE;
sound_service_dbus_update_sound_state (priv->service,
priv->current_sound_state);
@@ -250,37 +249,37 @@ active_sink_deactivate (ActiveSink* self)
}
SoundState
-active_sink_get_state (ActiveSink* self)
+device_get_state (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return priv->current_sound_state;
}
void
-active_sink_update_voip_input_source (ActiveSink* self, const pa_source_info* update)
+device_update_voip_input_source (Device* self, const pa_source_info* update)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
voip_input_menu_item_update (priv->voip_input_menu_item, update);
}
gboolean
-active_sink_is_voip_source_populated (ActiveSink* self)
+device_is_voip_source_populated (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return voip_input_menu_item_is_populated (priv->voip_input_menu_item);
}
-gint active_sink_get_source_index (ActiveSink* self)
+gint device_get_source_index (Device* self)
{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return voip_input_menu_item_get_index (priv->voip_input_menu_item);
}
-ActiveSink*
-active_sink_new (SoundServiceDbus* service)
+Device*
+device_new (SoundServiceDbus* service)
{
- ActiveSink* sink = g_object_new (ACTIVE_SINK_TYPE, NULL);
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink);
+ Device* sink = g_object_new (DEVICE_TYPE, NULL);
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (sink);
priv->service = service;
sound_service_dbus_build_sound_menu (service,
mute_menu_item_get_button (priv->mute_menuitem),
diff --git a/src/device.h b/src/device.h
new file mode 100644
index 0000000..42d8189
--- /dev/null
+++ b/src/device.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2010 Canonical Ltd.
+ *
+ * Authors:
+ * Conor Curran <conor.curran@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __DEVICE_H__
+#define __DEVICE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "common-defs.h"
+#include "sound-service-dbus.h"
+
+#include <pulse/pulseaudio.h>
+
+G_BEGIN_DECLS
+
+#define DEVICE_TYPE (device_get_type ())
+#define DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DEVICE_TYPE, Device))
+#define DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DEVICE_TYPE, DeviceClass))
+#define IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DEVICE_TYPE))
+#define IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DEVICE_TYPE))
+#define DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DEVICE_TYPE, DeviceClass))
+
+typedef struct _Device Device;
+typedef struct _DeviceClass DeviceClass;
+
+struct _Device {
+ GObject parent;
+};
+
+struct _DeviceClass {
+ GObjectClass parent_class;
+};
+
+GType device_get_type (void) G_GNUC_CONST;
+
+/**
+ * TODO
+ * Refactor this to become a device manager obj basically acting as wrapper for
+ * the communication between pulseaudio-mgr and the individual items.
+ * First steps collapse slider/volume related stuff into slider-menu-item.
+ */
+
+// Sink related
+void device_populate (Device* sink, const pa_sink_info* update);
+void device_update (Device* sink, const pa_sink_info* update);
+gboolean device_is_populated (Device* sink);
+gint device_get_index (Device* self);
+void device_deactivate (Device* self);
+void device_update_mute (Device* self, gboolean mute_update);
+void device_ensure_sink_is_unmuted (Device* self);
+
+// source and sinkinput/client related for VOIP functionality
+void device_update_voip_input_source (Device* sink, const pa_source_info* update);
+void device_activate_voip_item (Device* sink, gint sink_input_index, gint client_index);
+gint device_get_current_sink_input_index (Device* sink);
+gboolean device_is_voip_source_populated (Device* sink);
+gint device_get_source_index (Device* self);
+void device_determine_blocking_state (Device* self);
+void device_deactivate_voip_source (Device* self, gboolean visible);
+void device_deactivate_voip_client (Device* self);
+SoundState device_get_state (Device* self);
+
+Device* device_new (SoundServiceDbus* service);
+
+G_END_DECLS
+
+#endif
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 6d11221..036b46b 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -68,7 +68,7 @@ static void pm_sink_input_info_callback (pa_context *c,
const pa_sink_input_info *info,
int eol,
void *userdata);
-static void pm_update_active_sink (pa_context *c,
+static void pm_update_device (pa_context *c,
const pa_sink_info *info,
int eol,
void *userdata);
@@ -89,11 +89,11 @@ static pa_glib_mainloop *pa_main_loop = NULL;
Entry Point
**/
void
-pm_establish_pulse_connection (ActiveSink* active_sink)
+pm_establish_pulse_connection (Device* device)
{
pa_main_loop = pa_glib_mainloop_new (g_main_context_default ());
g_assert (pa_main_loop);
- reconnect_to_pulse ((gpointer)active_sink);
+ reconnect_to_pulse ((gpointer)device);
}
/**
@@ -119,7 +119,7 @@ reconnect_to_pulse (gpointer user_data)
{
g_debug("Attempt a pulse connection");
// reset
- g_return_val_if_fail (IS_ACTIVE_SINK (user_data), FALSE);
+ g_return_val_if_fail (IS_DEVICE (user_data), FALSE);
connection_attempts += 1;
if (pulse_context != NULL) {
@@ -216,38 +216,38 @@ pm_subscribed_events_callback (pa_context *c,
uint32_t index,
void* userdata)
{
- if (IS_ACTIVE_SINK (userdata) == FALSE){
+ if (IS_DEVICE (userdata) == FALSE){
g_critical ("subscribed events callback - our userdata is not what we think it should be");
return;
}
- ActiveSink* sink = ACTIVE_SINK (userdata);
+ Device* sink = DEVICE (userdata);
switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
case PA_SUBSCRIPTION_EVENT_SINK:
// We don't care about any other sink other than the active one.
- if (index != active_sink_get_index (sink))
+ if (index != device_get_index (sink))
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- active_sink_deactivate (sink);
+ device_deactivate (sink);
}
else{
pa_operation_unref (pa_context_get_sink_info_by_index (c,
index,
- pm_update_active_sink,
+ pm_update_device,
userdata) );
}
break;
case PA_SUBSCRIPTION_EVENT_SOURCE:
g_debug ("Looks like source event of some description - index = %i", index);
// We don't care about any other sink other than the active one.
- if (index != active_sink_get_source_index (sink))
+ if (index != device_get_source_index (sink))
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
g_debug ("Source removal event - index = %i", index);
- active_sink_deactivate_voip_source (sink, FALSE);
+ device_deactivate_voip_source (sink, FALSE);
}
else{
pa_operation_unref (pa_context_get_source_info_by_index (c,
@@ -260,12 +260,12 @@ pm_subscribed_events_callback (pa_context *c,
// We don't care about sink input removals.
g_debug ("sink input event");
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- gint cached_index = active_sink_get_current_sink_input_index (sink);
+ gint cached_index = device_get_current_sink_input_index (sink);
g_debug ("Just saw a sink input removal event - index = %i and cached index = %i", index, cached_index);
if (index == cached_index){
- active_sink_deactivate_voip_client (sink);
+ device_deactivate_voip_client (sink);
}
}
else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
@@ -308,7 +308,7 @@ pm_context_state_callback (pa_context *c, void *userdata)
break;
case PA_CONTEXT_FAILED:
g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
- active_sink_deactivate (ACTIVE_SINK (userdata));
+ device_deactivate (DEVICE (userdata));
if (reconnect_idle_id == 0){
reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
reconnect_to_pulse,
@@ -362,7 +362,7 @@ pm_server_info_callback (pa_context *c,
if (info == NULL) {
g_warning("No PA server - get the hell out of here");
- active_sink_deactivate (ACTIVE_SINK (userdata));
+ device_deactivate (DEVICE (userdata));
return;
}
// Go for the default sink
@@ -373,7 +373,7 @@ pm_server_info_callback (pa_context *c,
pm_default_sink_info_callback,
userdata) )) {
g_warning("pa_context_get_sink_info_by_namet() failed");
- active_sink_deactivate (ACTIVE_SINK (userdata));
+ device_deactivate (DEVICE (userdata));
pa_operation_unref(operation);
return;
}
@@ -382,7 +382,7 @@ pm_server_info_callback (pa_context *c,
pm_sink_info_callback,
userdata))) {
g_warning("pa_context_get_sink_info_list() failed");
- active_sink_deactivate (ACTIVE_SINK (userdata));
+ device_deactivate (DEVICE (userdata));
pa_operation_unref(operation);
return;
}
@@ -421,14 +421,14 @@ pm_sink_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){
+ if (IS_DEVICE (userdata) == FALSE || sink == NULL){
g_warning ("sink info callback - our user data is not what we think it should be or the sink parameter is null");
return;
}
- ActiveSink* a_sink = ACTIVE_SINK (userdata);
- if (active_sink_is_populated (a_sink) == FALSE &&
+ Device* a_sink = DEVICE (userdata);
+ if (device_is_populated (a_sink) == FALSE &&
g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){
- active_sink_populate (a_sink, sink);
+ device_populate (a_sink, sink);
}
}
}
@@ -443,16 +443,16 @@ pm_default_sink_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ if (IS_DEVICE (userdata) == FALSE || info == NULL){
g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null");
return;
}
// Only repopulate if there is a change with regards the index
- if (active_sink_get_index (ACTIVE_SINK (userdata)) == info->index)
+ if (device_get_index (DEVICE (userdata)) == info->index)
return;
g_debug ("Pulse Server has handed us a new default sink");
- active_sink_populate (ACTIVE_SINK (userdata), info);
+ device_populate (DEVICE (userdata), info);
}
}
@@ -466,18 +466,18 @@ pm_sink_input_info_callback (pa_context *c,
return;
}
else {
- if (info == NULL || IS_ACTIVE_SINK (userdata) == FALSE) {
+ if (info == NULL || IS_DEVICE (userdata) == FALSE) {
g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be");
return;
}
- if (IS_ACTIVE_SINK (userdata) == FALSE){
+ if (IS_DEVICE (userdata) == FALSE){
g_warning ("sink input info callback - our user data is not what we think it should be");
return;
}
// Check if this is Voip sink input
gint result = pa_proplist_contains (info->proplist, PA_PROP_MEDIA_ROLE);
- ActiveSink* a_sink = ACTIVE_SINK (userdata);
+ Device* a_sink = DEVICE (userdata);
if (result == 1){
g_debug ("Sink input info has media role property");
@@ -485,7 +485,7 @@ pm_sink_input_info_callback (pa_context *c,
g_debug ("prop role = %s", value);
if (g_strcmp0 (value, "phone") == 0) {
g_debug ("And yes its a VOIP app ... sink input index = %i", info->index);
- active_sink_activate_voip_item (a_sink, (gint)info->index, (gint)info->client);
+ device_activate_voip_item (a_sink, (gint)info->index, (gint)info->client);
// TODO to start with we will assume our source is the same as what this 'client'
// is pointing at. This should probably be more intelligent :
// query for the list of source output info's and going on the name of the client
@@ -494,14 +494,14 @@ pm_sink_input_info_callback (pa_context *c,
}
// And finally check for the mute blocking state
- if (active_sink_get_index (a_sink) == info->sink){
- active_sink_determine_blocking_state (a_sink);
+ if (device_get_index (a_sink) == info->sink){
+ device_determine_blocking_state (a_sink);
}
}
}
static void
-pm_update_active_sink (pa_context *c,
+pm_update_device (pa_context *c,
const pa_sink_info *info,
int eol,
void *userdata)
@@ -510,11 +510,11 @@ pm_update_active_sink (pa_context *c,
return;
}
else{
- if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
- g_warning ("update_active_sink - our user data is not what we think it should be or the info parameter is null");
+ if (IS_DEVICE (userdata) == FALSE || info == NULL){
+ g_warning ("update_device - our user data is not what we think it should be or the info parameter is null");
return;
}
- active_sink_update (ACTIVE_SINK(userdata), info);
+ device_update (DEVICE(userdata), info);
}
}
@@ -551,16 +551,16 @@ pm_default_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ if (IS_DEVICE (userdata) == FALSE || info == NULL){
g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null");
return;
}
// If there is an index change we need to change our cached source
- if (active_sink_get_source_index (ACTIVE_SINK (userdata)) == info->index)
+ if (device_get_source_index (DEVICE (userdata)) == info->index)
return;
g_debug ("Pulse Server has handed us a new default source");
- active_sink_deactivate_voip_source (ACTIVE_SINK (userdata), TRUE);
- active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info);
+ device_deactivate_voip_source (DEVICE (userdata), TRUE);
+ device_update_voip_input_source (DEVICE (userdata), info);
}
}
@@ -574,13 +574,13 @@ pm_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ if (IS_DEVICE (userdata) == FALSE || info == NULL){
g_warning ("source info callback - our user data is not what we think it should be or the source info parameter is null");
return;
}
// For now we will take the first available
- if (active_sink_is_voip_source_populated (ACTIVE_SINK (userdata)) == FALSE){
- active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info);
+ if (device_is_voip_source_populated (DEVICE (userdata)) == FALSE){
+ device_update_voip_input_source (DEVICE (userdata), info);
}
}
}
@@ -595,11 +595,11 @@ pm_update_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL ){
+ if (IS_DEVICE (userdata) == FALSE || info == NULL ){
g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null");
return;
}
g_debug ("Got a source update for %s , index %i", info->name, info->index);
- active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info);
+ device_update_voip_input_source (DEVICE (userdata), info);
}
}
diff --git a/src/pulseaudio-mgr.h b/src/pulseaudio-mgr.h
index d61117d..ace47f3 100644
--- a/src/pulseaudio-mgr.h
+++ b/src/pulseaudio-mgr.h
@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "active-sink.h"
+#include "device.h"
-void pm_establish_pulse_connection (ActiveSink* active_sink);
+void pm_establish_pulse_connection (Device* device);
void close_pulse_activites();
void pm_update_volume (gint sink_index, pa_cvolume new_volume);
void pm_update_mic_gain (gint source_index, pa_cvolume new_gain);
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 270b996..fb66563 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -28,7 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate;
struct _SliderMenuItemPrivate {
- ActiveSink* a_sink;
+ Device* a_sink;
gint index;
gchar* name;
pa_cvolume volume;
@@ -112,7 +112,7 @@ handle_event (DbusmenuMenuitem * mi,
gdouble volume_input = g_variant_get_double(input);
//g_debug ("slider menu item about to update volume %f", volume_input);
slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input);
- active_sink_ensure_sink_is_unmuted (priv->a_sink);
+ device_ensure_sink_is_unmuted (priv->a_sink);
}
}
}
@@ -212,7 +212,7 @@ slider_menu_item_construct_mono_volume (const pa_cvolume* vol)
}
SliderMenuItem*
-slider_menu_item_new (ActiveSink* sink)
+slider_menu_item_new (Device* sink)
{
SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL);
SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h
index b489032..4375971 100644
--- a/src/slider-menu-item.h
+++ b/src/slider-menu-item.h
@@ -23,7 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib-object.h>
#include <libdbusmenu-glib/menuitem.h>
-#include "active-sink.h"
+#include "device.h"
G_BEGIN_DECLS
@@ -56,7 +56,7 @@ void slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update
gint slider_menu_item_get_sink_index (SliderMenuItem* self);
-SliderMenuItem* slider_menu_item_new (ActiveSink* sink);
+SliderMenuItem* slider_menu_item_new (Device* sink);
G_END_DECLS
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 8d0cc0b..7c817af 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -29,7 +29,7 @@
#include <libdbusmenu-glib/client.h>
#include "sound-service-dbus.h"
-#include "active-sink.h"
+#include "device.h"
#include "gen-sound-service.xml.h"
#include "dbus-shared-names.h"
@@ -55,7 +55,7 @@ typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate;
struct _SoundServiceDbusPrivate {
GDBusConnection* connection;
DbusmenuMenuitem* root_menuitem;
- ActiveSink* active_sink;
+ Device* device;
};
static GDBusNodeInfo * node_info = NULL;
@@ -155,7 +155,7 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self)
paths);
dbusmenu_server_set_root (server, priv->root_menuitem);
g_object_unref (priv->root_menuitem);
- priv->active_sink = active_sink_new (self);
+ priv->device = device_new (self);
return priv->root_menuitem;
}
@@ -272,8 +272,8 @@ bus_method_call (GDBusConnection * connection,
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service);
if (g_strcmp0(method, "GetSoundState") == 0) {
- g_debug("Get state - %i", active_sink_get_state (priv->active_sink));
- retval = g_variant_new ( "(i)", active_sink_get_state (priv->active_sink));
+ g_debug("Get state - %i", device_get_state (priv->device));
+ retval = g_variant_new ( "(i)", device_get_state (priv->device));
}
else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) {
gboolean blacklist;
diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c
index a742654..a92f91c 100644
--- a/src/voip-input-menu-item.c
+++ b/src/voip-input-menu-item.c
@@ -28,7 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct _VoipInputMenuItemPrivate VoipInputMenuItemPrivate;
struct _VoipInputMenuItemPrivate {
- ActiveSink* a_sink;
+ Device* a_sink;
pa_cvolume volume;
gint mute;
guint32 volume_steps;
@@ -129,8 +129,6 @@ handle_event (DbusmenuMenuitem * mi,
if (priv->mute == 1) {
pm_update_mic_mute (priv->source_index, 0);
}
- //active_sink_update_volume (priv->a_sink, volume_input);
- //active_sink_ensure_sink_is_unmuted (priv->a_sink);
}
}
}
@@ -268,7 +266,7 @@ voip_input_menu_item_enable (VoipInputMenuItem* item,
}
VoipInputMenuItem*
-voip_input_menu_item_new (ActiveSink* sink)
+voip_input_menu_item_new (Device* sink)
{
VoipInputMenuItem *self = g_object_new(VOIP_INPUT_MENU_ITEM_TYPE, NULL);
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (self);
diff --git a/src/voip-input-menu-item.h b/src/voip-input-menu-item.h
index 6f4ed85..30ada5a 100644
--- a/src/voip-input-menu-item.h
+++ b/src/voip-input-menu-item.h
@@ -22,7 +22,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <pulse/pulseaudio.h>
#include <libdbusmenu-glib/menuitem.h>
-#include "active-sink.h"
+#include "device.h"
G_BEGIN_DECLS
@@ -62,7 +62,7 @@ gint voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item);
void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible);
void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item);
-VoipInputMenuItem* voip_input_menu_item_new (ActiveSink* sink);
+VoipInputMenuItem* voip_input_menu_item_new (Device* sink);
G_END_DECLS