This breaks implementation of "resume playback at saved position upon start" in Amarok. Reproducible: Always Steps to Reproduce: 1. Phonon::MediaObject *obj = new Phonon::MediaObject(); 2. obj->setCurrentSource( "path/to/source.mp3" ); 3. obj->pause(); Actual Results: stateChanged() with newState Phonon::LoadingState is emitted, then stateChanged() with newState Phonon::StoppedState is emitted, then noting happens Expected Results: stateChanged() with newState Phonon::PausedState it emitted at some point, so that media can be seeked before playback is started. Showcase: https://git.reviewboard.kde.org/r/105995/ There's no documentation whether setCurrentSource() is asynchronous or not, so I assume that calling pause() just after it is valid.
vlc does not like being paused while not having been played (which is perfectly sane TBH). given that the phonon api however does not suggest any such behavior it should work which in turn means a hacky work around in phonon vlc probably is in order. essentially we need to intercept the playing state change callback discard the state emission and instead set the vlc player instance to paused as there is no specification as to when the callback is sent this is nothing more than an appropximation to the desired behavior on phonon level as of course the callback could be done after the first samples were delivered to the output device. But even so the amount of samples would be less than what ends up being processed if we were to change phonon behavior (as phonon signals are all queued the delay between callback and actual pause call is obviously greater)
Git commit 67d64a1623c6c2167f6e131e036611aab32bfb92 by Harald Sitter. Committed on 22/08/2012 at 13:30. Pushed by sitter into branch 'master'. implement pausedplay mechanic phonon's api suggest that pausing before playing is possible (through naming of the interfaces) however vlc does not provide any such functionality so once again we do a nasty intercept-hack. pausedPlay issues a regular play but then intercepts the VLC playing event and directly switches to paused. nothing outside MediaPlayer ever knows that VLC actually was in playing state and a completely transparent switch from non-playing to paused becomes possible. please note that this does not in any way guarantee that no audio/video samples are already sent to the output. it merely tries to reduce the chance of this happening by calling pause in the event callback, which is of course threaded from the pipeline so anything can happen between us getting the signal and asking VLC to pause. verification for backport pending. M +17 -8 src/mediaobject.cpp M +1 -1 src/mediaobject.h M +18 -2 src/mediaplayer.cpp M +3 -0 src/mediaplayer.h http://commits.kde.org/phonon-vlc/67d64a1623c6c2167f6e131e036611aab32bfb92
I confirm this fixes the bug. (using Amarok and https://git.reviewboard.kde.org/r/105995/ patch)
Git commit 9600492eae50d48c93bed167afae1669f08459f1 by Harald Sitter. Committed on 22/08/2012 at 13:30. Pushed by sitter into branch '0.6'. implement pausedplay mechanic phonon's api suggest that pausing before playing is possible (through naming of the interfaces) however vlc does not provide any such functionality so once again we do a nasty intercept-hack. pausedPlay issues a regular play but then intercepts the VLC playing event and directly switches to paused. nothing outside MediaPlayer ever knows that VLC actually was in playing state and a completely transparent switch from non-playing to paused becomes possible. please note that this does not in any way guarantee that no audio/video samples are already sent to the output. it merely tries to reduce the chance of this happening by calling pause in the event callback, which is of course threaded from the pipeline so anything can happen between us getting the signal and asking VLC to pause. verification for backport pending. M +17 -8 src/mediaobject.cpp M +1 -1 src/mediaobject.h M +18 -2 src/mediaplayer.cpp M +3 -0 src/mediaplayer.h http://commits.kde.org/phonon-vlc/9600492eae50d48c93bed167afae1669f08459f1