Commit c8a2aec2 authored by Sandrine Avakian's avatar Sandrine Avakian

Using ms_factory_exit to destroy the factory and set it to NULL.

parent 4f39d6a4
......@@ -246,10 +246,8 @@ MSFactory *ms_factory_new(void){
* This should be done after destroying all objects created by the factory.
**/
void ms_factory_destroy(MSFactory *factory){
factory->ref_count--;
if (factory->ref_count == 0){
ms_factory_uninit_plugins(factory);
//if (factory->evq) ms_event_queue_destroy(factory->evq, factory);
if (factory->evq) ms_factory_destroy_event_queue(factory);
factory->formats=ms_list_free_with_data(factory->formats,(void(*)(void*))ms_fmt_descriptor_destroy);
factory->desc_list=ms_list_free(factory->desc_list);
......@@ -260,19 +258,10 @@ void ms_factory_destroy(MSFactory *factory){
factory->platform_tags = ms_list_free(factory->platform_tags);
if (factory->plugins_dir) ms_free(factory->plugins_dir);
ms_free(factory);
}
//if (factory==fallback_factory) fallback_factory=NULL;
//if (factory==fallback_factory) fallback_factory=NULL;
}
//
//MSFactory* ms_factory_exit(MSFactory* factory){
// ms_factory_uninit_voip(factory);
//
// ms_factory_destroy(factory);
// return NULL;
// }
// return factory;
//}
void ms_factory_register_filter(MSFactory* factory, MSFilterDesc* desc ) {
if (desc->id==MS_FILTER_NOT_SET_ID){
......
......@@ -341,6 +341,16 @@ void ms_factory_uninit_voip(MSFactory *obj){
}
MSFactory* ms_factory_exit(MSFactory* factory){
ms_factory_uninit_voip(factory);
factory->ref_count--;
if (factory->ref_count == 0){
ms_factory_destroy(factory);
return NULL;
}
return factory;
}
void ms_voip_exit(){
if (--ms_voip_ref >0 ) {
ms_message ("Skiping ms_voip_exit, still [%i] ref",ms_voip_ref);
......
......@@ -67,8 +67,7 @@ static int tester_after_all(void) {
ortp_exit();
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......
......@@ -55,9 +55,7 @@ static int tester_before_all(void) {
static int tester_after_all(void) {
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......
......@@ -42,8 +42,7 @@ static int basic_audio_tester_before_all(void) {
static int basic_audio_tester_after_all(void) {
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
ortp_exit();
return 0;
}
......
......@@ -59,19 +59,16 @@ static void filter_register_tester(void) {
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
ms_factory_uninit_voip(factory);
//ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
// ms_exit();
factory = ms_factory_exit(factory);
BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory,"MSVoidSource"));
filter= ms_factory_create_decoder(factory, "pcma");
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
ms_factory_uninit_voip(factory);
// ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
BC_ASSERT_PTR_NULL(factory);
}
#ifdef VIDEO_ENABLED
......@@ -176,7 +173,7 @@ static void test_filterdesc_enable_disable_base(const char* mime, const char* fi
if (is_enc)
filter = ms_factory_create_encoder(factory,mime);
else
filter = ms_factory_create_encoder(factory,mime);
filter = ms_factory_create_decoder(factory,mime);
BC_ASSERT_PTR_NULL(filter);
BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE));
......@@ -189,8 +186,7 @@ static void test_filterdesc_enable_disable_base(const char* mime, const char* fi
ms_filter_destroy(filter);
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
}
static void test_filterdesc_enable_disable(void) {
test_filterdesc_enable_disable_base("pcmu", "MSUlawDec", FALSE);
......
......@@ -31,8 +31,7 @@ static int tester_before_all(void) {
}
static int tester_after_all(void) {
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
return 0;
}
......
......@@ -48,8 +48,7 @@ static int tester_init(void) {
static int tester_cleanup(void) {
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......
......@@ -67,8 +67,7 @@ static int tester_before_all(void) {
static int tester_after_all(void) {
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......
......@@ -332,8 +332,7 @@ static int uninit_bench(struct bench_config *bench)
ortp_free(ts);
}
ms_factory_uninit_voip(bench->factory);
ms_factory_destroy(bench->factory);
bench->factory = ms_factory_exit(bench->factory);
ms_ticker_destroy(bench->ticker);
return 0;
}
......
......@@ -127,7 +127,6 @@ int main(int argc, char *argv[]){
ms_filter_destroy(f1);
ms_filter_destroy(f2);
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
return 0;
}
......@@ -1110,8 +1110,7 @@ void clear_mediastreams(MediastreamDatas* args) {
if (args->logfile)
fclose(args->logfile);
ms_factory_uninit_voip(args->video->ms.factory);
ms_factory_destroy(args->video->ms.factory);
args->video->ms.factory = ms_factory_exit(args->video->ms.factory);
}
// ANDROID JNI WRAPPER
......
......@@ -160,8 +160,7 @@ end:
/*free the RTP profile and payload type inside*/
if (profile) rtp_profile_destroy(profile);
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
return err;
}
......@@ -37,8 +37,7 @@ int main(int argc, char *argv[]){
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
printf("result: %i \n",ms_discover_mtu(argv[1]));
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
return 0;
}
......@@ -52,7 +52,6 @@ int main(int argc, char *argv[]){
ms_sleep(10);
ring_stop(r);
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
return 0;
}
......@@ -114,8 +114,7 @@ int main(int argc, char *argv[]){
ms_filter_destroy(det);
ms_filter_destroy(rec);
ms_factory_uninit_voip(factory);
ms_factory_destroy(factory);
factory = ms_factory_exit(factory);
//ms_base_exit();
return 0;
}
......
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