ServiceMP3: send evUpdatedInfo only the first time bitrate changes
authorAthanasios Oikonomou <athoik@gmail.com>
Tue, 17 Nov 2015 17:40:22 +0000 (19:40 +0200)
committerErik Slagter <erik@openpli.org>
Tue, 17 Nov 2015 18:13:40 +0000 (19:13 +0100)
Send evUpdatedInfo only the first time bitrate changes in order
to reduce events. This is required with GStreamer >= 1.6.0.

More info: http://forums.openpli.org/topic/29501-gstreamer-10/page-96

(cherry picked from commit a4c053e67632855e94d58ff9798ea9fea5d27edd)
Signed-off-by: Erik Slagter <erik@openpli.org>

lib/service/servicemp3.cpp
lib/service/servicemp3.h

index 9ac7645..0d9b7d9 100644 (file)
@@ -403,6 +403,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref):
        m_subtitle_sync_timer = eTimer::create(eApp);
        m_streamingsrc_timeout = 0;
        m_stream_tags = 0;
+       m_bitrate = 0;
        m_currentAudioStream = -1;
        m_currentSubtitleStream = -1;
        m_cachedSubtitleStream = 0; /* report the first subtitle stream to be 'cached'. TODO: use an actual cache. */
@@ -1797,6 +1798,22 @@ void eServiceMP3::gstBusCall(GstMessage *msg)
                                if (m_stream_tags)
                                        gst_tag_list_free(m_stream_tags);
                                m_stream_tags = result;
+
+                               /* send evUpdatedInfo only when bitrate changes from 0 in order to reduce events */
+                               guint value;
+                               if(gst_tag_list_get_uint(m_stream_tags, GST_TAG_BITRATE, &value))
+                               {
+                                       if(!m_bitrate && value)
+                                       {
+                                               m_bitrate = value;
+                                       }
+                                       else
+                                       {
+                                               m_bitrate = value;
+                                               gst_tag_list_free(tags);
+                                               break;
+                                       }
+                               }
                        }
 
                        const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0);
index c8a9fe7..61943c8 100644 (file)
@@ -323,6 +323,7 @@ private:
        int m_state;
        GstElement *m_gst_playbin, *audioSink, *videoSink;
        GstTagList *m_stream_tags;
+       guint m_bitrate;
 
        eFixedMessagePump<ePtr<GstMessageContainer> > m_pump;