Bug 252649

Summary: Fails to play Last.fm streams with Amarok
Product: [Frameworks and Libraries] phonon-backend-gstreamer Reporter: Mark Kretschmann <kretschmann>
Component: generalAssignee: Harald Sitter <sitter>
Status: RESOLVED FIXED    
Severity: normal CC: martin.sandsmark, myriam, sitter
Priority: HI    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.4.4
Sentry Crash Report:

Description Mark Kretschmann 2010-09-28 14:50:38 UTC
Version:           4.4.2 (KDE 4.5) (using KDE 4.5.1) 
OS:                Linux

Playing any Last.fm streams just cycles from error to error. Debug output from GStreamer is this:


0:00:22.765423684 23027 0x7f9f78012d70 WARN                 basesrc gstbasesrc.c:2550:gst_base_src_loop:<phononsrc0> error: Internal data flow error.
0:00:22.765463280 23027 0x7f9f78012d70 WARN                 basesrc gstbasesrc.c:2550:gst_base_src_loop:<phononsrc0> error: streaming task paused, reason error (-5)
0:00:22.765540670 23027 0x7f9f78012d70 WARN                typefind gsttypefindelement.c:561:gst_type_find_element_handle_event:<typefind> error: Stream contains no data.
0:00:22.765568285 23027 0x7f9f78012d70 WARN                typefind gsttypefindelement.c:561:gst_type_find_element_handle_event:<typefind> error: Can't typefind empty stream


Reproducible: Always

Steps to Reproduce:
Play Last.fm stream in Amarok.


Actual Results:  
fail

Expected Results:  
works
Comment 1 Harald Sitter 2010-12-18 14:42:28 UTC
Seems as if GStreamer closes the data stream in between getting metadata and actual playback start. Last.fm urls however only work once (i.e. you can open the URL on time and after that you'll get a 403, which is what gst falls over here).
Comment 2 Harald Sitter 2011-01-05 15:20:29 UTC
This will be partially solved in Phonon 4.5 in KDE as it defaults to KIO streams for everything but file:

I am not quite sure how to fix it natively though.
Comment 3 Harald Sitter 2011-01-13 20:40:47 UTC
The MediaObject resets connections somewhat randomly, however for Last.fm to work the connection must be held, as the URL is only valid for one connection attempt.
Comment 4 Harald Sitter 2011-01-13 21:17:33 UTC
commit a314c8e04f0e664c9efbb4419a2d48db38a997ae
branch master
Author: Harald Sitter <sitter@kde.org>
Date:   Thu Jan 13 21:15:48 2011 +0100

    Make Last.fm streams work. Their URLs can only be opened once, after
    that they return with forbidden. However the MO likes to reset the
    pipeline a lot and thus opens the connection twice -> fail.
    Worked around it by explicitly preventing last.fm URLs to be reset.
    
    More appropriate fix (removal of the resetting logic) coming with 4.5
    
    BUG: 252649

diff --git a/gstreamer/mediaobject.cpp b/gstreamer/mediaobject.cpp
index b1de342..27b0b3b 100644
--- a/gstreamer/mediaobject.cpp
+++ b/gstreamer/mediaobject.cpp
@@ -785,7 +785,17 @@ void MediaObject::setState(State newstate)
         break;
 
     case Phonon::PlayingState:
-       if (m_resetNeeded) {
+#ifdef __GNUC__
+#warning TODO 4.5
+#endif
+        // TODO 4.5: drop m_resetNeeded completely and use live connections, whatever
+        // those might be.
+        if (m_source.url().host().contains(QLatin1String("last.fm"))) {
+            // Never reset for last.fm as they only allow one connection attempt.
+            // https://bugs.kde.org/show_bug.cgi?id=252649
+            m_resetNeeded = false;
+        }
+        if (m_resetNeeded) {
             // ### Note this is a workaround and it should really be gracefully
             // handled by medianode when we implement live connections.
             // This generally happens if medianodes have been connected after the MediaSource was set
Comment 5 Myriam Schweingruber 2011-04-27 21:18:14 UTC
reassigning to the new bugzilla product for better bug tracing of the various backends. Sorry for the noise.