QtGstreamer fails creating pipeline after QGst::cleanup()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

QtGstreamer fails creating pipeline after QGst::cleanup()

Karl Phillip
Hi all,

I spent a lot of time to pinpoint this problem and I wonder if it's a bug of QtGstreamer or not.
If it's not, we seriously need to make this thing more clear on the documentation and prevent others from making the same mistake as I did.

I wrote a VideoPlayer class to deal with video files using QtGstreamer under the hood. I was able to instantiate a VideoPlayer object and display the video with no problems.
Then, I tried to destroy the current player and instantiate a new one (within the same thread) to watch another video. That's when it happend: the second object failed to create it's pipeline.

Hours of investigation went by until I found the source of the problem: the constructor of VideoPlayer initialized the library through "QGst::init();" and the destructor did the opposite with "QGst::cleanup();".
It was my understanding that after a cleanup() operation, a call to init() would restore things back to it's operational state, but so it happens that cleanup() makes it impossible.

What is also strange is that calling QGst::init() after a cleanup() doesn't return any errors nor throw exceptions, which I think it should, since you can't use the library to create a new pipeline rendering it pretty much useless.

I wrote a small demo to reproduce this behavior:

#include <QObject>
#include <QGst/Init>
#include <QGst/Pipeline>
#include <QGst/Element>

int main()
{

    qDebug() << "#1 call QGst::init()";
    QGst::init();

    QGst::PipelinePtr _pipeline = QGst::Pipeline::create();
    if (!_pipeline)
    {
        qDebug() << "#1 Failed creating pipeline !!!";
        return -1;
    }

    qDebug() << "#1 Setting pipeline to Playing";
    _pipeline->setState(QGst::StatePlaying);

    qDebug() << "#1 Setting pipeline to Null";
    _pipeline->setState(QGst::StateNull);

    qDebug() << "#1 call pipeline.clear()";
    _pipeline.clear();

    qDebug() << "#1 call QGst::cleanup()";
    QGst::cleanup();

    qDebug() << "\n* Press <enter> to restart the pipeline setup";
    getchar();

    qDebug() << "#2 call QGst::init()";
    QGst::init();
    _pipeline = QGst::Pipeline::create();
    if (!_pipeline)
    {
        qDebug() << "#2 Failed creating pipeline !!!";
        return -1;
    }

    return 0;
}


Thanks!
--
Karl Phillip



_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: QtGstreamer fails creating pipeline after QGst::cleanup()

George Kiagiadakis
On Tue, Nov 29, 2011 at 1:36 PM, Karl Phillip <[hidden email]> wrote:
> Hi all,
>
> I spent a lot of time to pinpoint this problem and I wonder if it's a bug of
> QtGstreamer or not.
> If it's not, we seriously need to make this thing more clear on the
> documentation and prevent others from making the same mistake as I did.

It's not a bug, afaik. After calling QGst::cleanup() (i.e.
gst_deinit()), you cannot use GStreamer anymore. This method is
intended to be used to cleanup when you exit your application, just to
avoid showing possible leaks in memory profilers like valgrind. You
normally don't need to call it at all.

> What is also strange is that calling QGst::init() after a cleanup() doesn't
> return any errors nor throw exceptions, which I think it should, since you
> can't use the library to create a new pipeline rendering it pretty much
> useless.

Doesn't it show anything on stderr?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: QtGstreamer fails creating pipeline after QGst::cleanup()

Karl Phillip
It shows nothing on stderr. I would expect init() to fail after cleanup().

Thanks!
--
Karl Phillip


On 29/11/2011, at 11:39, George Kiagiadakis <[hidden email]> wrote:

> On Tue, Nov 29, 2011 at 1:36 PM, Karl Phillip <[hidden email]> wrote:
>> Hi all,
>>
>> I spent a lot of time to pinpoint this problem and I wonder if it's a bug of
>> QtGstreamer or not.
>> If it's not, we seriously need to make this thing more clear on the
>> documentation and prevent others from making the same mistake as I did.
>
> It's not a bug, afaik. After calling QGst::cleanup() (i.e.
> gst_deinit()), you cannot use GStreamer anymore. This method is
> intended to be used to cleanup when you exit your application, just to
> avoid showing possible leaks in memory profilers like valgrind. You
> normally don't need to call it at all.
>
>> What is also strange is that calling QGst::init() after a cleanup() doesn't
>> return any errors nor throw exceptions, which I think it should, since you
>> can't use the library to create a new pipeline rendering it pretty much
>> useless.
>
> Doesn't it show anything on stderr?
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel