Commit 4045c599 authored by Aaron Bockover's avatar Aaron Bockover Committed by Aaron Bockover

Sensitize/desensitize audio cd rows based on their rip state

2006-03-20  Aaron Bockover  <aaron@abock.org>

    * src/PlaylistView.cs: Sensitize/desensitize audio cd rows based on
    their rip state

    * src/Banshee.Base/AudioCdRipper.cs: Update newly ripped track with
    its ripped URI so it can be played while the rest of the disk is
    ripping

    * src/Banshee.Base/Library.cs: Removed unused function

    * src/Banshee.Base/PlayerEngineCore.cs: Do not attempt to play track
    if it is explicitly marked as being unable to play; reversed order of
    Reset/Close in Close wrapper

    * src/Banshee.Base/TrackInfo.cs: Mark CanPlay as virtual

    * src/Banshee.Base/TrackInfoHeader.cs (SetIdle): Hide the box

    * src/Banshee.Base/AudioCd/AudioCdDisk.cs: Added an IsRipping property

    * src/Banshee.Base/AudioCd/AudioCdTrackInfo.cs: Added Disk, IsRipped, and
    CanPlay properties

    * src/Banshee.Base/Sources/AudioCdSource.cs: If current playing track
    in the engine is from the CD, shut down the engine; set disk.IsRipping
    accordingly

    * src/Banshee.Base/Sources/LibrarySource.cs: Removed old cruft

    * src/Banshee.MediaEngine/Helix/HelixRemotePlayerEngine.cs: Updated
    to reflect minor changes in the Buffering API in PlayerEngine

    * src/Banshee.Plugins/NotificationAreaIcon/NotificationAreaIconPlugin.cs:
    Guard against a potential nullref
