aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-05-19 15:38:17 -0400
committerKen VanDine <ken.vandine@canonical.com>2011-05-19 15:38:17 -0400
commit82a0655d82f040a729b225335b99fafba2786668 (patch)
treee1b1fb58a93f9d990d936cd60956fa7fbd7c42f2 /src
parentab30eadeaaee5ba003feaa5207c77820cc021684 (diff)
parent7a66e3144234408fad971e25f8164eab085fa21f (diff)
downloadayatana-indicator-sound-82a0655d82f040a729b225335b99fafba2786668.tar.gz
ayatana-indicator-sound-82a0655d82f040a729b225335b99fafba2786668.tar.bz2
ayatana-indicator-sound-82a0655d82f040a729b225335b99fafba2786668.zip
Import upstream version 0.7.0
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in32
-rw-r--r--src/device.c25
-rw-r--r--src/device.h4
-rw-r--r--src/metadata-widget.c20
-rw-r--r--src/mpris2-controller.c6
-rw-r--r--src/mpris2-controller.vala1
-rw-r--r--src/pulseaudio-mgr.c69
-rw-r--r--src/sound-service-dbus.c3
-rw-r--r--src/sound-state-manager.c14
-rw-r--r--src/sound-state.c43
-rw-r--r--src/sound-state.h31
-rw-r--r--src/voip-input-menu-item.c18
-rw-r--r--src/voip-input-menu-item.h4
14 files changed, 200 insertions, 74 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ae0d55a..bafd6be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,8 @@ libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
indicator-sound.c \
+ sound-state.c \
+ sound-state.h \
sound-state-manager.c \
sound-state-manager.h \
transport-widget.c \
@@ -90,6 +92,8 @@ indicator_sound_service_SOURCES = \
common-defs.h \
sound-service.h \
sound-service.c \
+ sound-state.c \
+ sound-state.h \
pulseaudio-mgr.h \
pulseaudio-mgr.c \
device.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 0cffd55..2011cba 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -73,6 +73,7 @@ LTLIBRARIES = $(soundmenulib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libsoundmenu_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_libsoundmenu_la_OBJECTS = libsoundmenu_la-indicator-sound.lo \
+ libsoundmenu_la-sound-state.lo \
libsoundmenu_la-sound-state-manager.lo \
libsoundmenu_la-transport-widget.lo \
libsoundmenu_la-metadata-widget.lo \
@@ -104,6 +105,7 @@ am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \
indicator_sound_service-fetch-file.$(OBJEXT)
am_indicator_sound_service_OBJECTS = \
indicator_sound_service-sound-service.$(OBJEXT) \
+ indicator_sound_service-sound-state.$(OBJEXT) \
indicator_sound_service-pulseaudio-mgr.$(OBJEXT) \
indicator_sound_service-device.$(OBJEXT) \
indicator_sound_service-sound-service-dbus.$(OBJEXT) \
@@ -321,6 +323,8 @@ libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
indicator-sound.c \
+ sound-state.c \
+ sound-state.h \
sound-state-manager.c \
sound-state-manager.h \
transport-widget.c \
@@ -390,6 +394,8 @@ indicator_sound_service_SOURCES = \
common-defs.h \
sound-service.h \
sound-service.c \
+ sound-state.c \
+ sound-state.h \
pulseaudio-mgr.h \
pulseaudio-mgr.c \
device.c \
@@ -574,6 +580,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-slider-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service-dbus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-state.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-title-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-transport-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-voip-input-menu-item.Po@am__quote@
@@ -581,6 +588,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-indicator-sound.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-metadata-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-sound-state-manager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-sound-state.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-title-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-transport-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-voip-input-widget.Plo@am__quote@
@@ -618,6 +626,14 @@ libsoundmenu_la-indicator-sound.lo: indicator-sound.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
+libsoundmenu_la-sound-state.lo: sound-state.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-sound-state.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-sound-state.Tpo -c -o libsoundmenu_la-sound-state.lo `test -f 'sound-state.c' || echo '$(srcdir)/'`sound-state.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-sound-state.Tpo $(DEPDIR)/libsoundmenu_la-sound-state.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-state.c' object='libsoundmenu_la-sound-state.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-sound-state.lo `test -f 'sound-state.c' || echo '$(srcdir)/'`sound-state.c
+
libsoundmenu_la-sound-state-manager.lo: sound-state-manager.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-sound-state-manager.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-sound-state-manager.Tpo -c -o libsoundmenu_la-sound-state-manager.lo `test -f 'sound-state-manager.c' || echo '$(srcdir)/'`sound-state-manager.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-sound-state-manager.Tpo $(DEPDIR)/libsoundmenu_la-sound-state-manager.Plo
@@ -690,6 +706,22 @@ indicator_sound_service-sound-service.obj: sound-service.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-sound-service.obj `if test -f 'sound-service.c'; then $(CYGPATH_W) 'sound-service.c'; else $(CYGPATH_W) '$(srcdir)/sound-service.c'; fi`
+indicator_sound_service-sound-state.o: sound-state.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-state.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-state.Tpo -c -o indicator_sound_service-sound-state.o `test -f 'sound-state.c' || echo '$(srcdir)/'`sound-state.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-sound-state.Tpo $(DEPDIR)/indicator_sound_service-sound-state.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-state.c' object='indicator_sound_service-sound-state.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-sound-state.o `test -f 'sound-state.c' || echo '$(srcdir)/'`sound-state.c
+
+indicator_sound_service-sound-state.obj: sound-state.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-state.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-state.Tpo -c -o indicator_sound_service-sound-state.obj `if test -f 'sound-state.c'; then $(CYGPATH_W) 'sound-state.c'; else $(CYGPATH_W) '$(srcdir)/sound-state.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-sound-state.Tpo $(DEPDIR)/indicator_sound_service-sound-state.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-state.c' object='indicator_sound_service-sound-state.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-sound-state.obj `if test -f 'sound-state.c'; then $(CYGPATH_W) 'sound-state.c'; else $(CYGPATH_W) '$(srcdir)/sound-state.c'; fi`
+
indicator_sound_service-pulseaudio-mgr.o: pulseaudio-mgr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-pulseaudio-mgr.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-pulseaudio-mgr.Tpo -c -o indicator_sound_service-pulseaudio-mgr.o `test -f 'pulseaudio-mgr.c' || echo '$(srcdir)/'`pulseaudio-mgr.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-pulseaudio-mgr.Tpo $(DEPDIR)/indicator_sound_service-pulseaudio-mgr.Po
diff --git a/src/device.c b/src/device.c
index 79b7b50..84db596 100644
--- a/src/device.c
+++ b/src/device.c
@@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mute-menu-item.h"
#include "voip-input-menu-item.h"
#include "pulseaudio-mgr.h"
+#include "sound-state.h"
typedef struct _DevicePrivate DevicePrivate;
@@ -123,10 +124,10 @@ device_sink_update (Device* self,
}
gint
-device_get_current_sink_input_index (Device* self)
+device_get_voip_source_output_index (Device* self)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item);
+ return voip_input_menu_item_get_source_output_index (priv->voip_input_menu_item);
}
static void
@@ -164,21 +165,7 @@ device_get_state_from_volume (Device* self)
DBUSMENU_VOLUME_MENUITEM_LEVEL);
gdouble volume_percent = g_variant_get_double (v);
- SoundState state = LOW_LEVEL;
-
- if (volume_percent < 30.0 && volume_percent > 0) {
- state = LOW_LEVEL;
- }
- else if (volume_percent < 70.0 && volume_percent >= 30.0) {
- state = MEDIUM_LEVEL;
- }
- else if (volume_percent >= 70.0) {
- state = HIGH_LEVEL;
- }
- else if (volume_percent == 0.0) {
- state = ZERO_LEVEL;
- }
- return state;
+ return sound_state_get_from_volume ((int)volume_percent);
}
void
@@ -211,11 +198,11 @@ device_is_sink_populated (Device* self)
}
void
-device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
+device_activate_voip_item (Device* self, gint source_output_index, gint client_index)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
- sink_input_index,
+ source_output_index,
client_index)){
voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
}
diff --git a/src/device.h b/src/device.h
index 9c74344..ccaf4ea 100644
--- a/src/device.h
+++ b/src/device.h
@@ -68,8 +68,8 @@ 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);
+void device_activate_voip_item (Device* sink, gint source_output_index, gint client_index);
+gint device_get_voip_source_output_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);
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index a37053b..38ed529 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -106,8 +106,7 @@ metadata_widget_init (MetadataWidget *self)
g_signal_connect(priv->album_art, "expose-event",
G_CALLBACK(metadata_image_expose),
- GTK_WIDGET(self));
- gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
+ GTK_WIDGET(self));
gtk_box_pack_start (GTK_BOX (priv->hbox),
priv->album_art,
@@ -190,26 +189,29 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE ||
priv->theme_change_occured == TRUE){
priv->theme_change_occured = FALSE;
- GdkPixbuf* orig_pixbuf;
- orig_pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
+ GdkPixbuf* pixbuf;
+ pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL);
//g_debug("metadata_load_new_image -> pixbuf from %s",
// priv->image_path->str);
- if(GDK_IS_PIXBUF(orig_pixbuf) == FALSE){
+ if(GDK_IS_PIXBUF(pixbuf) == FALSE){
//g_debug("problem loading the downloaded image just use the placeholder instead");
+ gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
draw_album_art_placeholder(metadata);
return TRUE;
}
- GdkPixbuf* pixbuf;
- pixbuf = gdk_pixbuf_scale_simple(orig_pixbuf,60, 60, GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf);
+ gtk_widget_set_size_request(GTK_WIDGET(priv->album_art),
+ gdk_pixbuf_get_width(pixbuf),
+ gdk_pixbuf_get_height(pixbuf));
+
g_string_erase(priv->old_image_path, 0, -1);
g_string_overwrite(priv->old_image_path, 0, priv->image_path->str);
- g_object_unref(pixbuf);
- g_object_unref(orig_pixbuf);
+ g_object_unref(pixbuf);
}
return FALSE;
}
+ gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
draw_album_art_placeholder(metadata);
return TRUE;
}
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c
index 0b84e72..8e381d6 100644
--- a/src/mpris2-controller.c
+++ b/src/mpris2-controller.c
@@ -472,7 +472,7 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
_tmp0_ = _tmp1_ == FALSE;
}
if (_tmp0_) {
- g_warning ("mpris2-controller.vala:71: Property-changed hash is null or this is an" \
+ g_warning ("mpris2-controller.vala:72: Property-changed hash is null or this is an" \
" interface that doesn't concern us");
return;
}
@@ -989,7 +989,7 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl
playlists_menuitem_update (data->playlists_item, data->current_playlists, data->current_playlists_length1);
_g_object_unref0 (data->playlists_item);
} else {
- g_warning ("mpris2-controller.vala:240: Playlists are on but its returning no cur" \
+ g_warning ("mpris2-controller.vala:241: Playlists are on but its returning no cur" \
"rent_playlists");
data->_tmp5_ = FALSE;
data->_tmp6_ = __bool_dup0 (&data->_tmp5_);
@@ -1245,7 +1245,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- g_critical ("mpris2-controller.vala:60: Problems connecting to the session bus - %s", e->message);
+ g_critical ("mpris2-controller.vala:61: Problems connecting to the session bus - %s", e->message);
_g_error_free0 (e);
}
__finally13:
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 04ceb88..9a0c1a5 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -16,6 +16,7 @@ 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/>.
*/
+
using Dbusmenu;
using Transport;
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 95f4c06..a31084a 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -76,7 +76,10 @@ static void pm_toggle_mute_for_every_sink_callback (pa_context *c,
const pa_sink_info *sink,
int eol,
void* userdata);
-
+static void pm_source_output_info_callback (pa_context *c,
+ const pa_source_output_info *info,
+ int eol,
+ void *userdata);
static gboolean reconnect_to_pulse (gpointer user_data);
@@ -257,23 +260,29 @@ pm_subscribed_events_callback (pa_context *c,
}
break;
case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
- // We don't care about sink input removals.
- g_debug ("sink input event");
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
+ g_debug ("some new sink input event ? - index = %i", index);
+ // Maybe blocking state ?.
+ pa_operation_unref (pa_context_get_sink_input_info (c,
+ index,
+ pm_sink_input_info_callback, userdata));
+ }
+ break;
+ case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
+ g_debug ("source output event");
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- 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){
+ gint cached_source_output_index = device_get_voip_source_output_index (sink);
+ if (index == cached_source_output_index){
+ g_debug ("Just saw a source output removal event - index = %i and cached index = %i", index, cached_source_output_index);
device_deactivate_voip_client (sink);
}
}
else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
- g_debug ("some new sink input event ? - index = %i", index);
- // Determine if its a VOIP app or a maybe blocking state.
- pa_operation_unref (pa_context_get_sink_input_info (c,
- index,
- pm_sink_input_info_callback, userdata));
+ g_debug ("some new source output event ? - index = %i", index);
+ // Determine if its a VOIP app.
+ pa_operation_unref (pa_context_get_source_output_info (c,
+ index,
+ pm_source_output_info_callback, userdata));
}
break;
case PA_SUBSCRIPTION_EVENT_SERVER:
@@ -333,6 +342,7 @@ pm_context_state_callback (pa_context *c, void *userdata)
(PA_SUBSCRIPTION_MASK_SINK|
PA_SUBSCRIPTION_MASK_SOURCE|
PA_SUBSCRIPTION_MASK_SINK_INPUT|
+ PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT|
PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) {
g_warning("pa_context_subscribe() failed");
@@ -470,21 +480,39 @@ pm_sink_input_info_callback (pa_context *c,
g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be");
return;
}
+ Device* a_sink = DEVICE (userdata);
+ // And finally check for the mute blocking state
+ if (device_get_sink_index (a_sink) == info->sink){
+ device_determine_blocking_state (a_sink);
+ }
+ }
+}
- if (IS_DEVICE (userdata) == FALSE){
- g_warning ("sink input info callback - our user data is not what we think it should be");
+static void
+pm_source_output_info_callback (pa_context *c,
+ const pa_source_output_info *info,
+ int eol,
+ void *userdata)
+{
+ if (eol > 0) {
+ return;
+ }
+ else {
+ if (info == NULL || IS_DEVICE (userdata) == FALSE) {
+ g_warning("Source output callback: SOURCE OUTPUT INFO IS NULL or 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);
Device* a_sink = DEVICE (userdata);
if (result == 1){
- g_debug ("Sink input info has media role property");
+ //g_debug ("Source output info has media role property");
const char* value = pa_proplist_gets (info->proplist, PA_PROP_MEDIA_ROLE);
- g_debug ("prop role = %s", value);
+ //g_debug ("prop role = %s", value);
if (g_strcmp0 (value, "phone") == 0 || g_strcmp0 (value, "production") == 0) {
- g_debug ("And yes its a VOIP app ... sink input index = %i", info->index);
+ g_debug ("We have a VOIP/PRODUCTION ! - index = %i", info->index);
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 :
@@ -492,11 +520,6 @@ pm_sink_input_info_callback (pa_context *c,
// from the sink input ensure our voip item is using the right source.
}
}
-
- // And finally check for the mute blocking state
- if (device_get_sink_index (a_sink) == info->sink){
- device_determine_blocking_state (a_sink);
- }
}
}
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index a22e648..d0fd765 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -200,7 +200,8 @@ show_sound_settings_dialog (DbusmenuMenuitem *mi,
{
GError * error = NULL;
if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) &&
- !g_spawn_command_line_async("xfce4-mixer", &error))
+ !g_spawn_command_line_async("gnome-control-center sound", &error) &&
+ !g_spawn_command_line_async("xfce4-mixer", &error))
{
g_warning("Unable to show dialog: %s", error->message);
g_error_free(error);
diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c
index 7095a39..c851407 100644
--- a/src/sound-state-manager.c
+++ b/src/sound-state-manager.c
@@ -24,6 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-state-manager.h"
#include "dbus-shared-names.h"
+#include "sound-state.h"
typedef struct _SoundStateManagerPrivate SoundStateManagerPrivate;
@@ -170,19 +171,20 @@ sound_state_manager_show_notification (SoundStateManager *self,
char *icon;
const int notify_value = CLAMP((int)value, -1, 101);
- SoundState state = sound_state_manager_get_current_state (self);
+
+ SoundState state = sound_state_get_from_volume ((int)value);
if (state == ZERO_LEVEL) {
// Not available for all the themes
- icon = "audio-volume-off";
+ icon = "notification-audio-volume-off";
} else if (state == LOW_LEVEL) {
- icon = "audio-volume-low";
+ icon = "notification-audio-volume-low";
} else if (state == MEDIUM_LEVEL) {
- icon = "audio-volume-medium";
+ icon = "notification-audio-volume-medium";
} else if (state == HIGH_LEVEL) {
- icon = "audio-volume-high";
+ icon = "notification-audio-volume-high";
} else {
- icon = "audio-volume-muted";
+ icon = "notification-audio-volume-muted";
}
notify_notification_update(priv->notification, PACKAGE_NAME, NULL, icon);
diff --git a/src/sound-state.c b/src/sound-state.c
new file mode 100644
index 0000000..72e411a
--- /dev/null
+++ b/src/sound-state.c
@@ -0,0 +1,43 @@
+/*
+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/>.
+*/
+
+#include "config.h"
+
+#include "sound-state.h"
+
+SoundState
+sound_state_get_from_volume (int volume_percent)
+{
+ SoundState state = LOW_LEVEL;
+
+ if (volume_percent < 30 && volume_percent > 0) {
+ state = LOW_LEVEL;
+ }
+ else if (volume_percent < 70 && volume_percent >= 30) {
+ state = MEDIUM_LEVEL;
+ }
+ else if (volume_percent >= 70) {
+ state = HIGH_LEVEL;
+ }
+ else if (volume_percent <= 0) {
+ state = ZERO_LEVEL;
+ }
+ return state;
+}
+
diff --git a/src/sound-state.h b/src/sound-state.h
new file mode 100644
index 0000000..9527c8e
--- /dev/null
+++ b/src/sound-state.h
@@ -0,0 +1,31 @@
+/*
+Copyright 2011 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 _SOUND_STATE_H_
+#define _SOUND_STATE_H_
+
+#include <glib.h>
+#include "common-defs.h"
+
+/* Helper functions for determining SOUNDSTATE */
+
+SoundState sound_state_get_from_volume (int volume_percent);
+
+#endif /* _SOUND_STATE_H_ */
+
diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c
index e645e69..7cbdd45 100644
--- a/src/voip-input-menu-item.c
+++ b/src/voip-input-menu-item.c
@@ -35,7 +35,7 @@ struct _VoipInputMenuItemPrivate {
pa_channel_map channel_map;
pa_volume_t base_volume;
gint source_index;
- gint sink_input_index;
+ gint source_output_index;
gint client_index;
};
@@ -82,7 +82,7 @@ voip_input_menu_item_init (VoipInputMenuItem *self)
FALSE );
priv->source_index = NOT_ACTIVE;
- priv->sink_input_index = NOT_ACTIVE;
+ priv->source_output_index = NOT_ACTIVE;
priv->client_index = NOT_ACTIVE;
priv->mute = NOT_ACTIVE;
}
@@ -183,18 +183,18 @@ voip_input_menu_item_update (VoipInputMenuItem* item,
gboolean
voip_input_menu_item_is_interested (VoipInputMenuItem* item,
- gint sink_input_index,
+ gint source_output_index,
gint client_index)
{
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item);
// Check to make sure we are not handling another voip beforehand and that we
// have an active sink (might need to match up at start up)
- if (priv->sink_input_index != NOT_ACTIVE &&
+ if (priv->source_output_index != NOT_ACTIVE &&
priv->source_index != NOT_ACTIVE){
return FALSE;
}
- priv->sink_input_index = sink_input_index;
+ priv->source_output_index = source_output_index;
priv->client_index = client_index;
return TRUE;
@@ -204,7 +204,7 @@ gboolean
voip_input_menu_item_is_active (VoipInputMenuItem* item)
{
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item);
- return (priv->sink_input_index != NOT_ACTIVE && priv->client_index != NOT_ACTIVE);
+ return (priv->source_output_index != NOT_ACTIVE && priv->client_index != NOT_ACTIVE);
}
@@ -223,11 +223,11 @@ voip_input_menu_item_get_index (VoipInputMenuItem* item)
}
gint
-voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item)
+voip_input_menu_item_get_source_output_index (VoipInputMenuItem* item)
{
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item);
- return priv->sink_input_index;
+ return priv->source_output_index;
}
/**
@@ -250,7 +250,7 @@ voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item)
{
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item);
priv->client_index = NOT_ACTIVE;
- priv->sink_input_index = NOT_ACTIVE;
+ priv->source_output_index = NOT_ACTIVE;
voip_input_menu_item_enable (item, FALSE);
}
diff --git a/src/voip-input-menu-item.h b/src/voip-input-menu-item.h
index 30ada5a..1446e03 100644
--- a/src/voip-input-menu-item.h
+++ b/src/voip-input-menu-item.h
@@ -50,14 +50,14 @@ void voip_input_menu_item_update (VoipInputMenuItem* item,
const pa_source_info* source);
void voip_input_menu_item_enable (VoipInputMenuItem* item, gboolean active);
gboolean voip_input_menu_item_is_interested (VoipInputMenuItem* item,
- gint sink_input_index,
+ gint source_output_index,
gint client_index);
gboolean voip_input_menu_item_is_active (VoipInputMenuItem* item);
gboolean voip_input_menu_item_is_populated (VoipInputMenuItem* item);
// TODO rename get source index
gint voip_input_menu_item_get_index (VoipInputMenuItem* item);
-gint voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item);
+gint voip_input_menu_item_get_source_output_index (VoipInputMenuItem* item);
void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible);
void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item);