From bc8e37b39bd83f4418a74f3407da3ddd231dca89 Mon Sep 17 00:00:00 2001 From: aymeric <aymeric@3f6dc0c8-ddfe-455d-9043-3cd528dc4637> Date: Thu, 20 Aug 2009 14:30:54 +0000 Subject: [PATCH] add unload method when complete audio filter is disabled/unregistred. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@589 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- .../include/mediastreamer2/mssndcard.h | 2 ++ linphone/mediastreamer2/src/mssndcard.c | 6 ++++++ linphone/mediastreamer2/src/winsnd2.c | 18 +++++++++--------- linphone/mediastreamer2/src/winsndds.cpp | 18 +++++++++--------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/linphone/mediastreamer2/include/mediastreamer2/mssndcard.h b/linphone/mediastreamer2/include/mediastreamer2/mssndcard.h index 63be4c5730..ea197482fb 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/mssndcard.h +++ b/linphone/mediastreamer2/include/mediastreamer2/mssndcard.h @@ -96,6 +96,7 @@ typedef int (*MSSndCardGetControlFunc)(struct _MSSndCard *obj, MSSndCardControlE typedef struct _MSFilter * (*MSSndCardCreateReaderFunc)(struct _MSSndCard *obj); typedef struct _MSFilter * (*MSSndCardCreateWriterFunc)(struct _MSSndCard *obj); typedef struct _MSSndCard * (*MSSndCardDuplicateFunc)(struct _MSSndCard *obj); +typedef void (*MSSndCardUnloadFunc)(MSSndCardManager *obj); struct _MSSndCardDesc{ const char *driver_type; @@ -110,6 +111,7 @@ struct _MSSndCardDesc{ MSSndCardCreateWriterFunc create_writer; MSSndCardUninitFunc uninit; MSSndCardDuplicateFunc duplicate; + MSSndCardUnloadFunc unload; }; diff --git a/linphone/mediastreamer2/src/mssndcard.c b/linphone/mediastreamer2/src/mssndcard.c index faa6b55455..593e3ec8fe 100644 --- a/linphone/mediastreamer2/src/mssndcard.c +++ b/linphone/mediastreamer2/src/mssndcard.c @@ -33,6 +33,12 @@ static MSSndCardManager * create_manager(){ void ms_snd_card_manager_destroy(void){ if (scm!=NULL){ + MSList *elem; + for(elem=scm->descs;elem!=NULL;elem=elem->next){ + MSSndCardDesc *desc = (MSSndCardDesc*)elem->data; + if (desc->unload!=NULL) + desc->unload(scm); + } ms_list_for_each(scm->cards,(void (*)(void*))ms_snd_card_destroy); ms_list_free(scm->cards); ms_list_free(scm->descs); diff --git a/linphone/mediastreamer2/src/winsnd2.c b/linphone/mediastreamer2/src/winsnd2.c index 5f77c9444f..56a0e3cd24 100755 --- a/linphone/mediastreamer2/src/winsnd2.c +++ b/linphone/mediastreamer2/src/winsnd2.c @@ -669,6 +669,7 @@ static void winsndcard_uninit(MSSndCard *card){ static void winsndcard_detect(MSSndCardManager *m); static MSSndCard *winsndcard_dup(MSSndCard *obj); +static void winsndcard_unload(MSSndCardManager *m); MSSndCardDesc winsnd_card_desc={ "MME", @@ -682,7 +683,8 @@ MSSndCardDesc winsnd_card_desc={ ms_winsnd_read_new, ms_winsnd_write_new, winsndcard_uninit, - winsndcard_dup + winsndcard_dup, + winsndcard_unload }; static MSSndCard *winsndcard_dup(MSSndCard *obj){ @@ -796,7 +798,7 @@ static void mark_as_removed(MSSndCardManager *m){ } } -static ms_thread_t poller_thread; +static ms_thread_t poller_thread=NULL; static bool_t poller_running=TRUE; static void * new_device_polling_thread(void *ignore){ @@ -821,15 +823,13 @@ static void stop_poller(){ poller_thread=NULL; } +static void winsndcard_unload(MSSndCardManager *m){ + stop_poller(); +} + static void winsndcard_detect(MSSndCardManager *m){ - static int doitonce = 0; _winsndcard_detect(m); - if (doitonce==0) - { - doitonce++; - ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL); - atexit(&stop_poller); - } + ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL); } typedef struct WinSnd{ diff --git a/linphone/mediastreamer2/src/winsndds.cpp b/linphone/mediastreamer2/src/winsndds.cpp index 08ea04122a..d04b76bfa5 100644 --- a/linphone/mediastreamer2/src/winsndds.cpp +++ b/linphone/mediastreamer2/src/winsndds.cpp @@ -766,6 +766,7 @@ static void winsnddscard_uninit(MSSndCard *card){ static void winsnddscard_detect(MSSndCardManager *m); static MSSndCard *winsnddscard_dup(MSSndCard *obj); +static void winsnddscard_unload(MSSndCardManager *m); MSSndCardDesc winsndds_card_desc={ "DirectSound", @@ -779,7 +780,8 @@ MSSndCardDesc winsndds_card_desc={ ms_winsndds_read_new, ms_winsndds_write_new, winsnddscard_uninit, - winsnddscard_dup + winsnddscard_dup, + winsnddscard_unload }; static MSSndCard *winsnddscard_dup(MSSndCard *obj){ @@ -991,7 +993,7 @@ static void mark_as_removed(MSSndCardManager *m){ } } -static ms_thread_t poller_thread; +static ms_thread_t poller_thread=NULL; static bool_t poller_running=TRUE; static void * new_device_polling_thread(void *ignore){ @@ -1016,15 +1018,13 @@ static void stop_poller(){ poller_thread=NULL; } +static void winsnddscard_unload(MSSndCardManager *m){ + stop_poller(); +} + static void winsnddscard_detect(MSSndCardManager *m){ - static int doitonce = 0; _winsnddscard_detect(m); - if (doitonce==0) - { - doitonce++; - ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL); - atexit(&stop_poller); - } + ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL); } typedef struct WinSndDs{ -- GitLab