Quantcast

Multiple loops in one library

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multiple loops in one library

Mikl
Hello,

Can i have multiple GMainLoop independent objects inside of one library(dll)?
My wish is to process multiple steams in one container.
Or it is "one for all" and can be different only inside of other library(dll)?

My wish :

If i have "recorder" and "reader" classes in different threads, but defined in the same library(dll):
GMainLoop* readerLoop = g_main_loop_new(NULL, FALSE);
GMainLoop* wriretLoop = g_main_loop_new(NULL, FALSE);

Both have pipelines:
GstElement* readerPipeline;
GstElement* writerPipeline;

Later, when i am watching events:
GstBus* readerBus = gst_pipeline_get_bus(GST_PIPELINE(readerPipeline));
gst_bus_add_watch(readerBus , BusCallback, this);
g_main_loop_run(readerLoop);

GstBus* writerBus = gst_pipeline_get_bus(GST_PIPELINE(writerPipeline));
gst_bus_add_watch(writerBus , BusCallback, this);
g_main_loop_run(wriretLoop);

Now, i have exception inside of BusCallback:
Exception thrown at 0x6146F214 (libgstreamer-1.0-0.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0xCDCDCDCD.

Will it work? Is any way to do it?

Thank you in advance.
Mikl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple loops in one library

filnet
You exception is due to improper initialization of something.
You don't show us enough code to help.

But note that g_main_loop_run() is a blocking method (afaik). It will not return until the loop is stopped. So execution flow of your code will stop on the first call to g_main_loop_run().
I think what you are trying to do will work fine with just one loop...


Le Mercredi 12 avril 2017 17h03, Mikl <[hidden email]> a écrit :


Hello,

Can i have multiple GMainLoop independent objects inside of one
library(dll)?
My wish is to process multiple steams in one container.
Or it is "one for all" and can be different only inside of other
library(dll)?

My wish :

If i have "recorder" and "reader" classes in different threads, but defined
in the same library(dll):
GMainLoop* readerLoop = g_main_loop_new(NULL, FALSE);
GMainLoop* wriretLoop = g_main_loop_new(NULL, FALSE);

Both have pipelines:
GstElement* readerPipeline;
GstElement* writerPipeline;

Later, when i am watching events:
GstBus* readerBus = gst_pipeline_get_bus(GST_PIPELINE(readerPipeline));
gst_bus_add_watch(readerBus , BusCallback, this);
g_main_loop_run(readerLoop);

GstBus* writerBus = gst_pipeline_get_bus(GST_PIPELINE(writerPipeline));
gst_bus_add_watch(writerBus , BusCallback, this);
g_main_loop_run(wriretLoop);

Now, i have exception inside of BusCallback:
Exception thrown at 0x6146F214 (libgstreamer-1.0-0.dll) in MyApp.exe:
0xC0000005: Access violation reading location 0xCDCDCDCD.

Will it work? Is any way to do it?

Thank you in advance.
Mikl



--
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list



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

Re: Multiple loops in one library

Mikl
This post was updated on .
Hello, filnet

Thank you for the answer.

I am aware about blocking nature of g_main_loop_run(). That's why i run reader and writer in parallel threads.
Or it is the same for the loop: i can call g_main_loop_run() from different threads, but it will block on the same object? In this case, i can believe, what running second loop from another thread is causing exception.

Here is my code:
GStreamer is base class. Contain basic functions
GStreamerWriter and GStreamerReader contain specific functions. inherit from GStreamer.
GStreamePlayer, GStreameInspector and GStreameRecorder are realizations.

I want to run all three in parallel in my application.
GStreamePlayer and GStreameInspector are working fine together, but starting GStreameRecorder is causing exception.

GStreamer.7z

PS: the mutexes and GStreamerInitialized in GStreamer it is something i already doing to try to fix the problem. Normally i want to do it without global variables.

Thank you in advance.
Mikl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple loops in one library

filnet
Hi,

Had a quick look at your code.
I am not sure but it could be that you have infinite recursion in your bus callback handling.

Are you sure that the following line is correct:
    GStreamer::StartWaitgLoop(&GStreamer::BusCallback);
and that it points to the derived callback as intended and not to the root callback?

Philippe.


Le Vendredi 14 avril 2017 9h18, Mikl <[hidden email]> a écrit :


Hello, filnet

Thank you for the answer.

I am aware about blocking nature of g_main_loop_run(). That's why i run
reader and writer in parallel threads.
Or it is the same for the loop: i can call g_main_loop_run() from different
threads, but it will block on the same object? In this case, i can believe,
what running second loop from another thread is causing exception.

Here is my code:
GStreamer is base class. Contain basic functions
GStreamerWriter and GStreamerReader contain specific functions. inherit from
GStreamer.
GStreamePlayer, GStreameInspector and GStreameRecorder are realizations.

I want to run all three in parallel in my application.

GStreamer.7z
<http://gstreamer-devel.966125.n4.nabble.com/file/n4682664/GStreamer.7z

Thank you in advance.
Mikl



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Multiple-loops-in-one-library-tp4682638p4682664.html

Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



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

Re: Multiple loops in one library

Mikl
Hello, filnet

GStreamer::BusCallback is virtual function.
virtual int BusCallback(GstMessage* message, void* data) = 0;

Real call back done in
static int GStreamer::BusCallback(GstBus* bus, GstMessage* message, void* data)
{
 return (library->*(library->_callBack))(message, data);
}

Don`t think i can do something wrong here.

Mikl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple loops in one library

filnet
You are probably right... The callback handling is a bit contrived. Why don't you call the callback directly (i.e. the _callBack member seems redundant).

Anyways, did you try to reproduce your issue under a debugger to get the location and call stack of the access violation?


Le Mardi 18 avril 2017 9h11, Mikl <[hidden email]> a écrit :


Hello, filnet

GStreamer::BusCallback is virtual function.
virtual int BusCallback(GstMessage* message, void* data) = 0;

Real call back done in
static int GStreamer::BusCallback(GstBus* bus, GstMessage* message, void*
data)
{
return (library->*(library->_callBack))(message, data);
}

Don`t think i can do something wrong here.

Mikl



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Multiple-loops-in-one-library-tp4682638p4682688.html

Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



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

Re: Multiple loops in one library

Mikl
Hello, filnet

Bug is found! You was right: one of bools was not initialized and had value 205. :) Also some other small things.
Thank you for help.

I will keep _callBack for now. The idea is to have common start of loop but possibility to have different stop.
For example, in recording i am not care about ASYNC_DONE, but in reading about EOS.
Also kind of interface for future realizations.

Mikl.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple loops in one library

filnet
You're welcome. Glad your resolved your issue :)


Le Mercredi 19 avril 2017 15h22, Mikl <[hidden email]> a écrit :


Hello, filnet

Bug is found! You was right: one of bools was not initialized and had value
205. :) Also some other small things.
Thank you for help.

I will keep _callBack for now. The idea is to have common start of loop but
possibility to have different stop.
For example, in recording i am not care about ASYNC_DONE, but in reading
about EOS.
Also kind of interface for future realizations.

Mikl.





--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Multiple-loops-in-one-library-tp4682638p4682729.html

Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Loading...