Bug 216175

Summary: Amarok can not play single track from CD
Product: [Applications] amarok Reporter: Mathew Topper <damm_horse>
Component: PlaylistAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: nhn
Priority: NOR    
Version: 2.2.1   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Mathew Topper 2009-11-25 23:39:19 UTC
Version:           2.2.1-2.fc11 (using KDE 4.3.3)
OS:                Linux
Installed from:    Fedora RPMs

Description of problem: If a single track is selected and moved to the playlist from a inserted CD and opened under Amarok, Amarok will play the track, but not stop once the track is complete. It will just keep playing tracks on the CD until the CD is finished.

How reproducible: Any CD

Steps to Reproduce:
1. Insert Audio CD
2. Start Amarok
3. Move one CD to playlist
4. Play it.
5. Wait till track end.

Actual results: The CD continues to play and moves to the next track (although the track is not in the playlist).

Expected results: The CD should stop playing after the selected track.

Additional info: A '0' is printed in the console at the end of the originally selected track, but not for the later, non selected tracks.
Comment 1 Nikolaj Hald Nielsen 2009-12-11 23:21:16 UTC
commit 4024fc42aaeca7deca18e6cd7e9146e3f0b30a23
Author: Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
Date:   Fri Dec 11 23:15:17 2009 +0100

    Playback of Audio Cd tracks now correctly stops if track is the last in the playlist.
    BUG: 216175

diff --git a/ChangeLog b/ChangeLog
index 3308158..a04226a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,8 @@ VERSION 2.2.2
     * Improved automatic resizing of lyrics and suggestions in the context applet.
 
   BUGFIXES:
+    * Playback of Audio CD track now correctly stops if track is the last in the
+      playlist. (BR 216175)
     * Fixed crash if user clicks rating widget on the current track applet while no
       track is playing (which is possible since there is a slight delay before the 
       applet switches "mode"). (BR 215471)
diff --git a/src/EngineController.cpp b/src/EngineController.cpp
index bb2dd98..8ef116e 100644
--- a/src/EngineController.cpp
+++ b/src/EngineController.cpp
@@ -76,6 +76,7 @@ EngineController::EngineController()
     : m_playWhenFetched( true )
     , m_fadeoutTimer( new QTimer( this ) )
     , m_volume( 0 )
+    , m_currentIsAudioCd( false )
 {
     DEBUG_BLOCK
 
@@ -325,6 +326,7 @@ EngineController::play( const Meta::TrackPtr& track, uint offset )
         return;
 
     m_currentTrack = track;
+    m_currentIsAudioCd = false;
     delete m_boundedPlayback;
     delete m_multiPlayback;
     delete m_multiSource;
@@ -376,6 +378,8 @@ EngineController::playUrl( const KUrl &url, uint offset )
 
     if ( url.url().startsWith( "audiocd:/" ) )
     {
+
+        m_currentIsAudioCd = true;
         //disconnect this signal for now or it will cause a loop that will cause a mutex lockup
         disconnect( m_controller, SIGNAL( titleChanged( int ) ), this, SLOT( slotTitleChanged( int ) ) );
 
@@ -448,6 +452,7 @@ EngineController::stop( bool forceInstant ) //SLOT
 {
     DEBUG_BLOCK
 
+    m_currentIsAudioCd = false;
     // need to get a new instance of multi if played again
     delete m_multiPlayback;
     delete m_multiSource;
@@ -872,7 +877,7 @@ EngineController::slotAboutToFinish()
     else if ( m_currentTrack && m_currentTrack->playableUrl().url().startsWith( "audiocd:/" ) )
     {
         debug() << "finished a CD track, don't care if queue is not empty, just get new track...";
-        //m_media->stop();
+
         The::playlistActions()->requestNextTrack();
         slotQueueEnded();
     }
@@ -1157,4 +1162,9 @@ void EngineController::slotTitleChanged( int titleNumber )
     slotAboutToFinish();
 }
 
+bool EngineController::isPlayingAudioCd()
+{
+    return m_currentIsAudioCd;
+}
+
 #include "EngineController.moc"
diff --git a/src/EngineController.h b/src/EngineController.h
index 521b683..d52a9e5 100644
--- a/src/EngineController.h
+++ b/src/EngineController.h
@@ -167,6 +167,11 @@ public:
      */
     QStringList eqBandsFreq() const;
 
+    /**
+    * @return whether the currently playing track is from an audiocd
+    */
+    bool isPlayingAudioCd();
+
 public slots:
     /**
      * Plays the current track, if there is one
@@ -350,6 +355,7 @@ private:
     bool m_playWhenFetched;
     QTimer* m_fadeoutTimer;
     int m_volume;
+    bool m_currentIsAudioCd;
 
     QMutex m_mutex;
 };
diff --git a/src/playlist/PlaylistActions.cpp b/src/playlist/PlaylistActions.cpp
index ff279a9..37c2f0c 100644
--- a/src/playlist/PlaylistActions.cpp
+++ b/src/playlist/PlaylistActions.cpp
@@ -125,6 +125,10 @@ Playlist::Actions::requestNextTrack()
         //played and will thus be stuck at the last track (or refuse to play any at all) if the playlist is restarted
         m_navigator->reset();
 
+        //if what is currently playing is a cd track, we need to stop playback as the cd will otherwise continue playing
+        if( The::engineController()->isPlayingAudioCd() )
+            The::engineController()->stop();
+
         return;
     }
Comment 2 Nikolaj Hald Nielsen 2009-12-11 23:24:00 UTC
Fixed in the above commit