Review Request: Remove EngineObserver and replacing it with signals/slots for better thread safety

Alex Merry kde at randomguy3.me.uk
Sun Oct 31 21:14:01 CET 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/100120/#review239
-----------------------------------------------------------


I'm in favour of this - the current EngineObserver construct is unnecessarily different from the standard Qt signals and slots system, and is also inefficient (particularly when you consider trackPositionChanged, for example, which is called frequently, but which most observers don't care about).

I haven't looked at most of the code, just the EngineController changes (and a couple of issues I noticed in CoverBlingApplet).


playground/src/context/applets/coverbling/CoverBlingApplet.cpp
<http://git.reviewboard.kde.org/r/100120/#comment189>

    This shouldn't be connected to jumpToPlaying, but to trackPlaying( Meta::TrackPtr ).



playground/src/context/applets/coverbling/CoverBlingApplet.cpp
<http://git.reviewboard.kde.org/r/100120/#comment190>

    This needs declaring as a slot in the header.



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment191>

    Delete stuff rather than commenting it :-)



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment203>

    The apidocs should mention (for isPlaying, isPaused and isStopped) what happens when fading out.



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment192>

    "Usually" is not helpful for people reading apidocs.  Is it deterministic?



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment193>

    Is there a better example we can replace the seeking one with?  Who actually uses isStream?



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment195>

    What if it's paused?  Buffering?



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment194>

    But not when it resumes, right?  This should be clarified in the docs.



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment196>

    Specifically, an error that prevented playback from starting or continuing, right?  This should be clarified.



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment197>

    Reading the apidocs, I'm completely confused about the difference between trackMetadataChanged and currentMetadataChanged, or what other changes I would get by also connecting to trackChanged.
    
    Are trackMetadataChanged and currentMetadataChanged identical apart from the argument type?  If so, this should be explicit in the apidocs.
    
    Most clients will just want to know when the "title of the currently-playing track" changes, either because a different track is playing or because the title property of the current track has changed (edited/stream/whatever).  What other use cases are there for connecting to a metadata changed signal?



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment198>

    EngineObserver doesn't really have the concept of a "current album", does it?  At least, conceptually.  It's just the album linked to the current track.  The apidocs should really reflect that.
    
    A related question: is this signal emitted if the album associated with the track changes (rather than the properties of the album)?  I would guess yes.
    
    What about when the track changes and the album stays the same?  Or the track changes and the album is different?
    
    Basically, the apidocs aren't clear enough.



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment199>

    The apidocs should be clearer about "userSeek" - when it is false, it means that the position change is due to normal playback progression.
    
    Perhaps this should be split into two signals, one for each value of userSeek - would this be more efficient, with a reduced number of listeners when the track is just progressing normally?
    
    Perhaps seeked( qint64 position ) and trackPositionChanged( qint64 position ), with the former being connected to the latter?



src/EngineController.h
<http://git.reviewboard.kde.org/r/100120/#comment200>

    This doesn't seem to be emitted or used anywhere.



src/EngineController.cpp
<http://git.reviewboard.kde.org/r/100120/#comment201>

    m_currentAlbum = 0, surely?



src/EngineController.cpp
<http://git.reviewboard.kde.org/r/100120/#comment202>

    Delete, rather than commenting out.



src/EngineController.cpp
<http://git.reviewboard.kde.org/r/100120/#comment205>

    Shouldn't m_currentAlbum be set to 0 as well?



src/EngineController.cpp
<http://git.reviewboard.kde.org/r/100120/#comment204>

    If this is false, the value of m_currentAlbum will be stale, won't it?


- Alex


