Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
Ludovico Cavedon wrote: > Gianluca Sforna wrote: >> >> 6. If you have an application that uses ALSA, please make sure that it >>doesn't hardcode ALSA driver names (i.e. something like "hw:0"), it >>should use "default" instead, which is now being redirected to >>"pulse", our plugin for libasound. Hardcoding ALSA device names >>(besides "default") is a bug in your application anyway, so here >>you have yet another reason to fix that! >> > > > Yes, sounds more than reasonable. > Using "hw" or "plughw" we bypass the user configuration in .asoundrc, > and this is not nice. Moreover it should be not a task of the > application to select the audio configuration, which can be quite complex. > > See this message and the other s from the thread: > http://lalists.stanford.edu/lad/2002/05/0111.html > > Applications should allow to choose between *virtual* PCM devices (like > "default" is). However, using the ALSA API which is mostly used (1.0.13) > it is not possible (as far as I could understand: I am not an expert, I > spent some time gathering info); it is possible only starting from API > 1.0.14. > > In the meanwhile, I think the best choice would be do as mstute > suggested: use the "default" PCM device by default (this would not break > compatibility with PulseAudio, etc), but allow the user to choose a > specific audio card (i.e. if they want to use a USB headset). Yes, I think this should be the way to go. It would be nice if we have support for both the old API and the new API. > > Regards, > Ludovico > > -- andreas > > > > ___ > Wengophone-devel mailing list > Wengophone-devel@lists.openwengo.com > http://dev.openwengo.com/mailman/listinfo/wengophone-devel -- http://www.cynapses.org/ - cybernetic synapses signature.asc Description: OpenPGP digital signature ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
Gianluca Sforna wrote: > > 6. If you have an application that uses ALSA, please make sure that it >doesn't hardcode ALSA driver names (i.e. something like "hw:0"), it >should use "default" instead, which is now being redirected to >"pulse", our plugin for libasound. Hardcoding ALSA device names >(besides "default") is a bug in your application anyway, so here >you have yet another reason to fix that! > Yes, sounds more than reasonable. Using "hw" or "plughw" we bypass the user configuration in .asoundrc, and this is not nice. Moreover it should be not a task of the application to select the audio configuration, which can be quite complex. See this message and the other s from the thread: http://lalists.stanford.edu/lad/2002/05/0111.html Applications should allow to choose between *virtual* PCM devices (like "default" is). However, using the ALSA API which is mostly used (1.0.13) it is not possible (as far as I could understand: I am not an expert, I spent some time gathering info); it is possible only starting from API 1.0.14. In the meanwhile, I think the best choice would be do as mstute suggested: use the "default" PCM device by default (this would not break compatibility with PulseAudio, etc), but allow the user to choose a specific audio card (i.e. if they want to use a USB headset). Regards, Ludovico signature.asc Description: OpenPGP digital signature ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
On 8/26/07, Ludovico Cavedon <[EMAIL PROTECTED]> wrote: > -I could not manage to specify the device number on the card, but just > the card number (like just "hw:0" instead of "hw:0,0"). This mean that > the default device is used on that card. However I think it is not too > bad, as the user should be asked to choose just the sound card. More > fine tuning should be done using alsa configuration (asoundrc) I don't know the details (so you may want to write to someone more knowledgeable than me) but the post about Fedora and PulseAudio I sent earlier states: 6. If you have an application that uses ALSA, please make sure that it doesn't hardcode ALSA driver names (i.e. something like "hw:0"), it should use "default" instead, which is now being redirected to "pulse", our plugin for libasound. Hardcoding ALSA device names (besides "default") is a bug in your application anyway, so here you have yet another reason to fix that! I would like to be more helpful than this but I really lack the required skillz... Cheers Gianluca ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
Hi again! Ludovico Cavedon wrote: > mstute wrote: >> On Friday 27 July 2007 00:42, Ludovico Cavedon wrote: >>> I noticed that opening plughw devices instead of hw is working for me >>> (no >>> mono/stereo issue). I tried both the internal soundcard and a USB >>> headset. >>> In this case, it is ALSA taking care of the necessary conversions. >> >> For me it does solve the mono/stereo issue but unfortunately it breaks >> audio mixing i.e no more dtfm feedback during a call... So I've added >> to your patch the default ALSA device that fit most of the use cases >> (see the attached patch) What do you think? > > Mhm, I think it is a good compromise. > Unfortunately I can not test it now, and I won't be reading the mail for > the next 20 days... I tried to understand why mixing gets broken: since alsa version 1.0.9, the "default" pcm is set up to use the "dmix" plugin to enable audio mixing for audio cards which do not support it in hardware. When using "plughw" we do get "dmix" working. We could enumerate the sound cards and use "default:0", "default:1", "default:2", etc. This would enable audio mixing via dmix if necessary, but it would be wrong to associate each "default:X" with a precise hardware devices, because mapping of "default" can be overridden by the .asoundrc file. Rather, I would use the "plug:dmix:X" (X=card number) device for output, instead of "plughw". See the patch attached (edit of mstute's patch) It has two little drawbacks: -it enables dmix even if not necessary -I could not manage to specify the device number on the card, but just the card number (like just "hw:0" instead of "hw:0,0"). This mean that the default device is used on that card. However I think it is not too bad, as the user should be asked to choose just the sound card. More fine tuning should be done using alsa configuration (asoundrc) The patch is working, but still needs a modification in one of these three directions: -manage to specify the device with dmix -remove duplicate output entries if a card has more than one output device (with the current patch the same output card would apply more than once) -remove device selection for both input and output (for sake of consistency) Actually, the best thing would be to use the new ALSA API of version 1.0.14, with would be allow to enumerate virtual pcm devices and gather information like the following: - $ aplay -L default:CARD=rev50 VIA 82C686A/B rev50, VIA 82C686A/B rev50 Default Audio Device front:CARD=rev50,DEV=0 VIA 82C686A/B rev50, VIA 82C686A/B rev50 Front speakers iec958:CARD=rev50,DEV=0 VIA 82C686A/B rev50, VIA 82C686A/B rev50 IEC958 (S/PDIF) Digital Audio Output null Discard all samples (playback) or generate zero samples (capture) default:CARD=Headset BT Headset, BT SCO PCM Default Audio Device - However using the new API would break compatibility with etch and feisty, and I think it should be avoided. What do you think? Regards, Ludovico Index: wengophone-2.1.1.dfsg0/libs/sound/src/linux/AudioDeviceManager.cpp === --- wengophone-2.1.1.dfsg0.orig/libs/sound/src/linux/AudioDeviceManager.cpp 2007-04-20 14:06:36.0 + +++ wengophone-2.1.1.dfsg0/libs/sound/src/linux/AudioDeviceManager.cpp 2007-08-25 20:13:42.0 + @@ -28,39 +28,19 @@ std::list AudioDeviceManager::getInputDeviceList() { RecursiveMutex::ScopedLock scopedLock(_mutex); - //HACK: always return the default one + plughw - std::list deviceList; - deviceList.push_back(getDefaultInputDevice()); - - StringList data; - data += String("ALSA: plughw"); - data += String("plughw"); - data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveIn); - deviceList.push_back(AudioDevice(data)); + std::list deviceList = find_alsa_devices(1); + deviceList.push_front(getDefaultInputDevice()); return deviceList; - - - //return find_alsa_devices(1); } std::list AudioDeviceManager::getOutputDeviceList() { RecursiveMutex::ScopedLock scopedLock(_mutex); - //HACK: always return the default one + plughw - std::list deviceList; - deviceList.push_back(getDefaultOutputDevice()); - - StringList data; - data += String("ALSA: plughw"); - data += String("plughw"); - data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveOut); - deviceList.push_back(AudioDevice(data)); + std::list deviceList = find_alsa_devices(0); + deviceList.push_front(getDefaultOutputDevice()); return deviceList; - - - //return find_alsa_devices(0); } AudioDevice AudioDeviceManager::getDefaultOutputDevice() { @@ -131,7 +111,7 @@ // open the sound card - if( snd_ctl_open(&snd_ctl, alsa_card_name, 0 ) < 0 ) + if ( snd_ctl_open(&snd_ctl, alsa_card_name, 0 ) < 0 ) { LOG_WARN("unable to open card: " + String(alsa_card_name)); break; @@ -165,8 +145,16 @@ int has_playback = 0; // compute internal device name - snprintf(alsa_device_name, sizeof
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
mstute wrote: On Friday 27 July 2007 00:42, Ludovico Cavedon wrote: I noticed that opening plughw devices instead of hw is working for me (no mono/stereo issue). I tried both the internal soundcard and a USB headset. In this case, it is ALSA taking care of the necessary conversions. For me it does solve the mono/stereo issue but unfortunately it breaks audio mixing i.e no more dtfm feedback during a call... So I've added to your patch the default ALSA device that fit most of the use cases (see the attached patch) What do you think? Mhm, I think it is a good compromise. Unfortunately I can not test it now, and I won't be reading the mail for the next 20 days... Regards, Ludovico ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
On Friday 27 July 2007 00:42, Ludovico Cavedon wrote: > I noticed that opening plughw devices instead of hw is working for me (no > mono/stereo issue). I tried both the internal soundcard and a USB headset. > In this case, it is ALSA taking care of the necessary conversions. > > I attached a patch to ticket #1764 > (http://dev.openwengo.com/trac/openwengo/trac.cgi/ticket/1746). > > Is it the right way to do it? Could someone try it, please? > > Regards, > Ludovico Cavedon > Hi Ludovico, For me it does solve the mono/stereo issue but unfortunately it breaks audio mixing i.e no more dtfm feedback during a call... So I've added to your patch the default ALSA device that fit most of the use cases (see the attached patch) What do you think? Looking at the code I've also noticed that the LinuxSound and alsa_sndfile* did not use the audio configuration so I've committed a fix (see rev 12081) Best regards, -- Mathieu Stute GPG: http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0x3EE62B4D Index: libs/sound/src/linux/AudioDeviceManager.cpp === --- libs/sound/src/linux/AudioDeviceManager.cpp (revision 12047) +++ libs/sound/src/linux/AudioDeviceManager.cpp (working copy) @@ -28,39 +28,19 @@ std::list AudioDeviceManager::getInputDeviceList() { RecursiveMutex::ScopedLock scopedLock(_mutex); - //HACK: always return the default one + plughw - std::list deviceList; - deviceList.push_back(getDefaultInputDevice()); + std::list deviceList = find_alsa_devices(1); + deviceList.push_front(getDefaultInputDevice()); - StringList data; - data += String("ALSA: plughw"); - data += String("plughw"); - data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveIn); - deviceList.push_back(AudioDevice(data)); - return deviceList; - - - //return find_alsa_devices(1); } std::list AudioDeviceManager::getOutputDeviceList() { RecursiveMutex::ScopedLock scopedLock(_mutex); - //HACK: always return the default one + plughw - std::list deviceList; - deviceList.push_back(getDefaultOutputDevice()); + std::list deviceList = find_alsa_devices(0); + deviceList.push_front(getDefaultOutputDevice()); - StringList data; - data += String("ALSA: plughw"); - data += String("plughw"); - data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveOut); - deviceList.push_back(AudioDevice(data)); - return deviceList; - - - //return find_alsa_devices(0); } AudioDevice AudioDeviceManager::getDefaultOutputDevice() { @@ -131,7 +111,7 @@ // open the sound card - if( snd_ctl_open(&snd_ctl, alsa_card_name, 0 ) < 0 ) + if ( snd_ctl_open(&snd_ctl, alsa_card_name, 0 ) < 0 ) { LOG_WARN("unable to open card: " + String(alsa_card_name)); break; @@ -165,8 +145,8 @@ int has_playback = 0; // compute internal device name - snprintf(alsa_device_name, sizeof(alsa_device_name), "%s:%d,%d", "hw", - card_index, device_index); + snprintf(alsa_device_name, sizeof(alsa_device_name), "%s:%d,%d", +"plughw", card_index, device_index); LOG_DEBUG("alsa_device_name: " + String(alsa_device_name)); pgpy16PesTRdl.pgp Description: PGP signature ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
Quoting Mathieu Stute <[EMAIL PROTECTED]>: > Unfortunately there are some bad news... PhApi does not handle devices that > are opened in stereo mode and from what I saw most of devices cannot be > opened > in mono mode. That's why the only device listed is the default one: you will > see "ALSA: default" in the audio configuration panel of the WengoPhone. > Another bug: when you resume a call that has been held there's no sound. I > will work the next days to get rid on these bugs. I noticed that opening plughw devices instead of hw is working for me (no mono/stereo issue). I tried both the internal soundcard and a USB headset. In this case, it is ALSA taking care of the necessary conversions. I attached a patch to ticket #1764 (http://dev.openwengo.com/trac/openwengo/trac.cgi/ticket/1746). Is it the right way to do it? Could someone try it, please? Regards, Ludovico Cavedon ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
Re: [Wengophone-devel] ALSA support in WengoPhone and PhApi
That is very, very good news. What stopped us adopting openwengo in our small company is the lack of support for our audio cards, but moving to ALSA support should solve the probelm. Thanks Mathieu! On Friday 20 April 2007 10:06:51 Mathieu Stute wrote: > Hi Linux guys, > > Since revision 10817 WengoPhone and PhApi can be compiled without portaudio > support :-) In this case a native ALSA support is used. You have to change > the option OWSOUND_PORTAUDIO_SUPPORT to activate it. (set it to OFF) > > To achieve this work I had to debug and improve the ALSA backend of PhApi > (phmedia-alsa.c) and I had to write a new implementation for owsound > (libs/sound/src/linux). For now this implementation has the responsability > to enumerate ALSA devices and plugins, to handle ALSA mixer and to play > sound files with libsndfile. This implementation will soon handle OSS too, > that's why I have named it "linux". > > Unfortunately there are some bad news... PhApi does not handle devices that > are opened in stereo mode and from what I saw most of devices cannot be > opened in mono mode. That's why the only device listed is the default one: > you will see "ALSA: default" in the audio configuration panel of the > WengoPhone. Another bug: when you resume a call that has been held there's > no sound. I will work the next days to get rid on these bugs. > > In order to integrate this in (one of) the next release(s) of WengoPhone I > would be very happy if some of you could test this new stuff. Please feel > free to feed our trac on this subject: the appropriate milestone for the > tickets is the "WengoPhone 2.1". And finally, for those who do not compile > the WengoPhone, I have added a new Linux builder on our buildbot with > portaudio support disabled. The related binaries are located in > http://wengofiles.wengo.fr/nightlybuilds/binary/NG/GNULinux/2.1 and are > named WengoPhone-2.1-minsizerel-alsa-xx.tar.bz2 > > note: tested with libasound2 1.0.11 and 1.0.13 on Debian (etch and lenny) > and ubuntu edgy. > note2: overide your current audio devices settings in the configuration > panel with "ALSA: default". > > Cheers, -- Technical Support eeos uk ltd Company No. 05765416 ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel
[Wengophone-devel] ALSA support in WengoPhone and PhApi
Hi Linux guys, Since revision 10817 WengoPhone and PhApi can be compiled without portaudio support :-) In this case a native ALSA support is used. You have to change the option OWSOUND_PORTAUDIO_SUPPORT to activate it. (set it to OFF) To achieve this work I had to debug and improve the ALSA backend of PhApi (phmedia-alsa.c) and I had to write a new implementation for owsound (libs/sound/src/linux). For now this implementation has the responsability to enumerate ALSA devices and plugins, to handle ALSA mixer and to play sound files with libsndfile. This implementation will soon handle OSS too, that's why I have named it "linux". Unfortunately there are some bad news... PhApi does not handle devices that are opened in stereo mode and from what I saw most of devices cannot be opened in mono mode. That's why the only device listed is the default one: you will see "ALSA: default" in the audio configuration panel of the WengoPhone. Another bug: when you resume a call that has been held there's no sound. I will work the next days to get rid on these bugs. In order to integrate this in (one of) the next release(s) of WengoPhone I would be very happy if some of you could test this new stuff. Please feel free to feed our trac on this subject: the appropriate milestone for the tickets is the "WengoPhone 2.1". And finally, for those who do not compile the WengoPhone, I have added a new Linux builder on our buildbot with portaudio support disabled. The related binaries are located in http://wengofiles.wengo.fr/nightlybuilds/binary/NG/GNULinux/2.1 and are named WengoPhone-2.1-minsizerel-alsa-xx.tar.bz2 note: tested with libasound2 1.0.11 and 1.0.13 on Debian (etch and lenny) and ubuntu edgy. note2: overide your current audio devices settings in the configuration panel with "ALSA: default". Cheers, -- Mathieu Stute GPG: http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0x3EE62B4D ___ Wengophone-devel mailing list Wengophone-devel@lists.openwengo.com http://dev.openwengo.com/mailman/listinfo/wengophone-devel