aboutsummaryrefslogtreecommitdiff
path: root/src/pulse-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse-manager.c')
-rw-r--r--src/pulse-manager.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index d5377bf..40add4e 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -26,8 +26,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <pulse/gccmacro.h>
#include "pulse-manager.h"
-#include "sound-service.h"
-
+#include "dbus-menu-manager.h"
static GHashTable *sink_hash = NULL;
static SoundServiceDbus *dbus_service = NULL;
@@ -69,8 +68,7 @@ void establish_pulse_activities(SoundServiceDbus *service)
// Establish event callback registration
pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
// BUILD MENU ANYWHO - it will be updated
- update_pa_state(FALSE, FALSE, FALSE, 0);
-
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
}
@@ -108,7 +106,7 @@ static void reconnect_to_pulse()
sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
// Establish event callback registration
pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
- update_pa_state(FALSE, FALSE, FALSE, 0);
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
}
@@ -276,12 +274,15 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in
gboolean device_available = determine_sink_availability();
if(device_available == TRUE)
{
- update_pa_state(TRUE, device_available, default_sink_is_muted(), get_default_sink_volume());
+ dbus_menu_manager_update_pa_state(TRUE,
+ device_available,
+ default_sink_is_muted(),
+ get_default_sink_volume());
}
else{
//Update the indicator to show PA either is not ready or has no available sink
g_warning("Cannot find a suitable default sink ...");
- update_pa_state(FALSE, device_available, TRUE, 0);
+ dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume());
}
}
else{
@@ -322,7 +323,7 @@ static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *
}
else
{
- update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume());
+ dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume());
}
}
}
@@ -385,7 +386,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
{
g_debug("Updating Mute from PA manager with mute = %i", s->mute);
sound_service_dbus_update_sink_mute(dbus_service, s->mute);
- update_mute_ui(s->mute);
+ dbus_menu_manager_update_mute_ui(s->mute);
if(s->mute == FALSE){
pa_volume_t vol = pa_cvolume_avg(&s->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
@@ -397,6 +398,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
}
else
{
+
sink_info *value;
value = g_new0(sink_info, 1);
value->index = value->device_index = info->index;
@@ -410,7 +412,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
value->channel_map = info->channel_map;
g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value);
g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");
- }
+ sound_service_dbus_update_sink_availability(dbus_service, TRUE);
+ }
}
@@ -421,7 +424,7 @@ static void pulse_server_info_callback(pa_context *c, const pa_server_info *info
if (info == NULL)
{
g_warning("No server - get the hell out of here");
- update_pa_state(FALSE, FALSE, TRUE, 0);
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0);
pa_server_available = FALSE;
return;
}
@@ -459,8 +462,11 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event
g_debug("PA_SUBSCRIPTION_EVENT_SINK event triggered");
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
{
- //TODO handle the remove event => if its our default sink - update date pa state
- } else
+ if(index == DEFAULT_SINK_INDEX)
+ g_debug("PA_SUBSCRIPTION_EVENT_SINK REMOVAL event triggered");
+ sound_service_dbus_update_sink_availability(dbus_service, FALSE);
+ }
+ else
{
pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata));
}
@@ -469,7 +475,7 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event
g_debug("PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
{
- //TODO handle the remove event
+ //handle the remove event - not relevant for current design
}
else
{