Bug 305021 - Phonon::MediaSource::currentSource() gives wrong current source if another track is already queued
Summary: Phonon::MediaSource::currentSource() gives wrong current source if another tr...
Status: RESOLVED FIXED
Alias: None
Product: phonon-backend-vlc
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 0.6
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 0.7
Assignee: Harald Sitter
URL:
Keywords:
: 306660 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-08-12 12:54 UTC by Matěj Laitl
Modified: 2012-11-13 19:51 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.6.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matěj Laitl 2012-08-12 12:54:05 UTC
Using steps to reproduce, I get following in Amarok debugging log:

amarok:       BEGIN: void EngineController::playUrl(const KUrl&, uint) 
amarok:         [EngineController] URL:  KUrl("http://mp1.somafm.com:8800") "http://mp1.somafm.com:8800" 
amarok:         [EngineController] Offset:  0 
amarok:         [EngineController] track pos after play:  0 
amarok:       END__: void EngineController::playUrl(const KUrl&, uint) [Took: 0.001s] 

(...)

amarok: BEGIN: void EngineController::slotNewTrackPlaying(const Phonon::MediaSource&) 
amarok: END__: void EngineController::slotNewTrackPlaying(const Phonon::MediaSource&) [Took: 0.047s] 
amarok: [EngineController] slotMetaDataChanged(): new meta-data: QMap(("xesam:album", QVariant(QString, "") ) ( "xesam:author" ,  QVariant(QString, "") ) ( "xesam:comment" ,  QVariant(QString, "") ) ( "xesam:genre" ,  QVariant(QString, "") ) ( "xesam:title" ,  QVariant(QString, "http://mp1.somafm.com:8800") ) ( "xesam:trackNumber" ,  QVariant(QString, "") ) ( "xesam:url" ,  QVariant(QUrl, QUrl("http://mp1.somafm.com:8800") ) ) )  
amarok: BEGIN: virtual void Playlist::Model::metadataChanged(Meta::TrackPtr)

^^^^ correct
(...)

amarok: [EngineController] slotMetaDataChanged(): new meta-data: QMap(("xesam:album", QVariant(QString, "") ) ( "xesam:author" ,  QVariant(QString, "") ) ( "xesam:comment" ,  QVariant(QString, "") ) ( "xesam:genre" ,  QVariant(QString, "Female Vocal Electronica") ) ( "xesam:title" ,  QVariant(QString, "Lush: Mostly female vocals with an electronic influence. [SomaFM]") ) ( "xesam:trackNumber" ,  QVariant(QString, "") ) ( "xesam:url" ,  QVariant(QUrl, QUrl("http://mp1.somafm.com:8800") ) ) )

^^^^ correct
(...)

amarok: BEGIN: void EngineController::slotAboutToFinish() 
amarok:       BEGIN: void EngineController::setNextTrack(Meta::TrackPtr) 
amarok:       END__: void EngineController::setNextTrack(Meta::TrackPtr) [Took: 0s] 
amarok: END__: void EngineController::slotAboutToFinish() [Took: 0s]

^^^^ aboutToFinish() signal emitted prematurely, the stream continues to play just
fine, but this is handled gracefully on Amarok side. Note that setNextTrack()
calls phononMediaObject->enqueue( "path/to/next/track.mp3" )
(...)

amarok: [EngineController] slotMetaDataChanged(): new meta-data: QMap(("xesam:album", QVariant(QString, "Lush: Mostly female vocals with an electronic influence. [SomaFM]") ) ( "xesam:author" ,  QVariant(QString, "") ) ( "xesam:comment" ,  QVariant(QString, "") ) ( "xesam:genre" ,  QVariant(QString, "Female Vocal Electronica") ) ( "xesam:title" ,  QVariant(QString, "Vanessa Daou - Somafm Announcer 2") ) ( "xesam:trackNumber" ,  QVariant(QString, "") ) ( "xesam:url" ,  QVariant(QUrl, QUrl("file:///home/strohel/music/mp3/Marvin Gaye/1971 What's Going On/01 What's Going On.mp3") ) ) )

^^^^ WRONG:
metadata from the currently playing stream (correct) got from signal
metadataChanged(), but incorrect url got from phononMediaObject->currentSource()->url()

Reproducible: Always

Steps to Reproduce:
1. Open Amarok (amarok --debug --nofork 2>&1 | grep -C3 EngineController), clear playlist
2. Add a stream to playlist (SomaFM in my case) and a normal track after it (Marvin Gaye in my case)
3. Play the stream
Actual Results:  
phonon-vlc reports incorrect currentSource() which breaks metadata updating of the stream in Amarok. - currentSource() reports the next song from Marvin Gaye while the stream is still playing.

Expected Results:  
currentSource() should report the stream url.

This may be a side-effect of premature aboutToFinish() signal being emitted.
Comment 1 Harald Sitter 2012-08-22 10:54:17 UTC
Git commit 324d7d92c97036f9c877c5e8c76c66651bbd8517 by Harald Sitter.
Committed on 22/08/2012 at 12:54.
Pushed by sitter into branch 'master'.

fix aboutToFinish thresh calculation

for continuous streams we get a length of 0, so we need to exclude <= 0
from delta calculation, otherwise aboutToFinish gets immediately emitted
for streams triggering a bogus source change in a consumer

M  +5    -1    src/mediaobject.cpp

http://commits.kde.org/phonon-vlc/324d7d92c97036f9c877c5e8c76c66651bbd8517
Comment 2 Harald Sitter 2012-08-22 10:55:21 UTC
Git commit 271761a8510bc2a62405e77fc9e5e13dc22155de by Harald Sitter.
Committed on 22/08/2012 at 12:54.
Pushed by sitter into branch '0.6'.

fix aboutToFinish thresh calculation

for continuous streams we get a length of 0, so we need to exclude <= 0
from delta calculation, otherwise aboutToFinish gets immediately emitted
for streams triggering a bogus source change in a consumer

M  +5    -1    src/mediaobject.cpp

http://commits.kde.org/phonon-vlc/271761a8510bc2a62405e77fc9e5e13dc22155de
Comment 3 Matěj Laitl 2012-08-24 15:51:28 UTC
I confirm this fixes the symptoms in Amarok, yay!
Comment 4 Harald Sitter 2012-09-13 10:35:45 UTC
*** Bug 306660 has been marked as a duplicate of this bug. ***