Commit 6d9371ec authored by aymeric's avatar aymeric

add API to get default capture & playback sound cards.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@256 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 067a957c
...@@ -25,6 +25,8 @@ EXPORTS ...@@ -25,6 +25,8 @@ EXPORTS
ms_snd_card_get_string_id ms_snd_card_get_string_id
ms_snd_card_manager_get ms_snd_card_manager_get
ms_snd_card_manager_get_default_card ms_snd_card_manager_get_default_card
ms_snd_card_manager_get_default_capture_card
ms_snd_card_manager_get_default_playback_card
ms_snd_card_manager_get_card ms_snd_card_manager_get_card
ms_snd_card_manager_get_list ms_snd_card_manager_get_list
ms_snd_card_dup ms_snd_card_dup
......
...@@ -161,6 +161,24 @@ MSSndCard * ms_snd_card_manager_get_card(MSSndCardManager *m, const char *id); ...@@ -161,6 +161,24 @@ MSSndCard * ms_snd_card_manager_get_card(MSSndCardManager *m, const char *id);
*/ */
MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m); MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m);
/**
* Retreive the default capture sound card object.
*
* @param m A sound card manager containing sound cards.
*
* Returns: MSSndCard if successfull, NULL otherwise.
*/
MSSndCard * ms_snd_card_manager_get_default_capture_card(MSSndCardManager *m);
/**
* Retreive the default playback sound card object.
*
* @param m A sound card manager containing sound cards.
*
* Returns: MSSndCard if successfull, NULL otherwise.
*/
MSSndCard * ms_snd_card_manager_get_default_playback_card(MSSndCardManager *m);
/** /**
* Retreive the list of sound card objects. * Retreive the list of sound card objects.
* *
......
...@@ -66,6 +66,28 @@ MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m){ ...@@ -66,6 +66,28 @@ MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m){
return NULL; return NULL;
} }
MSSndCard * ms_snd_card_manager_get_default_capture_card(MSSndCardManager *m){
MSList *elem;
for (elem=m->cards;elem!=NULL;elem=elem->next){
MSSndCard *card=(MSSndCard*)elem->data;
if (card->capabilities==(MS_SND_CARD_CAP_CAPTURE|MS_SND_CARD_CAP_PLAYBACK)
||card->capabilities==MS_SND_CARD_CAP_CAPTURE)
return card;
}
return NULL;
}
MSSndCard * ms_snd_card_manager_get_default_playback_card(MSSndCardManager *m){
MSList *elem;
for (elem=m->cards;elem!=NULL;elem=elem->next){
MSSndCard *card=(MSSndCard*)elem->data;
if (card->capabilities==(MS_SND_CARD_CAP_CAPTURE|MS_SND_CARD_CAP_PLAYBACK)
||card->capabilities==MS_SND_CARD_CAP_PLAYBACK)
return card;
}
return NULL;
}
const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m){ const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m){
return m->cards; return m->cards;
} }
......
...@@ -32,9 +32,11 @@ static void stop(int signum){ ...@@ -32,9 +32,11 @@ static void stop(int signum){
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
MSFilter *f1,*f2; MSFilter *f1,*f2;
MSSndCard *card; MSSndCard *card_capture;
MSSndCard *card_playback;
MSTicker *ticker; MSTicker *ticker;
char *card_id=NULL; char *card_id=NULL;
int rate = 16000;
ortp_init(); ortp_init();
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ms_init(); ms_init();
...@@ -46,20 +48,32 @@ int main(int argc, char *argv[]){ ...@@ -46,20 +48,32 @@ int main(int argc, char *argv[]){
if (card_id!=NULL) if (card_id!=NULL)
{ {
card=ms_snd_card_manager_get_card(ms_snd_card_manager_get(),card_id); card_capture = ms_snd_card_manager_get_card(ms_snd_card_manager_get(),card_id);
card_playback = ms_snd_card_manager_get_card(ms_snd_card_manager_get(),card_id);
#ifdef __linux #ifdef __linux
if (card==NULL) if (card_playback==NULL)
card = ms_alsa_card_new_custom(card_id, card_id); card_playback = ms_alsa_card_new_custom(card_id, card_id);
if (card_capture==NULL)
card_capture = ms_alsa_card_new_custom(card_id, card_id);
#endif #endif
} }
else card=ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()); else
{
if (card==NULL){ card_capture = ms_snd_card_manager_get_default_capture_card(ms_snd_card_manager_get());
card_playback = ms_snd_card_manager_get_default_playback_card(ms_snd_card_manager_get());
}
if (card_playback==NULL || card_capture==NULL){
ms_error("No card."); ms_error("No card.");
return -1; return -1;
} }
f1=ms_snd_card_create_reader(card); f1=ms_snd_card_create_reader(card_capture);
f2=ms_snd_card_create_writer(card); f2=ms_snd_card_create_writer(card_playback);
ms_filter_call_method (f1, MS_FILTER_SET_SAMPLE_RATE,
&rate);
ms_filter_call_method (f2, MS_FILTER_SET_SAMPLE_RATE,
&rate);
ticker=ms_ticker_new(); ticker=ms_ticker_new();
ms_filter_link(f1,0,f2,0); ms_filter_link(f1,0,f2,0);
ms_ticker_attach(ticker,f1); ms_ticker_attach(ticker,f1);
......
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