aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-16 12:36:43 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-16 12:36:43 +0000
commitde3ed4111ef50b847e1ba4d6ea06e13f913ba7a0 (patch)
treedd63dbbc059bd9a51564884d28ea704f18c1cfe9 /src
parentbb13f9134c42480ada8128cfbd3b19ec2d68865b (diff)
downloadayatana-indicator-sound-de3ed4111ef50b847e1ba4d6ea06e13f913ba7a0.tar.gz
ayatana-indicator-sound-de3ed4111ef50b847e1ba4d6ea06e13f913ba7a0.tar.bz2
ayatana-indicator-sound-de3ed4111ef50b847e1ba4d6ea06e13f913ba7a0.zip
race condtion on playbackstatus accommodated for and dbus names changed over the new canonical naming
Diffstat (limited to 'src')
-rw-r--r--src/dbus-shared-names.h2
-rw-r--r--src/indicator-sound.c4
-rw-r--r--src/mpris2-controller.vala15
-rw-r--r--src/music-player-bridge.vala10
-rw-r--r--src/player-controller.vala7
-rw-r--r--src/pulse-manager.c4
-rw-r--r--src/sound-service.xml4
7 files changed, 29 insertions, 17 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index a62238b..9d1e875 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -23,7 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DBUS_SHARED_NAMES_H__
-#define __DBUS_SHARED_NAMES_H__
+#define __DBUS_SHARED_NAMES_H__ 1
#define INDICATOR_SOUND_DBUS_NAME "com.canonical.indicators.sound"
#define INDICATOR_SOUND_DBUS_OBJECT "/com/canonical/indicators/sound/menu"
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index d5cc54c..34f5ed9 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -561,7 +561,7 @@ fetch_sink_availability_from_dbus(IndicatorSound* self)
GError * error = NULL;
gboolean * available_input;
available_input = g_new0(gboolean, 1);
- org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error);
+ com_canonical_indicators_sound_get_sink_availability(sound_dbus_proxy, available_input, &error);
if (error != NULL) {
g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message);
g_error_free(error);
@@ -593,7 +593,7 @@ fetch_mute_value_from_dbus()
GError * error = NULL;
gboolean *mute_input;
mute_input = g_new0(gboolean, 1);
- org_ayatana_indicator_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error);
+ com_canonical_indicators_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error);
if (error != NULL) {
g_warning("Unable to fetch MUTE at indicator start up: %s", error->message);
g_error_free(error);
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 42d08c9..7f14efe 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -46,7 +46,7 @@ public class Mpris2Controller : GLib.Object
try {
this.mpris2_root = Bus.get_proxy_sync ( BusType.SESSION,
this.owner.dbus_name,
- "/org/mpris/MediaPlayer2");
+ "/org/mpris/MediaPlayer2" );
this.player = Bus.get_proxy_sync ( BusType.SESSION,
this.owner.dbus_name,
"/org/mpris/MediaPlayer2" );
@@ -73,7 +73,11 @@ public class Mpris2Controller : GLib.Object
}
Variant? play_v = changed_properties.lookup("PlaybackStatus");
if(play_v != null){
+ // Race condition sometimes appears with the playback status
+ // 200ms timeout ensures we have the correct playback status at all times.
string state = this.player.PlaybackStatus;
+ //debug("in the property update and the playback status = %s and update = %s", state, (string)play_v);
+ Timeout.add ( 200, ensure_correct_playback_status );
TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state);
(this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
}
@@ -81,7 +85,7 @@ public class Mpris2Controller : GLib.Object
if(meta_v != null){
GLib.HashTable<string, Variant?> changed_updates = clean_metadata();
PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA];
- metadata.reset( MetadataMenuitem.attributes_format());
+ metadata.reset ( MetadataMenuitem.attributes_format());
metadata.update ( changed_updates,
MetadataMenuitem.attributes_format());
metadata.property_set_bool ( MENUITEM_PROP_VISIBLE,
@@ -89,6 +93,13 @@ public class Mpris2Controller : GLib.Object
}
}
+ private bool ensure_correct_playback_status(){
+ debug("TEST playback status = %s", this.player.PlaybackStatus);
+ TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus);
+ (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
+ return false;
+ }
+
private GLib.HashTable<string, Variant?>? clean_metadata()
{
GLib.HashTable<string, Variant?> changed_updates = this.player.Metadata;
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index b13b7f3..327a775 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -58,11 +58,11 @@ public class MusicPlayerBridge : GLib.Object
var mpris_key = determine_key ( path );
PlayerController ctrl = new PlayerController ( this.root_menu,
app_info,
- mpris_key,
+ null,
this.fetch_icon_name(path),
calculate_menu_position(),
PlayerController.state.OFFLINE );
- this.registered_clients.set(mpris_key, ctrl);
+ this.registered_clients.set(mpris_key, ctrl);
}
}
@@ -94,7 +94,7 @@ public class MusicPlayerBridge : GLib.Object
var mpris_key = determine_key ( path );
// Are we sure clients will appear like this with the new registration method in place.
if ( this.registered_clients.has_key (mpris_key) == false ){
- debug("New client has registered that we have not seen before: %s", desktop );
+ debug("New client has registered that we have not seen before: %s", dbus_name );
PlayerController ctrl = new PlayerController ( this.root_menu,
app_info,
dbus_name,
@@ -108,8 +108,8 @@ public class MusicPlayerBridge : GLib.Object
}
else{
this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
- this.registered_clients[mpris_key].activate ( );
- debug("Application has already registered - awaken the hibernation: %s \n", path);
+ this.registered_clients[mpris_key].activate ( dbus_name );
+ debug("Application has already registered - awaken the hibernation: %s \n", dbus_name );
}
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 9e00258..b5c2d76 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -53,7 +53,7 @@ public class PlayerController : GLib.Object
public PlayerController(Dbusmenu.Menuitem root,
GLib.AppInfo app,
- string dbus_name,
+ string? dbus_name,
string icon_name,
int offset,
state initial_state)
@@ -78,8 +78,9 @@ public class PlayerController : GLib.Object
this.update_layout();
}
- public void activate()
+ public void activate( string dbus_name )
{
+ this.dbus_name = dbus_name;
this.establish_mpris_connection();
}
@@ -103,7 +104,7 @@ public class PlayerController : GLib.Object
private void establish_mpris_connection()
{
- if(this.current_state != state.READY){
+ if(this.current_state != state.READY && this.dbus_name != null ){
debug("establish_mpris_connection - Not ready to connect");
return;
}
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index b002094..4443044 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -65,7 +65,7 @@ void establish_pulse_activities(SoundServiceDbus *service)
pa_main_loop = pa_glib_mainloop_new(g_main_context_default());
g_assert(pa_main_loop);
pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop),
- "ayatana.indicator.sound");
+ "com.canonical.indicators.sound");
g_assert(pulse_context);
sink_hash = g_hash_table_new_full(g_direct_hash,
@@ -103,7 +103,7 @@ reconnect_to_pulse()
sink_hash = NULL;
}
pulse_context = pa_context_new( pa_glib_mainloop_get_api( pa_main_loop ),
- "ayatana.indicator.sound" );
+ "com.canonical.indicators.sound" );
g_assert(pulse_context);
sink_hash = g_hash_table_new_full( g_direct_hash, g_direct_equal,
NULL,
diff --git a/src/sound-service.xml b/src/sound-service.xml
index ee19ceb..a552d52 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -1,6 +1,6 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/org/ayatana/indicator/sound">
- <interface name="org.ayatana.indicator.sound">
+<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"/>