aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-22 23:37:45 -0600
committerConor Curran <conor.curran@canonical.com>2011-01-22 23:37:45 -0600
commit1ccf02c850145706776fd2c79a30a33a02df50b3 (patch)
treefb0c092292dc76bba69cf5aeff24b3ca13176e0f
parent5f6cebbcfffa32bffada62659e750ab7d362802e (diff)
downloadayatana-indicator-sound-1ccf02c850145706776fd2c79a30a33a02df50b3.tar.gz
ayatana-indicator-sound-1ccf02c850145706776fd2c79a30a33a02df50b3.tar.bz2
ayatana-indicator-sound-1ccf02c850145706776fd2c79a30a33a02df50b3.zip
signals and methods cut down to size, next the indicator
-rw-r--r--src/common-defs.h10
-rw-r--r--src/dbus-shared-names.h5
-rw-r--r--src/indicator-sound.c2
-rw-r--r--src/pulse-manager.c12
-rw-r--r--src/sound-service-dbus.c54
-rw-r--r--src/sound-service-dbus.h1
-rw-r--r--src/sound-service.xml32
7 files changed, 64 insertions, 52 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index 5b5c418..3e6b004 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -16,14 +16,10 @@ 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 __COMMON_DEFS_H__
+#define __COMMON_DEFS_H__
-/* constants used for signals on the dbus. This file is shared between client and server implementation */
-#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
-#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
-#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
-
typedef enum {
MUTED,
ZERO_LEVEL,
@@ -67,3 +63,5 @@ typedef enum {
#define DBUSMENU_PLAYLISTS_MENUITEM_TYPE "x-canonical-sound-menu-player-playlists-type"
#define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title"
#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists"
+
+#endif
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index bdc40cb..b90d7a2 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -30,9 +30,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH "/com/canonical/indicators/sound/service"
#define INDICATOR_SOUND_DBUS_INTERFACE "com.canonical.indicators.sound"
#define INDICATOR_SOUND_DBUS_VERSION 0
-#define INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
-#define INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
+
+#define INDICATOR_SOUND_SIGNAL_SOUND_STATE_UPDATE "SoundStateUpdate"
#endif /* __DBUS_SHARED_NAMES_H__ */
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 3867f27..e0d2209 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -636,7 +636,7 @@ void
determine_state_from_volume(gdouble volume_percent)
{
if (device_available == FALSE)
- return;
+v return;
gint state = previous_state;
if (volume_percent < 30.0 && volume_percent > 0) {
state = STATE_LOW;
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 21b78b2..40bfc13 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -199,10 +199,12 @@ static void check_sink_input_while_muted_event(gint sink_index)
/* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/
if (default_sink_is_muted(sink_index) == TRUE) {
- sound_service_dbus_sink_input_while_muted(dbus_service, TRUE);
- } else {
- sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
+ sound_service_dbus_update_sound_state(dbus_service, BLOCKED);
}
+// Why do you need to send a false for a blocked event, it times out after 5 secs anyway
+//} else {
+ // sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
+ //}
}
static gdouble get_default_sink_volume()
@@ -437,7 +439,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
value->base_volume = info->base_volume;
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_sound_state(dbus_service, TRUE);
+ sound_service_dbus_update_sound_state(dbus_service, AVAILABLE);
}
}
@@ -496,7 +498,7 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event
case PA_SUBSCRIPTION_EVENT_SINK:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
if (index == DEFAULT_SINK_INDEX)
- sound_service_dbus_update_sink_availability(dbus_service, FALSE);
+ sound_service_dbus_update_sound_state(dbus_service, UNAVAILABLE);
/* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/
g_hash_table_remove(sink_hash, GINT_TO_POINTER(index));
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index c0e02ab..20546fc 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -32,7 +32,6 @@
#include "gen-sound-service.xml.h"
#include "dbus-shared-names.h"
-#include "common-defs.h"
#include "pulse-manager.h"
#include "slider-menu-item.h"
#include "mute-menu-item.h"
@@ -80,7 +79,7 @@ static void sound_service_dbus_build_sound_menu ( SoundServiceDbus* root,
gdouble volume );
static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
gpointer user_data);
-static void sound_service_dbus_set_state_from_volume (SoundServiceDbus* self);
+static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* self);
G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
@@ -293,21 +292,62 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj,
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
mute_menu_item_update (priv->mute_menuitem, mute_update);
}
+
// 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)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
-
+ SoundState update = new_state;
if (new_state == AVAILABLE &&
- dbusmenu_menuitem_property_get_bool (priv->mute_menuitem, DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE){
- sound_service_dbus_set_state_from_volume (self);
+ dbusmenu_menuitem_property_get_bool ( DBUSMENU_MENUITEM(priv->mute_menuitem),
+ DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE ){
+ update = sound_service_dbus_get_state_from_volume (self);
+ }
+
+ GVariant* v_output = g_variant_new("(i)", (int)update);
+
+ GError * error = NULL;
+
+ g_dbus_connection_emit_signal( priv->connection,
+ NULL,
+ INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH,
+ INDICATOR_SOUND_DBUS_INTERFACE,
+ INDICATOR_SOUND_SIGNAL_SOUND_STATE_UPDATE,
+ v_output,
+ &error );
+ if (error != NULL) {
+ g_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message);
+ g_error_free(error);
+ return;
}
+
+
}
-static void sound_service_dbus_set_state_from_volume (SoundServiceDbus* self)
+static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* self)
{
- //SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ GVariant* v = dbusmenu_menuitem_get_variant (DBUSMENU_MENUITEM(priv->volume_menuitem),
+ 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;
}
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
index 127ede2..fab3549 100644
--- a/src/sound-service-dbus.h
+++ b/src/sound-service-dbus.h
@@ -23,6 +23,7 @@
#include <glib.h>
#include <glib-object.h>
#include <libdbusmenu-glib/menuitem.h>
+#include "common-defs.h"
G_BEGIN_DECLS
diff --git a/src/sound-service.xml b/src/sound-service.xml
index 44ecc2b..07c9c3d 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -1,45 +1,17 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/com/canonical/indicators/sound">
<interface name="com.canonical.indicators.sound">
- <method name = "GetSinkMute">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_mute"/>
- <arg type='b' name='mute_input' direction="out"/>
- </method>
-
<method name = "BlacklistMediaPlayer">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_blacklist_media_player"/>
<arg type='s' name='player_desktop_name' direction="in"/>
</method>
-
- <method name = "GetSinkAvailability">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_availability"/>
- <arg type='b' name='availability_input' direction="out"/>
- </method>
-
- <method name = "GetSinkState">
+ <method name = "GetSoundState">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_state"/>
<arg type='i' name='current_state' direction="out"/>
</method>
-
-<!-- Will need to hook up another signal which monitors for volume change
-Our respective UI element should listen to this and therefore will be updated with accurate setting-->
-<!-- Triggered when a sink is muted but the input has been sent to that sink -->
- <signal name="SinkInputWhileMuted">
- <arg name="block_value" type="b" direction="out"/>
- </signal>
-
- <signal name="SinkStateUpdate">
+ <signal name="SoundStateUpdate">
<arg name="new_state" type="i" direction="out"/>
</signal>
-
- <signal name="SinkMuteUpdate">
- <arg name="mute_value" type="b" direction="out"/>
- </signal>
-
- <signal name="SinkAvailableUpdate">
- <arg name="available_value" type="b" direction="out"/>
- </signal>
-
</interface>
</node>