diff --git a/VideoImpl.cpp b/VideoImpl.cpp index 3fa0d5e..b0ea47c 100644 --- a/VideoImpl.cpp +++ b/VideoImpl.cpp @@ -306,6 +306,10 @@ void VideoImpl::resetMovie() bool VideoImpl::createVideoComponents() { + // Already supported? + if (videoIsSupported()) + return true; + // Create the video elements. _queue0 = gst_element_factory_make ("queue", "queue0"); _videoconvert0 = gst_element_factory_make ("videoconvert", "videoconvert0"); @@ -356,6 +360,10 @@ bool VideoImpl::createVideoComponents() bool VideoImpl::createAudioComponents() { + // Already supported? + if (audioIsSupported()) + return true; + // Create the audio elements. _audioqueue0 = gst_element_factory_make ("queue", "audioqueue0"); _audioconvert0 = gst_element_factory_make ("audioconvert", "audioconvert0"); diff --git a/VideoImpl.h b/VideoImpl.h index d44948b..f7a2907 100644 --- a/VideoImpl.h +++ b/VideoImpl.h @@ -112,6 +112,8 @@ public: bool videoIsConnected() const { return _videoIsConnected; } void videoConnect() { _videoIsConnected = true; } + bool videoIsSupported() const { return _queue0 != NULL; } + bool audioIsConnected() const { return _audioIsConnected; } void audioConnect() { _audioIsConnected = true; } bool audioIsSupported() const { return _audioqueue0 != NULL; } diff --git a/VideoUriDecodeBinImpl.cpp b/VideoUriDecodeBinImpl.cpp index 90381d0..95aaaec 100644 --- a/VideoUriDecodeBinImpl.cpp +++ b/VideoUriDecodeBinImpl.cpp @@ -69,13 +69,12 @@ void VideoUriDecodeBinImpl::gstPadAddedCallback(GstElement *src, GstPad *newPad, // Check for audio pads. else if (isAudioPad) { - if (p->audioIsSupported()) - sinkPad = gst_element_get_static_pad (p->_audioqueue0, "sink"); - else if (!p->createAudioComponents()) + if (!p->createAudioComponents()) { qWarning() << "Problem creating audio components." << endl; goto exit; } + sinkPad = gst_element_get_static_pad (p->_audioqueue0, "sink"); } // Other types: ignore. @@ -263,7 +262,7 @@ bool VideoUriDecodeBinImpl::loadMovie(const QString& path) { g_object_set (_uridecodebin0, "uri", uri, NULL); setPlayState(true); - + return true; }