Gapless playback for UPnP Renderer (and other improvements) (2 Viewers)

Marcus Venturi

MP Donator
  • Premium Supporter
  • March 23, 2012
    614
    745
    56
    Home Country
    Germany Germany
    I'm working since 2 years on a UPnP Controller for ANDROID, which should be very simple to use.

    As MediaPortal user my first goal is to have perfect playback together with the MediaPortal UPnP Renderer plugin developed from @hierl_w.

    https://forum.team-mediaportal.com/threads/working-on-new-mp-upnp-renderer-process-plugin.104959/#post835560

    As the UPnP Renderer does not support gapless playback or crossfade so far, I started to implement this.
    For this purpose I took the source code provided by @Dragy in the forum.

    I modified my ANDROID client, the UPnP Renderer and a few things in the BASS engine. (I implemented the SetNextAVTransportURI action in my client as well as in the UPnP Renderer).

    Everything works but not 100% perfect, because there are still small gaps (hickup) between the tracks.

    This is where I need the help of the other developers.
    I think of @hwahrmann or any other dev that has worked on the BASS engine and has knowledge of this.

    My changes are here:

    https://github.com/MediaPortal/MediaPortal-1/compare/master...UnlimitedStack:EXP_UPNP_RENDERER_FIXES

    This branch contains all fixes I made to improve the UPnP renderer playback. They are not only BASS related.

    As there is no repository for the latest MP_UPnPRenderer changes, I attached my modified version of the plugin. I could also provide the code.

    I added support for generating a fixed Unique Device Name. This can help if there are more than one MediaPortal instances running on the same network:

    upload_2015-4-20_15-38-23.png


    And of course the support for gapless playback:

    upload_2015-4-20_15-44-24.png


    To have a contoller for testing / debugging gapless playback, I attached an APK of my client.
    It can be manually installed on ANDROID. It is necessary to enable installation of apps from other sources than the Play Store. The app itself can be installed with Apk Installer.

    https://play.google.com/store/apps/details?id=com.graphilos.apkinst&hl=de

    After starting the app you see this:

    upload_2015-4-20_15-39-43.png


    Just tap on the gear on the left bottom, then you can select Server and Renderer:

    upload_2015-4-20_15-40-19.png


    Close the dialog with (X) and tap on the "Power On" symbol.that should appear if Server and Renderer are selected and available.

    upload_2015-4-20_15-40-57.png


    Then browse to a music album for testing:

    upload_2015-4-20_15-41-43.png


    Tap on a song to start playing.

    There is a control panel for playback. Just tap on the arrow-down symbol in the top right corner:

    upload_2015-4-20_15-42-26.png


    Now you can test gapless playback.

    My goal is to find out the reason for the remaining hickup(s).

    A big THANK YOU goes to @hierl_w, @Dragy and all the others that kept this plugin alive :)

    :) Let's hope somebody can help me...

    ATTENTION: As mentioned above, you have to build your own version of MediaPortal with this branch included:

    https://github.com/MediaPortal/MediaPortal-1/compare/master...UnlimitedStack:EXP_UPNP_RENDERER_FIXES

    Otherwise it won't work!!!

    UPDATE: Added new APK with bug fix
     

    Attachments

    • JustMusic-release.apk
      5 MB
    • MP_UPnPRenderer.zip
      307.7 KB
    • JustMusic-release-2.apk
      5 MB
    Last edited:

    Marcus Venturi

    MP Donator
  • Premium Supporter
  • March 23, 2012
    614
    745
    56
    Home Country
    Germany Germany
    A few details about the implementation of the UPnP gapless playback.

    Normally in UPnP the controller - is responsible for controlling how the renderer plays the files.

    The controller calls the UPnP action "SetAVTransportURI" to tell the renderer which song to play and then starts playback with the "Play" action. The renderer just takes the song from the given URI and plays it.

    When the song is finished the controller calls the action "SetAVTransportURI" again and starts playback again with the "Play" action.

    This concept makes gapless playback impossible.

    But there is also an UPnP action called "SetNextAVTransportURI".

    This tells the renderer which song to play after the current song has ended.
    In this case the renderer is responsible for playing the next song and not the controller.

    Now the client has only to call the action "SetAVTransportURI" for the first song and then the action "Play".
    Before a song ends the client calls the action "SetNextAVTransportURI" to keep the renderer playing.

    This allows the renderer to play gapless (if he is capable) between the current and the next song, that's all the magic.

    And this is the reason why most controller / renderer combinations are not able to play music gapless, because either the controller or the renderer does not implement the "SetNextAVTransportURI" action.

    My ANDROID client checks if the renderer supports the "SetNextAVTransportURI" action. If yes, it is used to allow gapless playback.
     
    Last edited:

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    Really nice!
    Could you publish your src for the renderer? I'm working on a renderer for MP2 and I guess it is very easy to implement the last step. Indeed I already have support for SetNextAVTransportURI it just doesn't get checked^^
     

    powermarcel10

    Retired Team Member
  • Premium Supporter
  • November 30, 2010
    2,839
    898
    35
    Groningen
    Home Country
    Netherlands Netherlands
    Hi Marcus, really nice work! Is there no way to release this just as a plugin without changing anything to the MP core? Or will the core things being changed for MP 1.12. I really like to try this!
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    Very nice!

    Tried the previous releases from @Dragy but maybe due to MePo changes it doesn't work right anymore at least with the Sony Walkman client, here's hoping this one works perfectly ;)
    Would be great if we can try this out without having to compile that MePo branch but gonna give it a go :)
     

    powermarcel10

    Retired Team Member
  • Premium Supporter
  • November 30, 2010
    2,839
    898
    35
    Groningen
    Home Country
    Netherlands Netherlands

    Marcus Venturi

    MP Donator
  • Premium Supporter
  • March 23, 2012
    614
    745
    56
    Home Country
    Germany Germany
    That's my goal, but it depends on how fast it is possible to fix the remainig hickups between 2 songs.
     

    Users who are viewing this thread

    Top Bottom