Commit ee242508 authored by Ghislain MARY's avatar Ghislain MARY

Prevent creating an event queue when calling ms_queue_pump() in...

Prevent creating an event queue when calling ms_queue_pump() in audio_stream_stop() and video_stream_stop().
parent 9d2cbff6
......@@ -247,6 +247,20 @@ MS2_PUBLIC void ms_factory_init_voip(MSFactory *obj);
MS2_PUBLIC void ms_factory_uninit_voip(MSFactory *obj);
/**
* Creates an event queue.
* Only one can exist so if it has already been created the same one will be returned.
* @param[in] obj MSFactory object.
* @return The created event queue.
*/
MS2_PUBLIC struct _MSEventQueue * ms_factory_create_event_queue(MSFactory *obj);
/**
* Gets the event queue associated with the factory.
* Can be NULL if no event queue has been created.
* @param[in] obj MSFactory object.
* @return The event queue associated with the factory.
*/
MS2_PUBLIC struct _MSEventQueue * ms_factory_get_event_queue(MSFactory *obj);
MS2_PUBLIC void ms_factory_set_event_queue(MSFactory *obj,struct _MSEventQueue *q);
......
......@@ -720,13 +720,17 @@ void ms_factory_set_plugins_dir(MSFactory *obj, const char *path) {
obj->plugins_dir = ms_strdup(path);
}
struct _MSEventQueue *ms_factory_get_event_queue(MSFactory *obj){
struct _MSEventQueue *ms_factory_create_event_queue(MSFactory *obj) {
if (obj->evq==NULL){
obj->evq=ms_event_queue_new();
}
return obj->evq;
}
struct _MSEventQueue *ms_factory_get_event_queue(MSFactory *obj){
return obj->evq;
}
/*this function is for compatibility, when event queues were created by the application*/
void ms_factory_set_event_queue(MSFactory *obj, MSEventQueue *evq){
obj->evq=evq;
......
......@@ -1532,6 +1532,8 @@ static void dismantle_local_player(AudioStream *stream){
}
void audio_stream_stop(AudioStream * stream){
MSEventQueue *evq;
if (stream->ms.sessions.ticker){
MSConnectionHelper h;
......@@ -1614,7 +1616,8 @@ void audio_stream_stop(AudioStream * stream){
rtp_session_signal_disconnect_by_callback(stream->ms.sessions.rtp_session,"payload_type_changed",(RtpCallback)audio_stream_payload_type_changed);
/*before destroying the filters, pump the event queue so that pending events have a chance to reach their listeners.
* When the filter are destroyed, all their pending events in the event queue will be cancelled*/
ms_event_queue_pump(ms_factory_get_event_queue(stream->ms.factory));
evq = ms_factory_get_event_queue(stream->ms.factory);
if (evq) ms_event_queue_pump(evq);
audio_stream_free(stream);
ms_filter_log_statistics();
}
......
......@@ -1314,7 +1314,9 @@ void video_stream_send_vfu(VideoStream *stream){
static MSFilter* _video_stream_stop(VideoStream * stream, bool_t keep_source)
{
MSEventQueue *evq;
MSFilter* source = NULL;
stream->eventcb = NULL;
stream->event_pointer = NULL;
if (stream->ms.sessions.ticker){
......@@ -1409,7 +1411,8 @@ static MSFilter* _video_stream_stop(VideoStream * stream, bool_t keep_source)
}
/*before destroying the filters, pump the event queue so that pending events have a chance to reach their listeners.
* When the filter are destroyed, all their pending events in the event queue will be cancelled*/
ms_event_queue_pump(ms_factory_get_event_queue(stream->ms.factory));
evq = ms_factory_get_event_queue(stream->ms.factory);
if (evq) ms_event_queue_pump(evq);
video_stream_free(stream);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment