[rygel] renderer: handle playback state in PlayerController
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] renderer: handle playback state in PlayerController
- Date: Sat, 14 Dec 2013 16:16:46 +0000 (UTC)
commit 1db7452f557748c60ae63c81455033247f2c081f
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date: Wed Nov 27 22:46:02 2013 +0200
renderer: handle playback state in PlayerController
Player.playback_state was modified from both PlayerController and
AVTransport. Start making all modifications through
PlayerController.playback_state. This has the added benefit that we
don't accidentally expose "EOS" state to AVTransport.
Also rename some variables "player"->"controller" to match reality.
https://bugzilla.gnome.org/show_bug.cgi?id=709165
src/librygel-renderer/rygel-av-transport.vala | 22 ++++++++--------
src/librygel-renderer/rygel-player-controller.vala | 27 +++++++++----------
2 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index 51e2aa3..394a4ba 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -187,7 +187,7 @@ internal class Rygel.AVTransport : Service {
// Send current state
ChangeLog log = new ChangeLog (null, LAST_CHANGE_NS);
- log.log ("TransportState", this.player.playback_state);
+ log.log ("TransportState", this.controller.playback_state);
log.log ("CurrentTransportActions",
this.controller.current_transport_actions);
log.log ("TransportStatus", this.status);
@@ -398,7 +398,7 @@ internal class Rygel.AVTransport : Service {
action.set ("CurrentTransportState",
typeof (string),
- this.player.playback_state,
+ this.controller.playback_state,
"CurrentTransportStatus",
typeof (string),
this.status,
@@ -496,7 +496,7 @@ internal class Rygel.AVTransport : Service {
return;
}
- this.player.playback_state = "STOPPED";
+ this.controller.playback_state = "STOPPED";
action.return ();
}
@@ -517,7 +517,7 @@ internal class Rygel.AVTransport : Service {
// Speed change will take effect when playback state is changed
this.player.playback_speed = speed;
- this.player.playback_state = "PLAYING";
+ this.controller.playback_state = "PLAYING";
action.return ();
}
@@ -527,13 +527,13 @@ internal class Rygel.AVTransport : Service {
return;
}
- if (this.player.playback_state != "PLAYING") {
+ if (this.controller.playback_state != "PLAYING") {
action.return_error (701, _("Transition not available"));
return;
}
- this.player.playback_state = "PAUSED_PLAYBACK";
+ this.controller.playback_state = "PAUSED_PLAYBACK";
action.return ();
}
@@ -670,19 +670,19 @@ internal class Rygel.AVTransport : Service {
action.return ();
}
- private void notify_state_cb (Object player, ParamSpec p) {
- var state = this.player.playback_state;
+ private void notify_state_cb (Object controller, ParamSpec p) {
+ var state = this.controller.playback_state;
this.changelog.log ("TransportState", state);
this.changelog.log ("CurrentTransportActions",
this.controller.current_transport_actions);
}
- private void notify_n_tracks_cb (Object player, ParamSpec p) {
+ private void notify_n_tracks_cb (Object controller, ParamSpec p) {
this.changelog.log ("NumberOfTracks",
this.controller.n_tracks.to_string ());
}
- private void notify_track_cb (Object player, ParamSpec p) {
+ private void notify_track_cb (Object controller, ParamSpec p) {
this.changelog.log ("CurrentTrack",
this.controller.track.to_string ());
}
@@ -698,7 +698,7 @@ internal class Rygel.AVTransport : Service {
this.changelog.log ("CurrentTrackURI", this.track_uri);
}
- private void notify_uri_cb (Object player, ParamSpec p) {
+ private void notify_uri_cb (Object controller, ParamSpec p) {
this.changelog.log ("AVTransportURI", this.controller.uri);
}
diff --git a/src/librygel-renderer/rygel-player-controller.vala
b/src/librygel-renderer/rygel-player-controller.vala
index 0d91640..c8431bb 100644
--- a/src/librygel-renderer/rygel-player-controller.vala
+++ b/src/librygel-renderer/rygel-player-controller.vala
@@ -51,17 +51,16 @@ internal class Rygel.PlayerController : Object {
public string protocol_info { construct; private get; }
/* public properties */
+
+ /* this._playback_state mirrors player.playback_state without including
+ * non-UPnP "EOS" value. It is updated from notify_state_cb */
[CCode (notify = false)]
public string playback_state {
get { return this._playback_state; }
- set {
- if (this._playback_state != value) {
- this._playback_state = value;
- this.notify_property ("playback-state");
- }
- }
+ set { this.player.playback_state = value; }
default = "NO_MEDIA_PRESENT";
}
+
public uint n_tracks { get; set; default = 0; }
public uint track {
get { return this._track; }
@@ -78,7 +77,7 @@ internal class Rygel.PlayerController : Object {
public string current_transport_actions {
owned get {
string actions = null;
- switch (this._playback_state) {
+ switch (this.playback_state) {
case "PLAYING":
case "TRANSITIONING":
actions = "Stop,Seek,Pause";
@@ -197,9 +196,8 @@ internal class Rygel.PlayerController : Object {
var state = this.player.playback_state;
if (state == "EOS") {
if (this.collection == null) {
- // Just move to stop
Idle.add (() => {
- this.player.playback_state = "STOPPED";
+ this.playback_state = "STOPPED";
return false;
});
@@ -213,9 +211,10 @@ internal class Rygel.PlayerController : Object {
this.reset ();
}
}
- } else {
- // just forward
- this.playback_state = state;
+ } else if (this._playback_state != state) {
+ // mirror player value in _playback_state and notify
+ this._playback_state = state;
+ this.notify_property ("playback-state");
}
}
@@ -230,14 +229,14 @@ internal class Rygel.PlayerController : Object {
this.player.uri = res.get_uri ();
if (item.upnp_class.has_prefix ("object.item.image") &&
this.collection != null &&
- this.player.playback_state != "STOPPED") {
+ this.playback_state != "STOPPED") {
this.setup_image_timeouts (item.lifetime);
}
}
}
private void reset () {
- this.player.playback_state = "STOPPED";
+ this.playback_state = "STOPPED";
this.track = 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]