banshee r3407 - in trunk/banshee: . src/Backends/Banshee.GStreamer/Banshee.GStreamer src/Core/Banshee.Services/Banshee.MediaEngine src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3407 - in trunk/banshee: . src/Backends/Banshee.GStreamer/Banshee.GStreamer src/Core/Banshee.Services/Banshee.MediaEngine src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue
- Date: Tue, 11 Mar 2008 00:24:48 +0000 (GMT)
Author: abock
Date: Tue Mar 11 00:24:48 2008
New Revision: 3407
URL: http://svn.gnome.org/viewvc/banshee?rev=3407&view=rev
Log:
2008-03-10 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs:
* src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs:
Use the new Ready state instead of Initialized
* src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs: Do not
allow state transitions unless the engine is setting itself to the
ready state; send the idle state automatically once the engine sends
the ready state; all engines must transition to ready before anything
else
* src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs:
Handle the NotReady state in much the same way Idle is handled; some
generic code cleanup
* src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineState.cs:
Removed Initialized state in favor of Ready, added the NotReady state,
which is the default state for all engines; engines must manually
transition to the Ready state before any other state changes can occur
* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
Set the playing track when PlayerEngineEvent.StartOfStream is raised;
do not set the playing track manually when querying the model
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineState.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
Modified: trunk/banshee/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs (original)
+++ trunk/banshee/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs Tue Mar 11 00:24:48 2008
@@ -110,7 +110,7 @@
gst_playback_set_buffering_callback (handle, buffering_callback);
gst_playback_set_tag_found_callback (handle, tag_found_callback);
- OnStateChanged (PlayerEngineState.Initalized);
+ OnStateChanged (PlayerEngineState.Ready);
if (pending_volume >= 0) {
Volume = (ushort)pending_volume;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs Tue Mar 11 00:24:48 2008
@@ -46,8 +46,9 @@
private TrackInfo current_track;
private SafeUri current_uri;
- private PlayerEngineState current_state = PlayerEngineState.Idle;
- private PlayerEngineState last_state = PlayerEngineState.Idle;
+ private PlayerEngineState current_state = PlayerEngineState.NotReady;
+ private PlayerEngineState last_state = PlayerEngineState.NotReady;
+ private PlayerEngineState idle_state = PlayerEngineState.NotReady;
protected abstract void OpenUri (SafeUri uri);
@@ -55,12 +56,12 @@
{
current_track = null;
current_uri = null;
- OnStateChanged (PlayerEngineState.Idle);
+ OnStateChanged (idle_state);
}
public virtual void Close ()
{
- OnStateChanged (PlayerEngineState.Idle);
+ OnStateChanged (idle_state);
}
public virtual void Dispose ()
@@ -86,7 +87,7 @@
private void HandleOpen (SafeUri uri)
{
- if (current_state != PlayerEngineState.Idle) {
+ if (current_state != PlayerEngineState.Idle && current_state != PlayerEngineState.NotReady) {
Close ();
}
@@ -120,6 +121,13 @@
if (current_state == state) {
return;
}
+
+ if (idle_state == PlayerEngineState.NotReady && state != PlayerEngineState.Ready) {
+ Hyena.Log.Warning ("Engine must transition to the ready state before other states can be entered", false);
+ return;
+ } else if (idle_state == PlayerEngineState.NotReady && state == PlayerEngineState.Ready) {
+ idle_state = PlayerEngineState.Idle;
+ }
if (ThreadAssist.InMainThread) {
RaiseStateChanged (state);
@@ -128,6 +136,14 @@
RaiseStateChanged (state);
});
}
+
+ // Going to the Ready state automatically transitions to the Idle state
+ // The Ready state is advertised so one-time startup processes can easily
+ // happen outside of the engine itself
+
+ if (state == PlayerEngineState.Ready) {
+ OnStateChanged (PlayerEngineState.Idle);
+ }
}
private void RaiseStateChanged (PlayerEngineState state)
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs Tue Mar 11 00:24:48 2008
@@ -148,12 +148,11 @@
if (args.State == PlayerEngineState.Loaded && CurrentTrack != null) {
active_engine.Volume = (ushort) VolumeSchema.Get ();
MetadataService.Instance.Lookup (CurrentTrack);
- } else if (args.State == PlayerEngineState.Initalized) {
+ } else if (args.State == PlayerEngineState.Ready) {
// Enable our preferred equalizer if it exists and was enabled last time.
- if (this.SupportsEqualizer && EqualizerSetting.EnabledSchema.Get ()) {
+ if (SupportsEqualizer && EqualizerSetting.EnabledSchema.Get ()) {
string name = EqualizerSetting.PresetSchema.Get();
-
- if (name != "") {
+ if (!String.IsNullOrEmpty (name)) {
// Don't use EqualizerManager.Instance - used by the eq dialog window.
EqualizerManager manager = new EqualizerManager (EqualizerManager.Instance.Path);
manager.Load ();
@@ -263,13 +262,18 @@
private void OpenCheck (object o)
{
+ if (CurrentState == PlayerEngineState.NotReady) {
+ throw new InvalidOperationException (String.Format ("Player engine {0} is in the NotReady state",
+ active_engine.GetType ().FullName));
+ }
+
SafeUri uri = null;
TrackInfo track = null;
if (o is SafeUri) {
- uri = o as SafeUri;
+ uri = (SafeUri)o;
} else if (o is TrackInfo) {
- track = o as TrackInfo;
+ track = (TrackInfo)o;
uri = track.Uri;
} else {
return;
@@ -357,7 +361,8 @@
public bool IsPlaying (TrackInfo track)
{
- return CurrentState != PlayerEngineState.Idle && track != null && track.AudiblyEqual (CurrentTrack);
+ return CurrentState != PlayerEngineState.Idle && CurrentState != PlayerEngineState.NotReady &&
+ track != null && track.AudiblyEqual (CurrentTrack);
}
private void CheckPending ()
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineState.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineState.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineState.cs Tue Mar 11 00:24:48 2008
@@ -40,11 +40,12 @@
public enum PlayerEngineState
{
+ NotReady,
+ Ready,
Idle,
Contacting,
Loaded,
Playing,
- Paused,
- Initalized
+ Paused
}
}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs Tue Mar 11 00:24:48 2008
@@ -68,7 +68,7 @@
private void OnPlayerEngineStateChanged (object o, PlayerEngineStateArgs args)
{
- if (args.State == PlayerEngineState.Initalized && !ServiceManager.PlayerEngine.SupportsEqualizer) {
+ if (args.State == PlayerEngineState.Ready && !ServiceManager.PlayerEngine.SupportsEqualizer) {
action_service["View.ShowEqualizerAction"].Sensitive = false;
}
}
Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs Tue Mar 11 00:24:48 2008
@@ -147,7 +147,9 @@
private void OnPlayerEngineEventChanged (object o, PlayerEngineEventArgs args)
{
if (args.Event == PlayerEngineEvent.EndOfStream) {
- RemoveFirstTrack ();
+ RemovePlayingTrack ();
+ } else if (args.Event == PlayerEngineEvent.StartOfStream) {
+ playing_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
}
}
@@ -194,7 +196,7 @@
void IBasicPlaybackController.Next ()
{
- RemoveFirstTrack ();
+ RemovePlayingTrack ();
if (Count <= 0) {
playing_track = null;
@@ -203,15 +205,14 @@
return;
}
- playing_track = (DatabaseTrackInfo)TrackModel[0];
- ServiceManager.PlayerEngine.OpenPlay (playing_track);
+ ServiceManager.PlayerEngine.OpenPlay ((DatabaseTrackInfo)TrackModel[0]);
}
void IBasicPlaybackController.Previous ()
{
}
- private void RemoveFirstTrack ()
+ private void RemovePlayingTrack ()
{
if (playing_track != null) {
RemoveTrack (playing_track);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]