[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Linphone-developers] Patch to support different alsa configurations
From: |
ingo . krabbe |
Subject: |
Re: [Linphone-developers] Patch to support different alsa configurations |
Date: |
Wed, 2 Apr 2014 11:39:07 +0200 |
[sorry, the patch did not came with the first mail, hopefully now]
>
> Hey Linphoners,
>
> today I tried to setup my laptop with linphone. I use two soundcards in my
> laptop, one for radio/music listening is a HighDefinition USB Card plugged
> into a hifi amplifier and should be used for ring tones only, as I want to
> notice when a call comes in, the other one I want to use for playback through
> headphones.
>
> Once you got familiar with alsa you should switch off any sound daemons,
> imho, as its much harder to customize sound daemon configuration, but
> configuring alsa. So did I, years ago actually.
>
> Of course I don't want linphone to block control of my sound devices as other
> software I might want to run as my favourite game, a browser or a music
> player might want to play audio through the cards too. So I cannot use the
> device detection algorithm, that finds cards only, but I need to specify two
> custom alsa devices, that are configured as dmix slaves.
>
> But the alsadev configuration string is interpreted as one string and
> repeated configuration strings aren't handled. So with the current source
> code I can only setup one custom alsa device.
>
> The patch attached modifies the configuration algorithm to read alsadev as a
> , separated list of custom alsa devices.
>
> If you extend the delimiters to several characters (",;:" for example) you
> should write some extra code to strip delimiters from the string. I can do
> that if you request that, but the code works for me, so I'll leave it as it
> is for now.
>
> cheers ingo
>
>
>
> _______________________________________________
> Linphone-developers mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/linphone-developers
commit 6d07a522ce7a79c30fe005f1ede302033f114470
Author: Ingo Krabbe <address@hidden>
Date: Wed Apr 2 11:32:17 2014 +0200
support multiple alsa devices
diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index fa94234..cb1d0c2 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -536,8 +536,25 @@ static void sound_config_read(LinphoneCore *lc)
/*alsadev let the user use custom alsa device within linphone*/
devid=lp_config_get_string(lc->config,"sound","alsadev",NULL);
if (devid){
- MSSndCard *card=ms_alsa_card_new_custom(devid,devid);
- ms_snd_card_manager_add_card(ms_snd_card_manager_get(),card);
+ MSSndCard* card;
+ const char* delim=",";
+ size_t l=strlen(devid);
+ char* d=malloc(l+1);
+ char* i;
+ memcpy(d,devid,l+1);
+ for (l=0,i=strpbrk(d+l,delim);i;i=strpbrk(d+l,delim)){
+ size_t m=i-d;
+ char s=*i;
+ *i='\0';
+ card=ms_alsa_card_new_custom(d+l,d+l);
+
ms_snd_card_manager_add_card(ms_snd_card_manager_get(),card);
+ *i=s;
+ l=m+1;
+ }
+ if(d[l]!='\0') {
+ card=ms_alsa_card_new_custom(d+l,d+l);
+
ms_snd_card_manager_add_card(ms_snd_card_manager_get(),card);
+ }
}
tmp=lp_config_get_int(lc->config,"sound","alsa_forced_rate",-1);
if (tmp>0) ms_alsa_card_set_forced_sample_rate(tmp);