fix crash (since audioselection) on playing audio only files
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Thu, 25 Sep 2008 07:00:00 +0000 (07:00 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Thu, 25 Sep 2008 07:00:00 +0000 (07:00 +0000)
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index f3f441772bb374c35b2f604efc3ab0c0a9e0360b..e3a6228d4d8a9abe506b0c356d39ed44e629cc43 100644 (file)
@@ -309,10 +309,11 @@ eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eAp
                        gst_element_add_pad(audio, gst_ghost_pad_new ("sink", audiopad));
                        gst_object_unref(audiopad);
                        gst_bin_add (GST_BIN(m_gst_pipeline), audio);
-
                                /* in mad's case, we can directly connect the decoder to the audiobin. otherwise, we do this in gstCBnewPad */
                        if (is_mp3)
                                gst_element_link(decoder, audio);
+                       audioStream audioStreamElem;
+                       m_audioStreams.push_back(audioStreamElem);
                } else /* is_video */
                {
                        gst_bin_add_many(GST_BIN(m_gst_pipeline), source, videodemux, audio, queue_audio, video, queue_video, NULL);
@@ -703,8 +704,12 @@ RESULT eServiceMP3::getTrackInfo(struct iAudioTrackInfo &info, unsigned int i)
                info.m_description = "AC3";
        else if (m_audioStreams[i].type == audioStream::atAAC)
                info.m_description = "AAC";
-       else  if (m_audioStreams[i].type == audioStream::atDTS)
+       else if (m_audioStreams[i].type == audioStream::atDTS)
                info.m_description = "DTS";
+       else if (m_audioStreams[i].type == audioStream::atPCM)
+               info.m_description = "PCM";
+       else if (m_audioStreams[i].type == audioStream::atOGG)
+               info.m_description = "OGG";
        else
                info.m_description = "???";
        if (info.m_language.empty())
@@ -766,15 +771,19 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg)
                        m_stream_tags = result;
                }
                gchar *g_audiocodec;
-               if (gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_audiocodec))
+               if (gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_audiocodec) && m_audioStreams.size())
                {
                        std::vector<audioStream>::iterator IterAudioStream = m_audioStreams.begin();
                        while ( IterAudioStream->language_code.length() && IterAudioStream != m_audioStreams.end())
                                IterAudioStream++;
                        if ( g_strrstr(g_audiocodec, "MPEG-1 layer 2") )
                                IterAudioStream->type = audioStream::atMP2;
+                       else if ( g_strrstr(g_audiocodec, "MPEG-1 layer 3") )
+                               IterAudioStream->type = audioStream::atMP3;
                        else if ( g_strrstr(g_audiocodec, "AC-3 audio") )
                                IterAudioStream->type = audioStream::atAC3;
+                       else if ( g_strrstr(g_audiocodec, "Uncompressed\ 16-bit\ PCM\ audio") )
+                               IterAudioStream->type = audioStream::atPCM;
                        gchar *g_language;
                        if ( gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_language) )
                                IterAudioStream->language_code = std::string(g_language);
index bf29efcf69a79fbc66928462d748f692a2e29910..aa342f4bf68604d59774cfd2150775cb4aa16bc3 100644 (file)
@@ -103,12 +103,13 @@ public:
        struct audioStream
        {
                GstPad* pad;
-               enum { atMP2, atMP3, atAC3, atDTS, atAAC };
+               enum { atMP2, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG };
                int type; // mpeg2, ac3, dts, ...
                std::string language_code; /* iso-639, if available. */
        };
 private:
        int m_currentAudioStream;
+       int m_currentTrickRate;
        std::vector<audioStream> m_audioStreams;
        friend class eServiceFactoryMP3;
        std::string m_filename;