aboutsummaryrefslogtreecommitdiff
path: root/src/mpris2-controller.vala
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/mpris2-controller.vala
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/mpris2-controller.vala')
-rw-r--r--src/mpris2-controller.vala15
1 files changed, 13 insertions, 2 deletions
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;