[Alsa-user] RT-timings when recording
Hello ALSA-user list! I am trying to read on an ALSA-device with a simple example program I found here: https://gist.github.com/albanpeignier/104902 It just sets up the audio interface and then records audio samples in a loop. That's it already. I enhanced it a little in order to measure some timings, that are relevant for me. So I'd like to have an endless loop running, that just records audio and does this at a fixed interval. For that reason, I altered the loop within the example-prorgam linked above like this: [code] gettimeofday( _debug_output_StTV, NULL ); for (i=0;i<10;i++) { if ((err = snd_pcm_readi (capture_handle, buffer, buffer_frames)) != buffer_frames) { fprintf (stderr, "read from audio interface failed %d (%s)\n", err, snd_strerror (err)); return (1); } gettimeofday( _end_of_loop_StTV, NULL ); looptime_I = (timestamp_end_of_loop_StTV.tv_usec - timestamp_debug_output_StTV.tv_usec + (timestamp_end_of_loop_StTV.tv_sec - timestamp_debug_output_StTV.tv_sec) * 100); gettimeofday( _debug_output_StTV, NULL ); fprintf(stdout, "read %d done, %05d usec\n", i, looptime_I); } [/code] I am reading a certain amount of frames. After that I measure the time it took to get this amount of frames. What surprises me is, that the intervals of reading are varying a lot. So my output looks like this: [quote] read 0 done, 45664 usec read 1 done, 00128 usec read 2 done, 00084 usec read 3 done, 09773 usec read 4 done, 00100 usec read 5 done, 00066 usec read 6 done, 00063 usec read 7 done, 09765 usec read 8 done, 00096 usec read 9 done, 00066 usec [/quote] The first one is irrelevant as the times taken are not reliable due to the initiation of this process. But then, I get 128 usecs, then 84 usecs - values that seem to be ok as the buffer that I am reading from might be filled initially. So reading does not take long, I am directly getting the audio data from the kernel driver. Then, it once takes longer - almost 10ms. This is alright, as my configured period time is 1, which I can observe from the output of snd_pcm_dump(); [quote] Hardware PCM card 1 'dummy-audio' device 0 subdevice 0 Its setup is: stream : CAPTURE access : RW_INTERLEAVED format : S16_LE subformat: STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 24000 period_size : 480 period_time : 1 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min: 480 period_event : 0 start_threshold : 1 stop_threshold : 24000 silence_threshold: 0 silence_size : 0 boundary : 1572864000 appl_ptr : 0 hw_ptr : 0 [/quote] After this 10ms run, there are three runs with values around 100us, which tells me, that everytime I want to read audio data in my loop, there is data waiting for me (mind my VERY simple snd_pcm_readi()-loop). But I don't understand, why it is that way. I would expect the next run after the first 10ms run to take 10ms again. I am running this program on an Intel Edison-Board using an RT-Kernel: [quote] # uname -a Linux wurst 3.10.17-rt12-poky-edison-preempt_rt+ #9 SMP PREEMPT RT Mon Sep 19 14:24:24 CEST 2016 i686 GNU/Linux [/quote] I also set some IRQ-priorities like this: [code] # chrt -f -p 90 # chrt -f -p 89 # chrt -f -p 89 [/code] The same measurement-results of the timings can be observed on a virtual machine using Oracle VirtualBox running an Ubuntu 14.04 with this Kernel: [quote] # uname -a Linux test-VirtualBox 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux [/quote] I will continue doing some tests even with other hardware in order to get an idea, why the program behaves like this. In the meantime, I'd appreciate any idea that could help in finding the source of my obervations. Maybe there is no "error" that I am searching for, but I rather misunderstand something in this matter. Thanks for any hints in advance. If there is any additonal information required, please ask me and I'll do my best to provide the information. Best regards, Dennis -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] period_size below 8000 on Intel Edison
Hello Clemens, the device is called "dummy-audio", check this output of aplay: >>>>>>>>>>>>>>>>>>>>>> root@edison:~# aplay -l List of PLAYBACK Hardware Devices card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 1: dummyaudio [dummy-audio], device 0: 1 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: dummyaudio [dummy-audio], device 1: ((null)) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: dummyaudio [dummy-audio], device 2: ((null)) [] Subdevices: 1/1 Subdevice #0: subdevice #0 root@edison:~# <<<<<<<<<<<<<<<<<<< As far as I know, this is just some audio driver, that Intel made for their Edison platform. I get the sound-data via I2S into an external soundcard, that reads the I2S data and produces some audible noise from the data. Anyway, if I use mpg123 (like this: "mpg123 -a hw:1,0 -v test.mp3" ), sound works fine, so the interface works fine. It just won't accept my settings, but here's more information on that, while I try to answer your questions the best way I can. period_time has the value "2000" before I use the function snd_pcm_hw_params_set_period_time_near(*pcm_handle, hwparams, _time, ); and has the same value of 2000 after I call it. And yes, I do call snd_pcm_hw_params() in my program after having set the period_time. For further understanding, here are the functions I call in my C-program: >>>>>>>>>>>>>>>>>>>>>> err = snd_pcm_hw_params_set_period_time_near(*pcm_handle, hwparams, _time, ); if( err != 0 ) { printf("%s:%u error setting period time (%s), error-code: %d\n", __FILE__, __LINE__, strerror(err), err); } err = snd_pcm_hw_params_set_buffer_time_near( *pcm_handle, hwparams, _time, ); if( err != 0 ) { printf("%s:%u error setting buffer time (%s), error-code: %d\n", __FILE__, __LINE__, strerror(err), err); } err = snd_pcm_hw_params( *pcm_handle, hwparams ); if( err != 0 ) { printf("%s:%u error installing hwparams (%s), error-code: %d\n", __FILE__, __LINE__, strerror(err), err); exit(EXIT_FAILURE); } <<<<<<<<<<<<<<<<<<< In addition, if I try to use the function snd_pcm_hw_params_set_period_size() as an alternative to snd_pcm_hw_params_set_period_time_near(), I get the error "main_alsa.c:231 error setting period size (Unknown error -22), error-code: -22". Here is how I call it: >>>>>>>>>>>>>>>>>>>>>> val = 96; dir = 0; err = snd_pcm_hw_params_set_period_size(*pcm_handle, hwparams, val, dir); if( err != 0 ) { printf("%s:%u error setting period size (%s), error-code: %d\n", __FILE__, __LINE__, strerror(err), err); } <<<<<<<<<<<<<<<<<<< Any additional help would be really appreciated. All the best and thanks in advance, Dennis Am 06.01.2016 um 20:58 schrieb Clemens Ladisch: > Dennis Borgmann wrote: >> A short while ago, I came across a new platform - the Intel Edison. I >> would like to port my software to that hardware, which essentially works >> out fine, as it also is a x86 platform. The only problem I see is ,that >> I have not yet been able to configure ALSA to shrink its period size >> down to 2ms on Intel Edison. I get the following output from >> snd_pcm_dump(*pcm_handle,NULL); >> >> Hardware PCM card 1 'dummy-audio' device 0 subdevice 0 > Is that device really called "dummy"? > >> As you can see, the period_size is 384 and the period_time is 8000. Its >> values should be 96 (period_size) and 2000 (period_time). I am setting >> these values in my C-program with these commands: >> >> err = snd_pcm_hw_params_set_period_time_near(*pcm_handle, hwparams, >> _time, ); >> >> period_time has the value 2000. > What value does it have after this function returns? > > Did you call snd_pcm_hw_params? > > > Regards, > Clemens -- ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] period_size below 8000 on Intel Edison
Hi alsa-users! I have a software written in C, that's been running for quite some time (about 5 years) on a x86-machine(actually, it's a PC Engines ALIX-Board with a Debian Linux running on it). It is using ALSA for reading from a soundcard, transmitting it via network to another node running roughly the same software that successively plays it back. The software therefore has two buffers - one on transmitter side and one on receiver side. It creates audio packages of 2ms length each, that then get transmitted via network. A short while ago, I came across a new platform - the Intel Edison. I would like to port my software to that hardware, which essentially works out fine, as it also is a x86 platform. The only problem I see is ,that I have not yet been able to configure ALSA to shrink its period size down to 2ms on Intel Edison. I get the following output from snd_pcm_dump(*pcm_handle,NULL); Hardware PCM card 1 'dummy-audio' device 0 subdevice 0 Its setup is: stream : PLAYBACK access : MMAP_INTERLEAVED format : S16_LE subformat: STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 768 period_size : 384 period_time : 8000 tstamp_mode : NONE period_step : 1 avail_min: 384 period_event : 0 start_threshold : 384 stop_threshold : 768 silence_threshold: 1 silence_size : 1 boundary : 1610612736 appl_ptr : 0 hw_ptr : 0 As you can see, the period_size is 384 and the period_time is 8000. Its values should be 96 (period_size) and 2000 (period_time). I am setting these values in my C-program with these commands: err = snd_pcm_hw_params_set_period_time_near(*pcm_handle, hwparams, _time, ); period_time has the value 2000. After having observed this discrepancy, I tried to solve it via another function: err = snd_pcm_hw_params_set_period_size( *pcm_handle, hwparams, val, dir ); The variables val and dir are set as follows: val=96; dir=0; Still, I did not get the result I wanted or needed. The period_size is still at 8000. Could anybody please point me to a hint, that could explain, why the Intel Edison cannot set the period_size below 8000? Is this a hardware issue or am I missing out something on my side? Should I try to configure my system in a different way? Is this maybe even a system-wide setting within ALSA? Any hint would be really appreciated. All the best, Dennis -- ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] _snd_pcm_hw_open not defined - ALSA plus MPlayer on ARM[AT91SAM9260]
Hello alsa-list, hello mplayer-list! These are the options I need in order to make it all run on my AT91SAM9260: ALSA-lib: :~/downloads/alsa-lib-1.0.24.1$ export LDFLAGS= :~/downloads/alsa-lib-1.0.24.1$ export CFLAGS= :~/downloads/alsa-lib-1.0.24.1$ export LIBS=-lm :~/downloads/alsa-lib-1.0.24.1$ ./configure --disable-old-symbols --disable-alisp --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --prefix=/usr --exec-prefix=/usr \ --sysconfdir=/etc --enable-shared=no --enable-static=yes --with-alsa-devdir=/dev/snd --with-pcm-plugins=all --with-ctl-plugins=all --without-versioned --disable-python --with-softfloat :~/downloads/alsa-lib-1.0.24.1$ make :~/downloads/alsa-lib-1.0.24.1$ mkdir ../alsa-destdir/usr -p :~/downloads/alsa-lib-1.0.24.1$ make install DESTDIR=/home/test/downloads/alsa-destdir/ Alsa-utils: :~/downloads/alsa-utils-1.0.24.2$ export LDFLAGS=-L/home/test/downloads/alsa-destdir/usr/lib/ :~/downloads/alsa-utils-1.0.24.2$ export CFLAGS=-I/home/test/downloads/alsa-lib-1.0.24.1/include/ :~/downloads/alsa-utils-1.0.24.2$ export LIBS= :~/downloads/alsa-utils-1.0.24.2$ ./configure --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --disable-xmlto \ --without-curses --with-alsa-inc-prefix=/home/test/downloads/alsa-destdir/usr/include/ --disable-nls --disable-alsamixer --disable-alsaloop --disable-alsatest :~/downloads/alsa-utils-1.0.24.2$ make :~/downloads/alsa-utils-1.0.24.2$ make install DESTDIR=/home/test/downloads/alsa-destdir/ MPlayer: :~/downloads/MPlayer-1.0rc4$ mkdir destdir :~/downloads/MPlayer-1.0rc4$ export TGT=`pwd`/destdir :~/downloads/MPlayer-1.0rc4$ export CFLAGS= :~/downloads/MPlayer-1.0rc4$ export LDFLAGS= :~/downloads/MPlayer-1.0rc4$ export LIBS= :~/downloads/MPlayer-1.0rc4$ make clean :~/downloads/MPlayer-1.0rc4$ ./configure --enable-cross-compile --cc=arm-linux-gcc --as=arm-linux-as --host-cc=gcc --target=arm-linux --prefix=$TGT --disable-network --disable-x11 \ --disable-gui --disable-armv6 --disable-armv6t2 --disable-armvfp --disable-neon --disable-iwmmxt --disable-libmpeg2 --disable-libmpeg2-internal --disable-mencoder --disable-tga --disable-pnm \ --disable-md5sum --disable-yuv4mpeg --disable-tv --disable-ftp --disable-real --disable-xanim --disable-v4l2 --disable-dvb --disable-fbdev --disable-dvdnav --disable-libdvdcss-internal \ --disable-dvdread-internal --disable-vcd --disable-tremor-internal --disable-faad-internal --disable-ossaudio --enable-static --extra-cflags=-mcpu=arm920t -O3 \ -I/home/test/downloads/alsa-destdir/usr/include/ --disable-libvorbis --extra-ldflags=-L/home/test/downloads/alsa-destdir/usr/lib/ :~/downloads/MPlayer-1.0rc4$ make At least now it runs. Last point I am struggling with right now is CPU load. On an AT91SAM9260(200MHz) the sound is stuttering at 100% CPU load, on an AT91SAM9g20(400MHz), the sound is working fine. I will try to let it run with libmad. I wonder if that will bring me forward a little. Anyway, mplayer and ALSA are running fine now. Thank you Jaroslav Kysela for the hint to the INSTALL-file. Best regards, Dennis Sergei Steshenko schrieb: On Thu, 31 Mar 2011 08:10:32 +0200 Sergei Steshenko steshenko_ser...@list.ru wrote: On Thu, 31 Mar 2011 07:59:56 +0200 (CEST) Jaroslav Kysela pe...@perex.cz wrote: [snip] If I remember correctly, the problem is that libtool uses only one target object file for both '-fPIC -DPIC' shared and static libraries. We use -DPIC to determine the static build to resolve buildin dynamic symbols. In other words, we need to determine the static mode at the compile time (in gcc) which libtool does not allow. Sure, it may work for other libraries which don't use the symbol tables in way as alsa-lib does. Jaroslav - Jaroslav Kysela pe...@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc. So, are you talking about a bug or a feature - the latter in this case is documented intended behavior of 'libtool'. If it is a feature, then the bug is with ALSA team which/who decided to use a wrong tool ('libtool') for the job (creating both dynamic and static libraries). If it's a bug in 'libtool', where is ALSA team's bug report ? Thanks, Sergei. -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user And it looks more and more like ALSA bug to me. The two relevant points are: 1) ALSA means Advanced _Linux_ Sound Architecture, the Linux word means Linux only; 2) 'libtool' is intended to abstract out complexities/nuances of library
[Alsa-user] _snd_pcm_hw_open not defined - ALSA plus MPlayer on ARM[AT91SAM9260]
Hello alsa-users, hello mplayer-users! Recently, I tried to compile MPlayer 1.0rc4-4.3.5 for ARM AT91-SAM9260. # uname -a Linux testsystem 2.6.33.7 #1 PREEMPT Wed Mar 30 13:33:39 CEST 2011 armv5tejl GNU/Linux Compiling MPlayer did work out with this configure-line: # export TGT=`pwd`/destdir # ./configure --enable-cross-compile --cc=arm-linux-gcc --as=arm-linux-as --host-cc=gcc --target=arm-linux --prefix=$TGT --disable-network --disable-x11 --disable-gui --disable-armv6 --disable-armv6t2 --disable-armvfp --disable-neon --disable-iwmmxt --disable-libmpeg2 --disable-libmpeg2-internal --disable-mencoder --disable-tga --disable-pnm --disable-md5sum --disable-yuv4mpeg --disable-tv --disable-ftp --disable-real --disable-xanim --disable-v4l2 --disable-dvb --disable-fbdev --disable-dvdnav --disable-libdvdcss-internal --disable-dvdread-internal --disable-vcd --disable-tremor-internal --disable-faad-internal --disable-ossaudio --disable-mp3lib --enable-static --extra-cflags=-mcpu=arm920t -O3 --disable-libvorbis Then I still needed ALSA for mplayer to run on my embedded board. This is the configure line for the alsa-lib: # ./configure --disable-old-symbols --disable-alisp --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --prefix=/usr --exec-prefix=/usr \ --sysconfdir=/etc --enable-shared --enable-static --with-alsa-devdir=/dev/snd --with-pcm-plugins=all --with-ctl-plugins=all --without-versioned --disable-python --with-softfloat # make I also needed alsa-utils, with these steps I managed to compile it: # export LDFLAGS=-L/home/test/downloads/alsa-destdir/usr/lib/ # export CFLAGS=-I/home/test/downloads/alsa-lib-1.0.24.1/include/ # export LIBS= # ./configure --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --disable-xmlto \ --without-curses --with-alsa-inc-prefix=/home/test/downloads/alsa-destdir/usr/include/ --disable-nls --disable-alsamixer # make After copying the alsa-destdir - folder to my target, everything is in its place and I can run mplayer. Only problem on the arm-target is: # /usr/local/sbin/mplayer -ao alsa:device=hw=0.0 /mnt/song.mp3 o alsa MPlayer 1.0rc4-4.3.5 (C) 2000-2010 MPlayer Team Playing /mnt/song.mp3. Audio only file format detected. == Opening audio decoder: [mp3lib] MPEG layer-2, layer-3 AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000-176400) Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3) == [AO_ALSA] alsa-lib: pcm.c:2175:(snd_pcm_open_conf) symbol _snd_pcm_hw_open is not defined inside [builtin] [AO_ALSA] Playback open error: No such device or address Failed to initialize audio driver 'alsa:device=hw=0.0' Could not open/initialize audio device - no sound. Audio: no sound Video: no video
Re: [Alsa-user] getting device name for playback
Hello alsa-users! I found out, how to get to know the device names. It can be done by parsing the output of alsactl store. Every device, that is capable of output, has got a negative or 0-value of dbmax. Best regards, Dennis Dennis Borgmann schrieb: Hello alsa-users! I would like to extract the info, which device is for playback on a sound device. For example, I have a headset, which gives back this info: :~# amixer -c 0 scontrols Simple mixer control 'Mic',0 Simple mixer control 'Auto Gain Control',0 Simple mixer control 'Speaker',0 and for another card plugged to the very same system: :~# amixer -c 1 scontrols Simple mixer control 'PCM',0 So there is one card having only one channel for playback (device named PCM here) and then there is the headset, which has a Speaker, an Auto Gain Control and a microphone(Mic). I want to adjust volumes of Speaker and PCM. To extract PCM of the soundcard can be done easily, since there is only one device. But take the card with the headset - how can I distinguish, which card if meant for playback? If I have a look at it with humanoid intuition, it is easy. But if I want to let this be parsed in a script - what to do? This card has got three devices. Any ideas? Best regards, Dennis -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] getting device name for playback
Hello alsa-users! I would like to extract the info, which device is for playback on a sound device. For example, I have a headset, which gives back this info: :~# amixer -c 0 scontrols Simple mixer control 'Mic',0 Simple mixer control 'Auto Gain Control',0 Simple mixer control 'Speaker',0 and for another card plugged to the very same system: :~# amixer -c 1 scontrols Simple mixer control 'PCM',0 So there is one card having only one channel for playback (device named PCM here) and then there is the headset, which has a Speaker, an Auto Gain Control and a microphone(Mic). I want to adjust volumes of Speaker and PCM. To extract PCM of the soundcard can be done easily, since there is only one device. But take the card with the headset - how can I distinguish, which card if meant for playback? If I have a look at it with humanoid intuition, it is easy. But if I want to let this be parsed in a script - what to do? This card has got three devices. Any ideas? Best regards, Dennis -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] snd_pcm_wait won't return
Hello alsa-users list! I am using the alsa-lib in one of my projects and within this project, there is a call for snd_pcm_wait() on a machine, that plays sound. The call itself looks like this: snd_pcm_wait( pcm_handle, 1000 ); A few steps before, I had the timeout set to unlimited (-1), which sometimes did not return at all. Now, it sometimes returns after the timeout, but in result I cannot write anything to the soundcard anymore. This error is reproducable if there are many underruns in a row. Since this program runs in a network environment and receives its data from a datastream, I sometimes cannot avoid those underruns. So, what could be the error, that leads to alsa not responding anymore? I can only revitalize the system after such an error by rebooting the whole system (well, at least I did not find another solution like snd_pcm_prepare or snd_pcm_recover). Which additional informations do you need? What is there, that I can provide in addition? Could this be an alsa-bug? Kind regards, Dennis -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] USB-no capture device
Hi list! I just compiled the new alsa-driver, since I had no capture option with a Behringer UCA202 USB-card, which contains a PCM2902 from TI using alsa in version 1.0.20. Now, I recompiled the following packages: alsa-driver-1.0.21 alsa-lib-1.0.21a alsa-utils-1.0.21 alsa-firmware-1.0.20 alsa-plugins-1.0.21 Then I copied them to a flash-card, that is put onto an ALIX-board from PC Engines. In the BIOS of the ALIX, I disabled the on-board CS5535 and then I plugged in the USB-card from Berhinger and did a full reboot. Now the result is the following: #alsactl store # cat /etc/asound.state state.default { control.1 { comment.access 'read write' comment.type BOOLEAN comment.count 1 iface MIXER name 'PCM Playback Switch' value true } control.2 { comment.access 'read write' comment.type INTEGER comment.count 2 comment.range '0 - 128' comment.dbmin 0 comment.dbmax 0 iface MIXER name 'PCM Playback Volume' value.0 128 value.1 128 } } #cat /proc/asound/cards 0 [default]: USB-Audio - USB Audio CODEC Burr-Brown from TI USB Audio CODEC at usb-:00:0f.4-4, full s # cat /proc/asound/devices 0: [ 0] : control 16: [ 0- 0]: digital audio playback 24: [ 0- 0]: digital audio capture 33:: timer # cat /proc/asound/pcm 00-00: USB Audio : USB Audio : playback 1 : capture 1 #cat /proc/asound/version Advanced Linux Sound Architecture Driver Version 1.0.21. Compiled on Dec 1 2009 for kernel 2.6.29.5-rt22-486-voyage. #cat /proc/asound/modules 0 snd_usb_audio #cat /proc/asound/timers G0: system timer : 1000.000us (1000 ticks) P0-0-0: PCM playback 0-0-0 : SLAVE P0-0-1: PCM capture 0-0-1 : SLAVE So far, so good, but if I go to alsamixer and try to select a capture device, it shows the following: This sound device does not have any capture controls. What am I doing wrong? Any ideas? I hope for a good answer since I want to get this device running :-) Kind regards, Dennis -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] Sound XRUN on RT-Linux
Hello ALSA-users! Hello RT-users! I think, this mail might be interesting for both the lists, since it's dealing with ALSA and the usage of a realtime-kernel. I've been playing around with ALSA for quite some weeks now and I am trying to get reading of sound done with small latencies. Therefore I am using the hw:0:0-device with SND_PCM_STREAM_CAPTURE and SND_PCM_NONBLOCK. My device is configured with a total buffersize of 882 frames (44100Hz in SND_PCM_FORMAT_S16 on 2 channels). All I do, is waiting 2 milliseconds and then reading with snd_ocm_readi() as much as I can from the soundcard (well, I get the amount of frames available after 2ms, of course. This timing is quite stable). I have the program running on an X86-board (500MHz Geode with CS5535-Chipset), I applied the realtime patches of Ingo Molnar, I did set my software to SCHED_FIFO and prio 90, the ICQ of the sounddevice is set to 98 (this is done with chrt -f -p 98 `pidof IRQ-11`), my /proc/interrupts is quite empty (see below) and I did set the latency of the PCI-devices in order to give prio ty the soundcard: setpci -v -s '*:*' latency_timer=20 setpci -v -d '1022:2093' latency_timer=80 My uname: # uname -a Linux master 2.6.29.5-rt22-486-voyage #1 PREEMPT RT Wed Jun 24 09:10:02 GMT 2009 i586 GNU/Linux Here goes the /proc/interrupts - stuff: #cat /proc/interrupts CPU0 0:1020847XT-PIC-XT timer 1: 2XT-PIC-XT i8042 2: 0XT-PIC-XT cascade 4:982XT-PIC-XT serial 10: 762598XT-PIC-XT wifi0 11:1788972XT-PIC-XTCS5535 Audio 12: 4XT-PIC-XT i8042 14:873XT-PIC-XT ide0 NMI: 0 Non-maskable interrupts LOC: 0 Local timer interrupts SPU: 0 Spurious interrupts CNT: 0 Performance counter interrupts ERR: 0 MIS: 0 My problem now: roundabout 5 times per minute, I get a buffer outrun, which results in a scratch of the sound, that I am recording. It seems like I am running over- and underruns again and again. The output looks like this: curdma=f3d8000 f97 bufaddr. curdma=f3d8000 f97 bufaddr. curdma=f3d8000 f97 bufaddr. curdma=f3d8000 f97 bufaddr. diff=dc8 = dc8 buf_bytes. diff=dc8 = dc8 buf_bytes. curdma=f3d8000 f97 bufaddr. curdma=f3d8000 f97 bufaddr. curdma=f3d8000 f97 bufaddr. diff=dc8 = dc8 buf_bytes. (and so on...) I found the driver module, that produces this output, it is /usr/src/linux-2.6.29.5/sound/pci/cs5535audio/cs5535audio_pcm.c From line 329 and onwards, there is the function static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer , which genreates this output and seems to be the reason for my crappy sound. Is there anyone among the RT-list or the ALSA-list who has a slight idea, what my problem might be related to and how I can get rid of it? Very kind regards, Dennis Borgmann -- ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] Strange knocking while playing sound
Hello list-users! I am programming some network-transmitting soundserver and client - I'm tyring to get some soundstreaming via network done. Everything works fine, the load of the driver ringbuffer seems to be OK so far (at least 400 frames in the buffer at any point of time, I am taking care of this in my program). Although this seems to be right, I get some odd knockings all of the time. The sound itself is transmitted OK, but still there is this ugly noise in the background. If I set the volume of the transmitting device to mute, the knocks go away and if I turn up the volume of the playing device, the knocks become louder. So it goes hand in hand with the music. I am working with snd_pcm_mmap_begin and snd_pcm_mmap_commit - just the way it is done in the pcm.c under the test-directory of the alsa-lib. While working with snd_pcm_writei(), those problems did not occur, but I want to test this using the mmap technology. (By the way, this also leads me to the conclusion, that my problems are related to the network client, which writes to the sound device). My problem does not seem to be related to sepcific soundcards, as I saw the problem on two different machines. Any suggestions, what my problem might be? Thanks a whole lot in advance for any kind of help! Dennis - -- Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] Underrun although there still is data in the driver
Hello Alsa-Users - list! I just wonder, how it is possible, that i get an EPIPE (underrun) on a nonblocking card while issueing writei(). If I issue a snd_pcm_avail() less than 40us before, it shows no underrun, but instead about 600 frames available in the driver, which would take about 10ms to play. Therefore, the driver cannot yet be empty! It should still have plenty of frames available!!! It is just a question of me understanding this. This seems to be illogical to me... Kind regards, Dennis -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] threshold not applied
Hello list-users! I am trying to set a software-parameter with this command: snd_pcm_sw_params_set_start_threshold This is working fine with a machine, that I got standing in my own flat. But as soon as I use it with a PC from a friend, this parameter is not applied (I can see this from time measurements while doing snd_pcm_readi). The hardware might be different, as I can set on the machine, that this parameter is working on can set the rate to 48000, but the machine, that this does not work wants to set 47999 instead. Does anyone have a clue, what the error might be? Kind regards in advance, Dennis -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] threshold not applied
Hello Jaroslav, thanks a whole lot for helping me out - but this brings me to another point. Where can I find such exact information about the functions? To me, the doxygen-docu does not contain this information as clear as you wrote it. Even now, I do not understand the doxygen-docu the way you write it. Where is a good source for documentation? I do NOT want to read the whole sourcecode of the alsa-lib... Very kind regards with sunny greetings from Germany Dennis Jaroslav Kysela schrieb: On Wed, 3 Jun 2009, Dennis Borgmann wrote: Hello list-users! I am trying to set a software-parameter with this command: snd_pcm_sw_params_set_start_threshold This is working fine with a machine, that I got standing in my own flat. But as soon as I use it with a PC from a friend, this parameter is not applied (I can see this from time measurements while doing snd_pcm_readi). For capture, start_threshold just starts capture when you request given amount of samples. Nothing else, so you may expect to read less samples than in start_threshold. You probably want to set avail_min parameter. Jaroslav - Jaroslav Kysela pe...@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc. -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] Fragment size
Hello List-users! I have been dealing with this for quite some time now and I cannot get to the point. I have a rather simple code of maybe 100 lines which just writes some buffer to the soundcard using snd_pcm_writei(). Although the buffer is just there within the program itself (no external source, just internal in order to understand the code), I am running into underruns. I don't see the point - how ca I run into underruns, if data is always there? In addition I would like to set the fragment count of the driver - I think this term is derived from OSS. I would like to have at least three fragments of each 256 frames, but I do not know how to set this. The doxygen documentation is not a real good source I must admit... Could anyone please help me? Thanks in advance Dennis I attached my testcode. #include includes.h #include defines.h struct globals global; int main( int argc, char ** argv) { int transmitter_decision = 0; /* simple flag for bool choice of server */ snd_pcm_t *sound_handler; struct sched_param scheduler_parameter; char read_data[2048]; char *pointer; int written_frames; int len=256; struct timeval time2,time3; scheduler_parameter.sched_priority = SCHEDULER_PRIORITY; sched_setscheduler(0, SCHEDULER_POLICY, scheduler_parameter); snd_pcm_stream_t stream; snd_pcm_hw_params_t *hwparams; snd_pcm_sw_params_t *swparams; char *pcm_name; unsigned int exact_rate; snd_pcm_access_t accesstype = ACCESS; snd_pcm_format_t format = FORMAT; snd_pcm_uframes_t buffersize = BUFFERSIZE_FRAMES; unsigned int periods = PERIODS_PER_INTERRUPT; int dir, err; snd_pcm_uframes_t val; snd_pcm_t *pcm_handle; memset( read_data, 0xff, sizeof( read_data ) ); if (argc 2) { printf(usage: '%s SERVER-IP' for client or '%s 1' for server \n,argv[0],argv[0]); exit( -1 ); } if( memset( global, 0, sizeof(struct globals) ) == NULL ) perror(memset); if( strncmp(argv[1],1,1) == 0 ) transmitter_decision = 1; pcm_name = strdup(hw:0,0); snd_pcm_hw_params_alloca( hwparams ); stream = SND_PCM_STREAM_PLAYBACK; if( snd_pcm_open( pcm_handle, pcm_name, stream, 0 ) != 0 ) { fprintf(stderr, Error opening PCM device %s\n, pcm_name); return(-1); } if( snd_pcm_hw_params_any( pcm_handle, hwparams ) != 0 ) { fprintf(stderr, Cannot configure PCM device\n); return(-1); } /** Setting the previously tested capabilities */ if( snd_pcm_hw_params_set_access( pcm_handle, hwparams, accesstype ) != 0 ) { fprintf(stderr, SET: Error setting access\n); return(-1); } if( snd_pcm_hw_params_set_format( pcm_handle, hwparams, format ) != 0 ) { fprintf(stderr, SET: Error setting format\n); return(-1); } exact_rate = RATE; dir = -1; if( snd_pcm_hw_params_set_rate_near( pcm_handle, hwparams, exact_rate, dir ) != 0 ) { fprintf(stderr, SET: Error setting rate %d\n, dir); return(-1); } if( RATE != exact_rate ) { fprintf(stderr, The rate is not supported by your hardware.\n \ ATTENTION! Alsa-resampler being used!!! == Using %d_Hz instead of %d_Hz.\n, exact_rate, RATE); } if( snd_pcm_hw_params_set_channels( pcm_handle, hwparams, CHANNELS ) != 0 ) { fprintf(stderr, SET: Error setting channels\n); return(-1); } if( snd_pcm_hw_params_set_periods_near( pcm_handle, hwparams, periods, 0 ) != 0 ) { fprintf(stderr, SET: Error setting periods\n); return(-1); } // Set buffer size (in frames). The resulting latency is given by // latency = periodsize * periods / (rate * bytes_per_frame) // Buffersize in FRAMES Not in bytes!! if( snd_pcm_hw_params_set_buffer_size_near( pcm_handle, hwparams, buffersize ) != 0 ) { fprintf(stderr, SET: Error buffer size\n); return(-1); } if( buffersize != BUFFERSIZE_FRAMES ) { fprintf(stderr, BUFFERSIZE_FRAMES not set, check capture.cpp!\n); return(-1); } if( snd_pcm_hw_params( pcm_handle, hwparams ) != 0 ) { fprintf(stderr, SET: Error applying parameters\n); return(-1); } snd_pcm_sw_params_alloca(swparams); err = snd_pcm_sw_params_current(pcm_handle, swparams); if (err 0) { printf(Unable to determine current swparams %s\n,snd_strerror(err)); return err; } snd_pcm_hw_params_get_period_size(hwparams, val, NULL); err = snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, val); if (err 0) { printf(Unable to set avail min %s\n, snd_strerror(err)); return err; } err = snd_pcm_sw_params(pcm_handle, swparams); if (err 0) { printf(Unable to set sw params %s\n, snd_strerror(err)); return err; } while(1){ len=256; pointer=read_data; while (len 0) { while( ( written_frames = snd_pcm_writei( pcm_handle, pointer, len ) ) 0 ) { snd_pcm_prepare( pcm_handle ); printf( Buffer Underrun \n); } if(written_frames!=256)printf(%d\n,written_frames); pointer+=written_frames*4; len-=written_frames; } } } -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of