aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/active-sink.c43
-rw-r--r--src/active-sink.h16
-rw-r--r--src/pulseaudio-mgr.c37
-rw-r--r--src/slider-menu-item.c9
-rw-r--r--src/sound-service-dbus.c5
5 files changed, 41 insertions, 69 deletions
diff --git a/src/active-sink.c b/src/active-sink.c
index 1aa6c67..37cdf51 100644
--- a/src/active-sink.c
+++ b/src/active-sink.c
@@ -35,8 +35,8 @@ struct _ActiveSinkPrivate
gint index;
gchar* name;
pa_cvolume volume;
- pa_channel_map channel_map;
- pa_volume_t base_volume;
+ pa_channel_map channel_map;
+ pa_volume_t base_volume;
};
#define ACTIVE_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACTIVE_SINK_TYPE, ActiveSinkPrivate))
@@ -82,15 +82,7 @@ active_sink_init(ActiveSink *self)
static void
active_sink_dispose (GObject *object)
-{
- ActiveSink * self = ACTIVE_SINK(object);
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
-
- /*if (priv->details != NULL) {
- g_free (priv->details->name);
- g_free (priv->details);
- }*/
-
+{
G_OBJECT_CLASS (active_sink_parent_class)->dispose (object);
}
@@ -127,11 +119,18 @@ active_sink_is_populated (ActiveSink* sink)
return (priv->index != -1);
}
-gboolean
-active_sink_is_muted (ActiveSink* self)
+void
+active_sink_determine_blocking_state (ActiveSink* self)
{
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
- return mute_menu_item_is_muted (priv->mute_menuitem);
+ if (mute_menu_item_is_muted (priv->mute_menuitem)){
+ /**
+ We don't want to set the current state to blocking
+ as this is a fire and forget event.
+ */
+ sound_service_dbus_update_sound_state (priv->service,
+ BLOCKED);
+ }
}
gint
@@ -154,6 +153,18 @@ active_sink_update_volume (ActiveSink* self, gdouble percent)
}
void
+active_sink_deactivate (ActiveSink* self)
+{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ priv->current_sound_state = UNAVAILABLE;
+ sound_service_dbus_update_sound_state (priv->service,
+ priv->current_sound_state);
+ priv->index = -1;
+ g_free(priv->name);
+ priv->name = NULL;
+}
+
+void
active_sink_update_mute (ActiveSink* self, gboolean muted)
{
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
@@ -211,8 +222,8 @@ active_sink_construct_mono_volume (const pa_cvolume* vol)
return new_volume;
}
-
-ActiveSink* active_sink_new (SoundServiceDbus* service)
+ActiveSink*
+active_sink_new (SoundServiceDbus* service)
{
ActiveSink* sink = g_object_new (ACTIVE_SINK_TYPE, NULL);
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink);
diff --git a/src/active-sink.h b/src/active-sink.h
index 3b21d94..5fdcba9 100644
--- a/src/active-sink.h
+++ b/src/active-sink.h
@@ -48,24 +48,18 @@ struct _ActiveSinkClass {
GObjectClass parent_class;
};
-/*typedef struct {
- gchar* name;
- gint index;
- pa_cvolume volume;
- pa_channel_map channel_map;
- gboolean mute;
- pa_volume_t base_volume;
-} sink_details;
-*/
-
GType active_sink_get_type (void) G_GNUC_CONST;
void active_sink_populate (ActiveSink* sink, const pa_sink_info* update);
+
gboolean active_sink_is_populated (ActiveSink* sink);
-gboolean active_sink_is_muted (ActiveSink* self);
+void active_sink_determine_blocking_state (ActiveSink* self);
+
gint active_sink_get_index (ActiveSink* self);
SoundState active_sink_get_state (ActiveSink* self);
+void active_sink_deactivate (ActiveSink* self);
+
void active_sink_update_volume (ActiveSink* self, gdouble vol_percent);
void active_sink_update_mute (ActiveSink* self, gboolean muted);
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index eaff2b7..cb786de 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -62,10 +62,7 @@ static void pm_update_active_sink (pa_context *c,
void *userdata);
-//static void pm_populate_active_sink (const pa_sink_info *info, ActiveSink* sink);
static gboolean reconnect_to_pulse (gpointer user_data);
-//static pa_cvolume construct_mono_volume(const pa_cvolume* vol);
-
static gint connection_attempts = 0;
static gint reconnect_idle_id = 0;
@@ -87,9 +84,7 @@ pm_establish_pulse_connection (ActiveSink* active_sink)
pa_context_set_state_callback (pulse_context,
pm_context_state_callback,
(gpointer)active_sink);
-
- //TODO update active sink before init with state at unavailable
-
+
pa_context_connect (pulse_context, NULL, PA_CONTEXT_NOFAIL, (gpointer)active_sink);
}
@@ -144,20 +139,6 @@ reconnect_to_pulse (gpointer user_data)
}
}
-/*static void
-pm_populate_active_sink (const pa_sink_info *info, ActiveSink* sink)
-{
- details->index = info->index;
- details->name = g_strdup (info->name);
- details->mute = !!info->mute;
- details->volume = construct_mono_volume (&info->volume);
- details->base_volume = info->base_volume;
- details->channel_map = info->channel_map;
- active_sink_update_details (sink, details);
- g_debug ("active sink populated with sink %s", details->name);
-
-}*/
-
/**********************************************************************************************************************/
// Pulse-Audio asychronous call-backs
@@ -182,7 +163,8 @@ pm_subscribed_events_callback (pa_context *c,
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- // TODO: Fire of an unavailable state signal and try to find another sink
+ active_sink_deactivate (ACTIVE_SINK (userdata));
+
}
else{
pa_operation_unref (pa_context_get_sink_info_by_index (c,
@@ -228,7 +210,7 @@ pm_context_state_callback (pa_context *c, void *userdata)
break;
case PA_CONTEXT_FAILED:
g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
- // TODO: update state to unvailable on active sink
+ active_sink_deactivate (ACTIVE_SINK (userdata));
if (reconnect_idle_id == 0){
reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
reconnect_to_pulse,
@@ -276,7 +258,7 @@ pm_server_info_callback (pa_context *c,
if (info == NULL) {
g_warning("No PA server - get the hell out of here");
- //TODO update active sink with state info
+ active_sink_deactivate (ACTIVE_SINK (userdata));
return;
}
if (info->default_sink_name != NULL) {
@@ -321,7 +303,6 @@ pm_sink_info_callback (pa_context *c,
if (active_sink_is_populated (a_sink) == FALSE &&
g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){
active_sink_populate (a_sink, sink);
- //populate_active_sink (sink, a_sink);
}
}
}
@@ -333,7 +314,6 @@ pm_default_sink_info_callback (pa_context *c,
void *userdata)
{
if (eol > 0) {
- // TODO what happens here - high and dry!
return;
}
else {
@@ -344,7 +324,6 @@ pm_default_sink_info_callback (pa_context *c,
g_debug ("server has handed us a default sink");
active_sink_populate (ACTIVE_SINK (userdata), info);
- //pm_populate_active_sink (info, ACTIVE_SINK (userdata));
}
}
@@ -369,9 +348,8 @@ pm_sink_input_info_callback (pa_context *c,
}
ActiveSink* a_sink = ACTIVE_SINK (userdata);
- if (active_sink_get_index (a_sink) == info->sink &&
- active_sink_is_muted (a_sink) == TRUE) {
- // TODO fire off blocking signal
+ if (active_sink_get_index (a_sink) == info->sink){
+ active_sink_determine_blocking_state (a_sink);
}
}
}
@@ -393,6 +371,7 @@ pm_update_active_sink (pa_context *c,
pa_volume_t vol = pa_cvolume_max (&info->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
active_sink_update_volume (ACTIVE_SINK(userdata), volume_percent);
+ active_sink_update_mute (ACTIVE_SINK(userdata), info->mute);
}
}
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 3554b0d..6fd4dbc 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -62,12 +62,7 @@ static void slider_menu_item_init (SliderMenuItem *self)
g_debug("Building new Slider Menu Item");
dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
DBUSMENU_MENUITEM_PROP_TYPE,
- DBUSMENU_VOLUME_MENUITEM_TYPE );
-
- /*dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(self),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- TRUE);*/
-
+ DBUSMENU_VOLUME_MENUITEM_TYPE );
return;
}
@@ -110,8 +105,6 @@ handle_event (DbusmenuMenuitem * mi,
void slider_menu_item_update (SliderMenuItem* item,
gdouble update)
{
- // TODO
- // Check if that variant below will leak !!!
GVariant* new_volume = g_variant_new_double(update);
dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item),
DBUSMENU_VOLUME_MENUITEM_LEVEL,
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index f9428cc..58367f4 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -151,7 +151,6 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self)
dbusmenu_server_set_root (server, priv->root_menuitem);
g_object_unref (priv->root_menuitem);
priv->active_sink = active_sink_new (self);
- //establish_pulse_activities (self);
return priv->root_menuitem;
}
@@ -222,9 +221,6 @@ sound_service_dbus_finalize (GObject *object)
// EMIT STATE SIGNAL
-
-// TODO: this will be a bit messy until the pa_manager is sorted.
-// And we figure out all of the edge cases.
void
sound_service_dbus_update_sound_state (SoundServiceDbus* self,
SoundState new_state)
@@ -251,7 +247,6 @@ sound_service_dbus_update_sound_state (SoundServiceDbus* self,
}
//HANDLE DBUS METHOD CALLS
-// TODO we will need to implement the black_list method.
static void
bus_method_call (GDBusConnection * connection,
const gchar * sender,