parent f0b6d516
2006-03-20 Aaron Bockover <aaron@abock.org>
* src/PlaylistView.cs: Sensitize/desensitize audio cd rows based on
their rip state
* src/Banshee.Base/AudioCdRipper.cs: Update newly ripped track with
its ripped URI so it can be played while the rest of the disk is
ripping
* src/Banshee.Base/Library.cs: Removed unused function
* src/Banshee.Base/PlayerEngineCore.cs: Do not attempt to play track
if it is explicitly marked as being unable to play; reversed order of
Reset/Close in Close wrapper
* src/Banshee.Base/TrackInfo.cs: Mark CanPlay as virtual
* src/Banshee.Base/TrackInfoHeader.cs (SetIdle): Hide the box
* src/Banshee.Base/AudioCd/AudioCdDisk.cs: Added an IsRipping property
* src/Banshee.Base/AudioCd/AudioCdTrackInfo.cs: Added Disk, IsRipped, and
CanPlay properties
* src/Banshee.Base/Sources/AudioCdSource.cs: If current playing track
in the engine is from the CD, shut down the engine; set disk.IsRipping
accordingly
* src/Banshee.Base/Sources/LibrarySource.cs: Removed old cruft
* src/Banshee.MediaEngine/Helix/HelixRemotePlayerEngine.cs: Updated
to reflect minor changes in the Buffering API in PlayerEngine
* src/Banshee.Plugins/NotificationAreaIcon/NotificationAreaIconPlugin.cs:
Guard against a potential nullref
2006-03-19 Aaron Bockover <aaron@abock.org> 2006-03-19 Aaron Bockover <aaron@abock.org>
* entagged-sharp/EncodingInfo.cs: Handle invalid integer durations * entagged-sharp/EncodingInfo.cs: Handle invalid integer durations
......
...@@ -79,7 +79,7 @@ namespace Banshee.Base ...@@ -79,7 +79,7 @@ namespace Banshee.Base
//mb_disc.Client.Debug = true; //mb_disc.Client.Debug = true;
foreach(SimpleTrack mb_track in mb_disc) { foreach(SimpleTrack mb_track in mb_disc) {
AudioCdTrackInfo track = new AudioCdTrackInfo(device_node); AudioCdTrackInfo track = new AudioCdTrackInfo(this);
track.Duration = new TimeSpan(mb_track.Length * TimeSpan.TicksPerSecond); track.Duration = new TimeSpan(mb_track.Length * TimeSpan.TicksPerSecond);
track.TrackIndex = mb_track.Index; track.TrackIndex = mb_track.Index;
track.Artist = Catalog.GetString("Unknown Artist"); track.Artist = Catalog.GetString("Unknown Artist");
...@@ -297,5 +297,11 @@ namespace Banshee.Base ...@@ -297,5 +297,11 @@ namespace Banshee.Base
public IEnumerable Tracks { public IEnumerable Tracks {
get { return tracks; } get { return tracks; }
} }
private bool is_ripping = false;
public bool IsRipping {
get { return is_ripping; }
set { is_ripping = value; }
}
} }
} }
/*************************************************************************** /***************************************************************************
* AudioCdTrackInfo.cs * AudioCdTrackInfo.cs
* *
* Copyright (C) 2005 Novell * Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover (aaron@aaronbock.net) * Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/ ****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: /* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
...@@ -39,14 +38,15 @@ namespace Banshee.Base ...@@ -39,14 +38,15 @@ namespace Banshee.Base
public class AudioCdTrackInfo : TrackInfo public class AudioCdTrackInfo : TrackInfo
{ {
private int track_index; private int track_index;
private string device;
private bool do_rip; private bool do_rip;
private bool is_ripped;
private AudioCdDisk disk;
public AudioCdTrackInfo(string device) public AudioCdTrackInfo(AudioCdDisk disk)
{ {
PreviousTrack = Gtk.TreeIter.Zero; PreviousTrack = Gtk.TreeIter.Zero;
CanSaveToDatabase = false; CanSaveToDatabase = false;
this.device = device; this.disk = disk;
do_rip = true; do_rip = true;
} }
...@@ -63,31 +63,35 @@ namespace Banshee.Base ...@@ -63,31 +63,35 @@ namespace Banshee.Base
} }
public int TrackIndex { public int TrackIndex {
get { get { return track_index; }
return track_index;
}
set { set {
track_index = value; track_index = value;
TrackNumber = (uint)value; TrackNumber = (uint)value;
uri = new Uri("cdda://" + track_index + "#" + device); uri = new Uri("cdda://" + track_index + "#" + disk.DeviceNode);
} }
} }
public string Device { public string Device {
get { get { return disk.DeviceNode; }
return device; }
}
public AudioCdDisk Disk {
get { return disk; }
} }
public bool CanRip { public bool CanRip {
get { get { return do_rip; }
return do_rip; set { do_rip = value; }
} }
set { public bool IsRipped {
do_rip = value; get { return is_ripped; }
} set { is_ripped = value; }
}
public override bool CanPlay {
get { return !disk.IsRipping || (disk.IsRipping && IsRipped); }
} }
} }
} }
...@@ -150,6 +150,9 @@ namespace Banshee.Base ...@@ -150,6 +150,9 @@ namespace Banshee.Base
private void OnTrackFinished(AudioCdTrackInfo track, int trackNumber, Uri outputUri) private void OnTrackFinished(AudioCdTrackInfo track, int trackNumber, Uri outputUri)
{ {
track.IsRipped = true;
track.Uri = outputUri;
AudioCdRipperTrackFinishedHandler handler = TrackFinished; AudioCdRipperTrackFinishedHandler handler = TrackFinished;
if(handler != null) { if(handler != null) {
AudioCdRipperTrackFinishedArgs args = new AudioCdRipperTrackFinishedArgs(); AudioCdRipperTrackFinishedArgs args = new AudioCdRipperTrackFinishedArgs();
...@@ -272,6 +275,7 @@ namespace Banshee.Base ...@@ -272,6 +275,7 @@ namespace Banshee.Base
private PipelineProfile profile; private PipelineProfile profile;
public event HaveTrackInfoHandler HaveTrackInfo; public event HaveTrackInfoHandler HaveTrackInfo;
public event EventHandler Finished;
private ActiveUserEvent user_event; private ActiveUserEvent user_event;
...@@ -378,15 +382,25 @@ namespace Banshee.Base ...@@ -378,15 +382,25 @@ namespace Banshee.Base
ripper.Dispose(); ripper.Dispose();
user_event.Dispose(); user_event.Dispose();
OnFinished();
} }
private void OnRipperError(object o, EventArgs args) private void OnRipperError(object o, EventArgs args)
{ {
ripper.Dispose(); ripper.Dispose();
user_event.Dispose(); user_event.Dispose();
OnFinished();
LogCore.Instance.PushError(Catalog.GetString("Cannot Import CD"), ripper.ErrorMessage); LogCore.Instance.PushError(Catalog.GetString("Cannot Import CD"), ripper.ErrorMessage);
} }
private void OnFinished()
{
EventHandler handler = Finished;
if(handler != null) {
handler(this, new EventArgs());
}
}
private bool OnTimeout() private bool OnTimeout()
{ {
int diff = currentSeconds - lastPollSeconds; int diff = currentSeconds - lastPollSeconds;
...@@ -419,6 +433,7 @@ namespace Banshee.Base ...@@ -419,6 +433,7 @@ namespace Banshee.Base
} }
user_event.Dispose(); user_event.Dispose();
OnFinished();
} }
public int QueueSize { public int QueueSize {
......
/*************************************************************************** /***************************************************************************
* Library.cs * Library.cs
* *
* Copyright (C) 2005 Novell * Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover (aaron@aaronbock.net) * Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/ ****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: /* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
...@@ -202,10 +202,10 @@ namespace Banshee.Base ...@@ -202,10 +202,10 @@ namespace Banshee.Base
} }
} }
private void Remove(Uri trackUri) /*private void Remove(Uri trackUri)
{ {
Remove(TracksFnKeyed[MakeFilenameKey(trackUri)] as LibraryTrackInfo); Remove(TracksFnKeyed[MakeFilenameKey(trackUri)] as LibraryTrackInfo);
} }*/
public void Remove(LibraryTrackInfo track) public void Remove(LibraryTrackInfo track)
{ {
......
...@@ -159,6 +159,10 @@ namespace Banshee.Base ...@@ -159,6 +159,10 @@ namespace Banshee.Base
public static void OpenPlay(TrackInfo track) public static void OpenPlay(TrackInfo track)
{ {
if(!track.CanPlay) {
return;
}
CheckPending(); CheckPending();
active_engine.Open(track); active_engine.Open(track);
active_engine.Play(); active_engine.Play();
...@@ -166,8 +170,8 @@ namespace Banshee.Base ...@@ -166,8 +170,8 @@ namespace Banshee.Base
public static void Close() public static void Close()
{ {
active_engine.Close();
active_engine.Reset(); active_engine.Reset();
active_engine.Close();
} }
public static void Play() public static void Play()
......
...@@ -140,6 +140,13 @@ namespace Banshee.Sources ...@@ -140,6 +140,13 @@ namespace Banshee.Sources
private void ImportDisk() private void ImportDisk()
{ {
if(disk.IsRipping) {
Console.WriteLine("CD is already ripping");
return;
}
disk.IsRipping = true;
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
foreach(AudioCdTrackInfo track in disk.Tracks) { foreach(AudioCdTrackInfo track in disk.Tracks) {
...@@ -150,10 +157,17 @@ namespace Banshee.Sources ...@@ -150,10 +157,17 @@ namespace Banshee.Sources
if(list.Count > 0) { if(list.Count > 0) {
AudioCdRipper ripper = new AudioCdRipper(); AudioCdRipper ripper = new AudioCdRipper();
// ripper.HaveTrackInfo += OnAudioCdRipperTrackRipped; ripper.Finished += OnRipperFinished;
ripper.HaveTrackInfo += OnRipperHaveTrackInfo;
foreach(AudioCdTrackInfo track in list) { foreach(AudioCdTrackInfo track in list) {
ripper.QueueTrack(track); ripper.QueueTrack(track);
} }
AudioCdTrackInfo playing_track = PlayerEngineCore.CurrentTrack as AudioCdTrackInfo;
if(playing_track != null && playing_track.Disk == disk) {
PlayerEngineCore.Close();
}
ripper.Start(); ripper.Start();
} else { } else {
HigMessageDialog dialog = new HigMessageDialog(InterfaceElements.MainWindow, DialogFlags.Modal, HigMessageDialog dialog = new HigMessageDialog(InterfaceElements.MainWindow, DialogFlags.Modal,
...@@ -163,9 +177,21 @@ namespace Banshee.Sources ...@@ -163,9 +177,21 @@ namespace Banshee.Sources
); );
dialog.Run(); dialog.Run();
dialog.Destroy(); dialog.Destroy();
disk.IsRipping = false;
} }
} }
private void OnRipperHaveTrackInfo(object o, HaveTrackInfoArgs args)
{
OnUpdated();
}
private void OnRipperFinished(object o, EventArgs args)
{
disk.IsRipping = false;
OnUpdated();
}
private void OnDiskUpdated(object o, EventArgs args) private void OnDiskUpdated(object o, EventArgs args)
{ {
ThreadAssist.ProxyToMain(delegate { ThreadAssist.ProxyToMain(delegate {
......
...@@ -37,7 +37,6 @@ namespace Banshee.Sources ...@@ -37,7 +37,6 @@ namespace Banshee.Sources
public class LibrarySource : Source public class LibrarySource : Source
{ {
private static LibrarySource instance; private static LibrarySource instance;
private bool updating = false;
public static LibrarySource Instance { public static LibrarySource Instance {
get { get {
if(instance == null) { if(instance == null) {
...@@ -47,13 +46,6 @@ namespace Banshee.Sources ...@@ -47,13 +46,6 @@ namespace Banshee.Sources
return instance; return instance;
} }
} }
private bool DelayedUpdateHandler()
{
OnUpdated();
updating = false;
return false;
}
private LibrarySource() : base(Catalog.GetString("Music Library"), 0) private LibrarySource() : base(Catalog.GetString("Music Library"), 0)
{ {
......
...@@ -402,7 +402,7 @@ namespace Banshee.Base ...@@ -402,7 +402,7 @@ namespace Banshee.Base
} }
} }
public bool CanPlay { public virtual bool CanPlay {
get { get {
return can_play; return can_play;
} }
......
/*************************************************************************** /***************************************************************************
* TrackInfoHeader.cs * TrackInfoHeader.cs
* *
* Copyright (C) 2005 Novell * Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover (aaron@aaronbock.net) * Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/ ****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: /* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
...@@ -133,9 +132,7 @@ namespace Banshee.Widgets ...@@ -133,9 +132,7 @@ namespace Banshee.Widgets
} }
public CoverArtThumbnail Cover { public CoverArtThumbnail Cover {
get { get { return cover; }
return cover;
}
} }
public Gdk.Pixbuf DefaultCover { public Gdk.Pixbuf DefaultCover {
...@@ -150,13 +147,12 @@ namespace Banshee.Widgets ...@@ -150,13 +147,12 @@ namespace Banshee.Widgets
} }
public VBox VBox { public VBox VBox {
get { get { return box; }
return box;
}
} }
public void SetIdle() public void SetIdle()
{ {
box.Hide();
} }
} }
} }
...@@ -104,7 +104,7 @@ namespace Banshee.MediaEngine.Helix ...@@ -104,7 +104,7 @@ namespace Banshee.MediaEngine.Helix
break; break;
case ContentState.Loading: case ContentState.Loading:
case ContentState.Contacting: case ContentState.Contacting:
OnStateChanged(PlayerEngineState.Buffering); OnEventChanged(PlayerEngineEvent.Buffering);
break; break;
default: default:
OnStateChanged(PlayerEngineState.Idle); OnStateChanged(PlayerEngineState.Idle);
......
...@@ -223,8 +223,13 @@ namespace Banshee.Plugins.NotificationAreaIcon { ...@@ -223,8 +223,13 @@ namespace Banshee.Plugins.NotificationAreaIcon {
private void OnPlayerEngineEventChanged(object o, PlayerEngineEventArgs args) { private void OnPlayerEngineEventChanged(object o, PlayerEngineEventArgs args) {
switch (args.Event) { switch (args.Event) {
case PlayerEngineEvent.Iterate: case PlayerEngineEvent.Iterate:
popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds; if(PlayerEngineCore.CurrentTrack != null) {
popup.Position = PlayerEngineCore.Position; popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds;
popup.Position = PlayerEngineCore.Position;
} else {
popup.Duration = 0;
popup.Position = 0;
}
break; break;
case PlayerEngineEvent.StartOfStream: case PlayerEngineEvent.StartOfStream:
FillPopup(); FillPopup();
......
...@@ -38,6 +38,7 @@ using Pango; ...@@ -38,6 +38,7 @@ using Pango;
using Banshee.Base; using Banshee.Base;
using Banshee.Dap; using Banshee.Dap;
using Banshee.Sources;
namespace Banshee namespace Banshee
{ {
...@@ -336,16 +337,16 @@ namespace Banshee ...@@ -336,16 +337,16 @@ namespace Banshee
renderer.Foreground = null; renderer.Foreground = null;
renderer.Sensitive = true;
TrackInfo ti = model.IterTrackInfo(iter); TrackInfo ti = model.IterTrackInfo(iter);
if(ti == null) { if(ti == null) {
return; return;
} }
if(ti.GetType() != typeof(DapTrackInfo)) if(ti is AudioCdTrackInfo) {
return; renderer.Sensitive = ti.CanPlay;
}
if((ti as DapTrackInfo).NeedSync)
renderer.Foreground = "blue";
} }
protected void TrackCellInd(TreeViewColumn tree_column, protected void TrackCellInd(TreeViewColumn tree_column,
...@@ -356,7 +357,7 @@ namespace Banshee ...@@ -356,7 +357,7 @@ namespace Banshee
if(PlayerEngineCore.CurrentTrack == null) { if(PlayerEngineCore.CurrentTrack == null) {
model.PlayingIter = TreeIter.Zero; model.PlayingIter = TreeIter.Zero;
if(ti != null) { if(ti != null && !(ti is AudioCdTrackInfo)) {
renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf; renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf;
} else { } else {
renderer.Pixbuf = null; renderer.Pixbuf = null;
...@@ -369,6 +370,8 @@ namespace Banshee ...@@ -369,6 +370,8 @@ namespace Banshee
if(PlayerEngineCore.CurrentTrack != null && PlayerEngineCore.CurrentTrack.Equals(ti)) { if(PlayerEngineCore.CurrentTrack != null && PlayerEngineCore.CurrentTrack.Equals(ti)) {
renderer.Pixbuf = nowPlayingPixbuf; renderer.Pixbuf = nowPlayingPixbuf;
model.PlayingIter = iter; model.PlayingIter = iter;
} else if(ti is AudioCdTrackInfo) {
renderer.Pixbuf = null;
} else { } else {
renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf; renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf;
} }
...@@ -382,10 +385,14 @@ namespace Banshee ...@@ -382,10 +385,14 @@ namespace Banshee
{ {
CellRendererToggle toggle = (CellRendererToggle)cell; CellRendererToggle toggle = (CellRendererToggle)cell;
AudioCdTrackInfo ti = model.IterTrackInfo(iter) as AudioCdTrackInfo; AudioCdTrackInfo ti = model.IterTrackInfo(iter) as AudioCdTrackInfo;
if (ti != null)
toggle.Active = ti.CanRip; if(ti != null) {
else toggle.Sensitive = ti.CanPlay && !ti.IsRipped;
toggle.Activatable = toggle.Sensitive;
toggle.Active = ti.CanRip && !ti.IsRipped;
} else {
toggle.Active = false; toggle.Active = false;
}
} }
protected void TrackCellTrack(TreeViewColumn tree_column, protected void TrackCellTrack(TreeViewColumn tree_column,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment