Commit bc8e37b3 authored by aymeric's avatar aymeric

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
parent c6964906
...@@ -96,6 +96,7 @@ typedef int (*MSSndCardGetControlFunc)(struct _MSSndCard *obj, MSSndCardControlE ...@@ -96,6 +96,7 @@ typedef int (*MSSndCardGetControlFunc)(struct _MSSndCard *obj, MSSndCardControlE
typedef struct _MSFilter * (*MSSndCardCreateReaderFunc)(struct _MSSndCard *obj); typedef struct _MSFilter * (*MSSndCardCreateReaderFunc)(struct _MSSndCard *obj);
typedef struct _MSFilter * (*MSSndCardCreateWriterFunc)(struct _MSSndCard *obj); typedef struct _MSFilter * (*MSSndCardCreateWriterFunc)(struct _MSSndCard *obj);
typedef struct _MSSndCard * (*MSSndCardDuplicateFunc)(struct _MSSndCard *obj); typedef struct _MSSndCard * (*MSSndCardDuplicateFunc)(struct _MSSndCard *obj);
typedef void (*MSSndCardUnloadFunc)(MSSndCardManager *obj);
struct _MSSndCardDesc{ struct _MSSndCardDesc{
const char *driver_type; const char *driver_type;
...@@ -110,6 +111,7 @@ struct _MSSndCardDesc{ ...@@ -110,6 +111,7 @@ struct _MSSndCardDesc{
MSSndCardCreateWriterFunc create_writer; MSSndCardCreateWriterFunc create_writer;
MSSndCardUninitFunc uninit; MSSndCardUninitFunc uninit;
MSSndCardDuplicateFunc duplicate; MSSndCardDuplicateFunc duplicate;
MSSndCardUnloadFunc unload;
}; };
......
...@@ -33,6 +33,12 @@ static MSSndCardManager * create_manager(){ ...@@ -33,6 +33,12 @@ static MSSndCardManager * create_manager(){
void ms_snd_card_manager_destroy(void){ void ms_snd_card_manager_destroy(void){
if (scm!=NULL){ 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_for_each(scm->cards,(void (*)(void*))ms_snd_card_destroy);
ms_list_free(scm->cards); ms_list_free(scm->cards);
ms_list_free(scm->descs); ms_list_free(scm->descs);
......
...@@ -669,6 +669,7 @@ static void winsndcard_uninit(MSSndCard *card){ ...@@ -669,6 +669,7 @@ static void winsndcard_uninit(MSSndCard *card){
static void winsndcard_detect(MSSndCardManager *m); static void winsndcard_detect(MSSndCardManager *m);
static MSSndCard *winsndcard_dup(MSSndCard *obj); static MSSndCard *winsndcard_dup(MSSndCard *obj);
static void winsndcard_unload(MSSndCardManager *m);
MSSndCardDesc winsnd_card_desc={ MSSndCardDesc winsnd_card_desc={
"MME", "MME",
...@@ -682,7 +683,8 @@ MSSndCardDesc winsnd_card_desc={ ...@@ -682,7 +683,8 @@ MSSndCardDesc winsnd_card_desc={
ms_winsnd_read_new, ms_winsnd_read_new,
ms_winsnd_write_new, ms_winsnd_write_new,
winsndcard_uninit, winsndcard_uninit,
winsndcard_dup winsndcard_dup,
winsndcard_unload
}; };
static MSSndCard *winsndcard_dup(MSSndCard *obj){ static MSSndCard *winsndcard_dup(MSSndCard *obj){
...@@ -796,7 +798,7 @@ static void mark_as_removed(MSSndCardManager *m){ ...@@ -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 bool_t poller_running=TRUE;
static void * new_device_polling_thread(void *ignore){ static void * new_device_polling_thread(void *ignore){
...@@ -821,15 +823,13 @@ static void stop_poller(){ ...@@ -821,15 +823,13 @@ static void stop_poller(){
poller_thread=NULL; poller_thread=NULL;
} }
static void winsndcard_unload(MSSndCardManager *m){
stop_poller();
}
static void winsndcard_detect(MSSndCardManager *m){ static void winsndcard_detect(MSSndCardManager *m){
static int doitonce = 0;
_winsndcard_detect(m); _winsndcard_detect(m);
if (doitonce==0) ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL);
{
doitonce++;
ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL);
atexit(&stop_poller);
}
} }
typedef struct WinSnd{ typedef struct WinSnd{
......
...@@ -766,6 +766,7 @@ static void winsnddscard_uninit(MSSndCard *card){ ...@@ -766,6 +766,7 @@ static void winsnddscard_uninit(MSSndCard *card){
static void winsnddscard_detect(MSSndCardManager *m); static void winsnddscard_detect(MSSndCardManager *m);
static MSSndCard *winsnddscard_dup(MSSndCard *obj); static MSSndCard *winsnddscard_dup(MSSndCard *obj);
static void winsnddscard_unload(MSSndCardManager *m);
MSSndCardDesc winsndds_card_desc={ MSSndCardDesc winsndds_card_desc={
"DirectSound", "DirectSound",
...@@ -779,7 +780,8 @@ MSSndCardDesc winsndds_card_desc={ ...@@ -779,7 +780,8 @@ MSSndCardDesc winsndds_card_desc={
ms_winsndds_read_new, ms_winsndds_read_new,
ms_winsndds_write_new, ms_winsndds_write_new,
winsnddscard_uninit, winsnddscard_uninit,
winsnddscard_dup winsnddscard_dup,
winsnddscard_unload
}; };
static MSSndCard *winsnddscard_dup(MSSndCard *obj){ static MSSndCard *winsnddscard_dup(MSSndCard *obj){
...@@ -991,7 +993,7 @@ static void mark_as_removed(MSSndCardManager *m){ ...@@ -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 bool_t poller_running=TRUE;
static void * new_device_polling_thread(void *ignore){ static void * new_device_polling_thread(void *ignore){
...@@ -1016,15 +1018,13 @@ static void stop_poller(){ ...@@ -1016,15 +1018,13 @@ static void stop_poller(){
poller_thread=NULL; poller_thread=NULL;
} }
static void winsnddscard_unload(MSSndCardManager *m){
stop_poller();
}
static void winsnddscard_detect(MSSndCardManager *m){ static void winsnddscard_detect(MSSndCardManager *m){
static int doitonce = 0;
_winsnddscard_detect(m); _winsnddscard_detect(m);
if (doitonce==0) ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL);
{
doitonce++;
ms_thread_create(&poller_thread,NULL,new_device_polling_thread,NULL);
atexit(&stop_poller);
}
} }
typedef struct WinSndDs{ typedef struct WinSndDs{
......
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