On 2010-10-31 15:53:10, Ralf Engels wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/100120/
> -----------------------------------------------------------
> 
> (Updated 2010-10-31 15:53:10)
> 
> 
> Review request for Amarok.
> 
> 
> Summary
> -------
> 
> Remove EngineObserver and the observer pattern.
> Instead we have several new signals and functions in EngineController.
> Also the EngineController is now a MetaObserver for the current track and exporting the relevant signals.
> 
> This patch improves the tread safety and reduces the complexity of the code by a lot.
> Over 600 lines of codes could be removed while at the same time fixing the image update problems and several small problems where classes listened for the album meta changed but forgot that the album could change when a user changed the track.
> 
> 
> Diffs
> -----
> 
>   playground/src/context/applets/coverbling/CoverBlingApplet.h a3ff113 
>   playground/src/context/applets/coverbling/CoverBlingApplet.cpp a2a50e7 
>   playground/src/context/applets/video/Video.h 1d52f0b 
>   playground/src/context/applets/video/Video.cpp 8471497 
>   src/ActionClasses.h aa67ec7 
>   src/ActionClasses.cpp 61e8af8 
>   src/App.cpp e6006b9 
>   src/EngineController.h aae4503 
>   src/EngineController.cpp 65b3f2e 
>   src/KNotificationBackend.h 02cc9d8 
>   src/KNotificationBackend.cpp b98391c 
>   src/MainWindow.h 4593d47 
>   src/MainWindow.cpp 9102558 
>   src/TrayIcon.h d1ffd43 
>   src/TrayIcon.cpp 47f56bf 
>   src/amarokurls/AmarokUrlHandler.cpp 1d8cd46 
>   src/context/ContextView.h a3f36fb 
>   src/context/ContextView.cpp ccfe4f3 
>   src/context/applets/photos/PhotosApplet.h 4cac9ea 
>   src/context/applets/photos/PhotosApplet.cpp 0b47da9 
>   src/context/applets/similarartists/SimilarArtistsApplet.h 3a2d7ea 
>   src/context/applets/similarartists/SimilarArtistsApplet.cpp 0cf2c76 
>   src/context/applets/videoclip/VideoclipApplet.h a0704c6 
>   src/context/applets/videoclip/VideoclipApplet.cpp 789173e 
>   src/context/engines/current/CurrentEngine.h 0369065 
>   src/context/engines/current/CurrentEngine.cpp 2c32f75 
>   src/context/engines/labels/LabelsEngine.h 626a030 
>   src/context/engines/labels/LabelsEngine.cpp 65278b4 
>   src/context/engines/lyrics/LyricsEngine.h 771bf6f 
>   src/context/engines/lyrics/LyricsEngine.cpp 527cd0d 
>   src/context/engines/similarartists/SimilarArtistsEngine.h fea9bf5 
>   src/context/engines/similarartists/SimilarArtistsEngine.cpp 97bc109 
>   src/context/engines/upcomingevents/UpcomingEventsEngine.h c57b004 
>   src/context/engines/upcomingevents/UpcomingEventsEngine.cpp 66131fd 
>   src/context/engines/wikipedia/WikipediaEngine.h 5d53082 
>   src/context/engines/wikipedia/WikipediaEngine.cpp 4c65799 
>   src/core-impl/meta/stream/Stream_p.h cd217bf 
>   src/core-impl/meta/timecode/TimecodeObserver.h b727196 
>   src/core-impl/meta/timecode/TimecodeObserver.cpp dea809d 
>   src/core/CMakeLists.txt 5863ca1 
>   src/core/engine/EngineObserver.h 5a93062 
>   src/core/engine/EngineObserver.cpp 7d5728b 
>   src/dbus/mpris1/PlayerHandler.h 8f90f27 
>   src/dbus/mpris1/PlayerHandler.cpp 0afeb59 
>   src/dbus/mpris2/Mpris2DBusHandler.h a767c79 
>   src/dbus/mpris2/Mpris2DBusHandler.cpp 59afbf3 
>   src/dialogs/ScriptManager.h 6104dcf 
>   src/dialogs/ScriptManager.cpp e98f45f 
>   src/dynamic/BiasSolver.cpp bf8e3c8 
>   src/dynamic/biases/EchoNest.h 9a6ecc7 
>   src/dynamic/biases/EchoNest.cpp 16f26f4 
>   src/mac/GrowlInterface.h 3bb35d2 
>   src/mac/GrowlInterface.cpp 862d019 
>   src/playlist/PlaylistActions.h 035ff77 
>   src/playlist/PlaylistActions.cpp 2358b29 
>   src/playlist/PlaylistController.cpp d38c9d6 
>   src/playlist/view/listview/PrettyItemDelegate.cpp ab19ccc 
>   src/scriptengine/AmarokEngineScript.h 55e275c 
>   src/scriptengine/AmarokEngineScript.cpp 15f7b6e 
>   src/services/lastfm/ScrobblerAdapter.h ef7a7c1 
>   src/services/lastfm/ScrobblerAdapter.cpp 1b4da4a 
>   src/services/lastfm/biases/LastFmBias.h 6ba571d 
>   src/services/lastfm/biases/LastFmBias.cpp 4093104 
>   src/statemanagement/DefaultApplicationController.cpp 8205aab 
>   src/statusbar/StatusBar.h b785714 
>   src/statusbar/StatusBar.cpp 48df821 
>   src/toolbar/CurrentTrackToolbar.h c8293f3 
>   src/toolbar/CurrentTrackToolbar.cpp 22408ea 
>   src/toolbar/MainToolbar.h fc29ba2 
>   src/toolbar/MainToolbar.cpp abeedc6 
>   src/toolbar/SlimToolbar.h dcfaf22 
>   src/toolbar/SlimToolbar.cpp e69df7c 
>   src/toolbar/VolumePopupButton.h a0f5d56 
>   src/toolbar/VolumePopupButton.cpp fb5fcb1 
>   src/widgets/Osd.h b80b37e 
>   src/widgets/Osd.cpp af4b24b 
>   src/widgets/ProgressWidget.h 3fba490 
>   src/widgets/ProgressWidget.cpp 211cea7 
>   src/widgets/VolumeWidget.h 910e9f1 
>   src/widgets/VolumeWidget.cpp e1d01f1 
>   tests/core-impl/meta/multi/CMakeLists.txt 8a51249 
>   tests/playlist/CMakeLists.txt 01703fe 
> 
> Diff: http://git.reviewboard.kde.org/r/100120/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Ralf
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/amarok-devel/attachments/20101031/b81e20c3/attachment-0001.htm 


More information about the Amarok-devel mailing list