/[packages]/updates/1/amarok/current/SOURCES/0006-Fix-some-audio-cd-related-issue.patch
ViewVC logotype

Annotation of /updates/1/amarok/current/SOURCES/0006-Fix-some-audio-cd-related-issue.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 137424 - (hide annotations) (download)
Thu Sep 1 02:36:21 2011 UTC (13 years ago) by mikala
File size: 7765 byte(s)
SILENT: new file ./SOURCES/0006-Fix-some-audio-cd-related-issue.patch
1 mikala 137424 commit 425d684b7df0e8b50faa0cbe86eecb2d4d5022cd
2     Author: Ralf Engels <ralf-engels@gmx.de>
3     Date: Wed May 18 20:34:42 2011 +0200
4    
5     Fix some audio cd related issue: not playing, skipping tracks with gstreamer, no length shown
6    
7     Don't start a new track in the EngineController if the new title is the one we just started. (fixes bug 222405)
8     Handle a device specifier (?device=<deviceName>) in EngineController::playUrl, the old code would not play if the deviceName had a slash (/) in it. (fixes bug 261175).
9     Use KIO:NetAccess::stat to compute track lengths, previously shown as 0:00, fixes bug 207806.
10     src/core-impl/meta/cdda/AudioCdTrackProvider_p.cpp (AudioCdTrackProvider::Private::Private,AudioCdTrackProvider::Private::deviceAdded): Fix some typos, that may have caused crashes.
11    
12     Courtesy: Arnold Metselaar
13    
14     diff --git a/src/EngineController.cpp b/src/EngineController.cpp
15     index 2f666fd..a1c4c76 100644
16     --- a/src/EngineController.cpp
17     +++ b/src/EngineController.cpp
18     @@ -83,6 +83,7 @@ EngineController::EngineController()
19     , m_playWhenFetched( true )
20     , m_volume( 0 )
21     , m_currentIsAudioCd( false )
22     + , m_currentAudioCdTrack( 0 )
23     , m_ignoreVolumeChangeAction ( false )
24     , m_ignoreVolumeChangeObserve ( false )
25     , m_tickInterval( 0 )
26     @@ -460,6 +461,15 @@ EngineController::playUrl( const KUrl &url, uint offset )
27     QString trackNumberString = url.url();
28     trackNumberString = trackNumberString.remove( "audiocd:/" );
29    
30     + const QString devicePrefix( "?device=" );
31     + QString device("");
32     + if (trackNumberString.contains(devicePrefix))
33     + {
34     + int pos = trackNumberString.indexOf( devicePrefix );
35     + device = trackNumberString.mid( pos + devicePrefix.size() );
36     + trackNumberString = trackNumberString.left( pos );
37     + }
38     +
39     QStringList parts = trackNumberString.split( '/' );
40    
41     if ( parts.count() != 2 )
42     @@ -479,25 +489,27 @@ EngineController::playUrl( const KUrl &url, uint offset )
43    
44     int trackNumber = parts.at( 1 ).toInt();
45    
46     - debug() << "3.2.1...";
47     + debug() << "Old device: " << m_media.data()->currentSource().deviceName();
48    
49     Phonon::MediaSource::Type type = m_media.data()->currentSource().type();
50     - if( type != Phonon::MediaSource::Disc )
51     + if( type != Phonon::MediaSource::Disc || m_media.data()->currentSource().deviceName() != device )
52     {
53     m_media.data()->clear();
54     - m_media.data()->setCurrentSource( Phonon::Cd );
55     + debug() << "New device: " << device;
56     + m_media.data()->setCurrentSource( Phonon::MediaSource( Phonon::Cd, device ) );
57     }
58    
59     - debug() << "boom?";
60     + debug() << "Track: " << trackNumber;
61     + m_currentAudioCdTrack = trackNumber;
62     m_controller.data()->setCurrentTitle( trackNumber );
63     debug() << "no boom?";
64    
65     if( type == Phonon::MediaSource::Disc )
66     {
67     - // The track has changed but the slot will not be called,
68     - // because it's still the same media source, which means
69     + // The track has changed but the slot may not be called,
70     + // because it may be still the same media source, which means
71     // we need to do it explicitly.
72     - slotNewTrackPlaying( Phonon::Cd );
73     + slotNewTrackPlaying( m_media.data()->currentSource() );
74     }
75    
76     //reconnect it
77     @@ -1306,9 +1318,10 @@ EngineController::slotSeekableChanged( bool seekable )
78     void EngineController::slotTitleChanged( int titleNumber )
79     {
80     DEBUG_BLOCK
81     - Q_UNUSED( titleNumber );
82     -
83     - slotAboutToFinish();
84     + if ( titleNumber != m_currentAudioCdTrack )
85     + {
86     + slotAboutToFinish();
87     + }
88     }
89    
90     void EngineController::slotVolumeChanged( qreal newVolume )
91     diff --git a/src/EngineController.h b/src/EngineController.h
92     index 4117a89..7874a79 100644
93     --- a/src/EngineController.h
94     +++ b/src/EngineController.h
95     @@ -553,6 +553,7 @@ private:
96     bool m_playWhenFetched;
97     int m_volume;
98     bool m_currentIsAudioCd;
99     + int m_currentAudioCdTrack;
100    
101     QList<QVariantMap> m_metaDataHistory; // against metadata spam
102    
103     diff --git a/src/core-impl/collections/audiocd/AudioCdCollection.cpp b/src/core-impl/collections/audiocd/AudioCdCollection.cpp
104     index 13a04ae..3e73dde 100644
105     --- a/src/core-impl/collections/audiocd/AudioCdCollection.cpp
106     +++ b/src/core-impl/collections/audiocd/AudioCdCollection.cpp
107     @@ -37,6 +37,7 @@
108    
109     #include <kio/job.h>
110     #include <kio/netaccess.h>
111     +#include <kio/udsentry.h>
112    
113     #include <solid/device.h>
114     #include <solid/opticaldrive.h>
115     @@ -254,7 +255,7 @@ AudioCdCollection::infoFetchComplete( KJob *job )
116    
117     debug() << "Track name: " << trackName;
118    
119     - QString padding = i < 10 ? "0" : QString();
120     + QString padding = (i + 1) < 10 ? "0" : QString();
121    
122     QString baseFileName = m_fileNamePattern;
123     debug() << "Track Base File Name (before): " << baseFileName;
124     @@ -277,6 +278,7 @@ AudioCdCollection::infoFetchComplete( KJob *job )
125    
126     trackPtr->setTrackNumber( i + 1 );
127     trackPtr->setFileNameBase( baseFileName );
128     + trackPtr->setLength( trackLength( i + 1 ) );
129    
130     memoryCollection()->addTrack( Meta::TrackPtr::staticCast( trackPtr ) );
131    
132     @@ -324,6 +326,19 @@ AudioCdCollection::infoFetchComplete( KJob *job )
133     }
134     }
135    
136     +qint64
137     +AudioCdCollection::trackLength(int i) const
138     +{
139     + KUrl kioUrl = audiocdUrl( QString("Track%1.wav").arg(i, 2, 10, QChar('0') ) );
140     + KIO::UDSEntry uds;
141     + if ( KIO::NetAccess::stat(kioUrl, uds, NULL) )
142     + {
143     + qint64 samples = (uds.numberValue(KIO::UDSEntry::UDS_SIZE, 44) - 44) / 4;
144     + return (samples - 44) * 10 / 441;
145     + }
146     + return 0;
147     +}
148     +
149     QString
150     AudioCdCollection::collectionId() const
151     {
152     @@ -456,6 +471,7 @@ AudioCdCollection::noInfoAvailable()
153    
154     trackPtr->setTrackNumber( i );
155     trackPtr->setFileNameBase( trackName );
156     + trackPtr->setLength( trackLength( i ) );
157    
158     memoryCollection()->addTrack( Meta::TrackPtr::staticCast( trackPtr ) );
159    
160     diff --git a/src/core-impl/collections/audiocd/AudioCdCollection.h b/src/core-impl/collections/audiocd/AudioCdCollection.h
161     index a3baf61..6196b4a 100644
162     --- a/src/core-impl/collections/audiocd/AudioCdCollection.h
163     +++ b/src/core-impl/collections/audiocd/AudioCdCollection.h
164     @@ -103,6 +103,7 @@ private:
165    
166     // Helper function to build the audiocd url.
167     KUrl audiocdUrl( const QString &path = "" ) const;
168     + qint64 trackLength( int i ) const;
169    
170     /**
171     * Clear collection and read the CD currently in the drive, adding Artist, Album,
172     diff --git a/src/core-impl/meta/cdda/AudioCdTrackProvider_p.cpp b/src/core-impl/meta/cdda/AudioCdTrackProvider_p.cpp
173     index 048e6b6..e697367 100644
174     --- a/src/core-impl/meta/cdda/AudioCdTrackProvider_p.cpp
175     +++ b/src/core-impl/meta/cdda/AudioCdTrackProvider_p.cpp
176     @@ -52,7 +52,7 @@ AudioCdTrackProvider::Private::Private()
177     if( device.is<Solid::Block>() )
178     {
179     //does this actually work on windows???
180     - Solid::Block *sb = devie.as>Solid::Block>();
181     + Solid::Block *sb = device.as<Solid::Block>();
182     m_cddaDevices.insert( device.udi(), sb->device() );
183     }
184     }
185     @@ -81,7 +81,7 @@ AudioCdTrackProvider::Private::deviceAdded( const QString &udi )
186     if( device.is<Solid::Block>() )
187     {
188     //does this actually work on windows???
189     - Solid::Block *sb = devie.as>Solid::Block>();
190     + Solid::Block *sb = device.as<Solid::Block>();
191     m_cddaDevices.insert( device.udi(), sb->device() );
192     KCompactDisc cd;
193     cd.setDevice( sb->device() );

  ViewVC Help
Powered by ViewVC 1.1.30