Commit 7b3f7cb2 authored by Simon Morlat's avatar Simon Morlat
Browse files

improve mssndcard api

parent 2a6a3675
......@@ -194,6 +194,26 @@ MS2_PUBLIC void ms_snd_card_manager_destroy(MSSndCardManager* sndcardmanager);
*/
MS2_PUBLIC MSSndCard * ms_snd_card_manager_get_card(MSSndCardManager *m, const char *id);
/**
* Retreive a playback capable sound card object based on its name.
*
* @param m A sound card manager containing sound cards.
* @param id A name for card to search.
*
* Returns: MSSndCard if successfull, NULL otherwise.
*/
MS2_PUBLIC MSSndCard * ms_snd_card_manager_get_playback_card(MSSndCardManager *m, const char *id);
/**
* Retreive a capture capable sound card object based on its name.
*
* @param m A sound card manager containing sound cards.
* @param id A name for card to search.
*
* Returns: MSSndCard if successfull, NULL otherwise.
*/
MS2_PUBLIC MSSndCard * ms_snd_card_manager_get_capture_card(MSSndCardManager *m, const char *id);
/**
* Retreive the default sound card object.
*
......
......@@ -192,7 +192,7 @@ static MSSndCard *ca_card_new(const char *name, const char * uidname, AudioDevic
int err;
d->uidname = ms_strdup(uidname);
card->name = ms_strdup(name);
card->name = ms_strdup_printf("%s (%s)", name, uidname); /*include uid so that names are uniques*/
card->capabilities = cap;
slen = sizeof(format);
......
......@@ -63,38 +63,44 @@ MSSndCard * ms_snd_card_manager_get_card(MSSndCardManager *m, const char *id){
return NULL;
}
MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m){
/*return the first card that has the capture+playback capability */
static MSSndCard *get_card_with_cap(MSSndCardManager *m, const char *id, unsigned int caps){
MSList *elem;
for (elem=m->cards;elem!=NULL;elem=elem->next){
MSSndCard *card=(MSSndCard*)elem->data;
if ((card->capabilities & MS_SND_CARD_CAP_CAPTURE )
&& (card->capabilities & MS_SND_CARD_CAP_PLAYBACK))
return card;
if ((id== NULL || strcmp(ms_snd_card_get_string_id(card),id)==0) && (card->capabilities & caps) == caps) return card;
}
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)
return card;
}
MSSndCard * ms_snd_card_manager_get_playback_card(MSSndCardManager *m, const char *id){
MSSndCard *ret;
ret = get_card_with_cap(m, id, MS_SND_CARD_CAP_PLAYBACK);
if (ret) return ret;
if (id != NULL) ms_warning("No playback card with id %s",id);
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_PLAYBACK)
return card;
}
MSSndCard * ms_snd_card_manager_get_capture_card(MSSndCardManager *m, const char *id){
MSSndCard *ret;
ret = get_card_with_cap(m, id, MS_SND_CARD_CAP_CAPTURE);
if (ret) return ret;
if (id != NULL) ms_warning("No capture card with id %s",id);
return NULL;
}
MSSndCard * ms_snd_card_manager_get_default_card(MSSndCardManager *m){
/*return the first card that has the capture+playback capability */
return get_card_with_cap(m, NULL, MS_SND_CARD_CAP_PLAYBACK | MS_SND_CARD_CAP_CAPTURE);
}
MSSndCard * ms_snd_card_manager_get_default_capture_card(MSSndCardManager *m){
return get_card_with_cap(m, NULL, MS_SND_CARD_CAP_CAPTURE);
}
MSSndCard * ms_snd_card_manager_get_default_playback_card(MSSndCardManager *m){
return get_card_with_cap(m, NULL, MS_SND_CARD_CAP_PLAYBACK);
}
const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m){
return m->cards;
}
......
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