Hi,<br><br>I just checked ubuntu was applied patch which you mentioned.<br><br>> alsa-plugins (1.0.17-0ubuntu5) intrepid-proposed; urgency=low<br>> <br>> * debian/patches/pulse_recording_fix.patch: pa_stream_trigger()<br>
> returns<br>> NULL for capture, so test for it first. Spotted by Takashi Iwai<br>> and<br>> acked by Lennart Poettering.<br>> * LP: #282316 - erratic elapsed time count in "sound recorder"<br>
> <a href="https://bugs.launchpad.net/ubuntu/+bug/282316">https://bugs.launchpad.net/ubuntu/+bug/282316</a><br>> <br>> -- Daniel T Chen <<a href="mailto:crimsun@ubuntu.com">crimsun@ubuntu.com</a>> Mon, 27 Oct 2008 00:14:00<br>
> -0400<br><br>and I upgraded to 1.0.17-0ubuntu5,<br>then -5 I/O error has gone. :-)<br><br>but, still there is a problem, and it looks related with pulseaudio<br><br>
Before using pulseaudio my recording program works well...<br>I know my source is not good code,<br>
but I want to know, what I have to pay attention<br>
when backend of sound system is pulseaudio?<br><br>I use alsa lib to recording from input device,<br>so I made linux_audio_capture() function.<br>When I use snd_pcm_readi() function,<br>the program is aborted or terminated cause of segmentation fault.<br>
<br>> audio_linux_capture()<br>> -> snd_pcm_readi()<br>> -> ...(?)...<br>> -> pulse_poll_activate()<br>> -> write() <- crash!<br><br>gdb tells...<br><br>> (gdb) thread 6<br>
> [Switching to thread 6 (Thread 0xb57e9b90 (LWP 11361))]#0 0xb7ff4430 in __kernel_vsyscall ()<br>> (gdb) bt<br>> #0 0xb7ff4430 in __kernel_vsyscall ()<br>> #1 0xb77d53bb in write () from /lib/tls/i686/cmov/libc.so.6<br>
> #2 0xb4f8d796 in pulse_poll_activate () from /usr/lib/alsa-lib/libasound_module_pcm_pulse.so<br>> #3 0xb4f8be8f in ?? () from /usr/lib/alsa-lib/libasound_module_pcm_pulse.so<br>> #4 0xb4f8c01d in ?? () from /usr/lib/alsa-lib/libasound_module_pcm_pulse.so<br>
> #5 0xb78f2201 in ?? () from /usr/lib/libasound.so.2<br>> #6 0xb78ae0d0 in ?? () from /usr/lib/libasound.so.2<br>> #7 0xb78f2465 in ?? () from /usr/lib/libasound.so.2<br>> #8 0xb78a8544 in snd_pcm_readi () from /usr/lib/libasound.so.2<br>
> #9 0x0805e641 in audio_linux_capture (handle=0x979ee00) at audio_linux.c:720<br>> #10 0x0805c07c in audio_do_thread_work (data=0x97cd648, user_data=0xb57e933c) at audio.c:474<br>> #11 0x0805c1d0 in audio_thread_func (data=0x0) at audio.c:514<br>
> #12 0xb799b02f in ?? () from /usr/lib/libglib-2.0.so.0<br>> #13 0xb75f350f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0<br>> #14 0xb77e57ee in clone () from /lib/tls/i686/cmov/libc.so.6<br>> (gdb)<br>
<br>my audio_linux_capture() function looks like:<br><br>> static int<br>> audio_linux_capture (void *handle)<br>> {<br>> AudioLinux *al = handle;<br>> snd_pcm_uframes_t frames;<br>> int err, worked;<br>
> <br>> worked = 0;<br>> <br>> if (!al->first)<br>> {<br>> /* is it time for reading? */<br>> err = audio_linux_wait_poll (al);<br>> if (err < 0)<br>> {<br>
> if (snd_pcm_state (al->handle) == SND_PCM_STATE_XRUN ||<br>> snd_pcm_state (al->handle) == SND_PCM_STATE_SUSPENDED)<br>> {<br>> err = snd_pcm_state (al->handle) == SND_PCM_STATE_XRUN ? -EPIPE : -ESTRPIPE;<br>
> if (audio_linux_xrun_recovery (al, err) < 0)<br>> {<br>> log_warning (NULL, "write error: %s", snd_strerror (err));<br>> return worked;<br>
> }<br>> al->first = 1;<br>> }<br>> else if (snd_pcm_state (al->handle) == SND_PCM_STATE_RUNNING)<br>> {<br>> /* nothing to do */<br>
> }<br>> else<br>> {<br>> log_debug (NULL, "failed to wait poll");<br>> return worked;<br>> }<br>> }<br>> <br>
> /* nothing to do yet */<br>> if (!err)<br>> return worked;<br>> }<br>> <br>> al->frame->len = 0;<br>> al->frame_offset = 0;<br>> <br>> capture_loop:<br>> <br>
> /* read it now */<br>> if (0) log_debug (NULL, "bytes: %d", err * al->bytes_per_frame);<br>> err = snd_pcm_readi (al->handle, al->frame->data, frames);<br>> if (err < 0)<br>> {<br>
> if (1) log_debug (NULL, "err: %d", err);<br>> if (audio_linux_xrun_recovery (al, err) < 0)<br>> {<br>> if (err != -EAGAIN)<br>> log_warning (NULL, "failed to read: %s", snd_strerror (err));<br>
> }<br>> al->first = 1;<br>> return worked;<br>> }<br>> <br>> if (snd_pcm_state (al->handle) == SND_PCM_STATE_RUNNING)<br>> al->first = 0;<br>> <br>> if (!err)<br>
> return worked;<br>> <br>> al->frame->len = err * al->bytes_per_frame;<br>> <br>> if (al->capture_callback)<br>> al->capture_callback (al->frame, al->capture_callback_data);<br>
> <br>> ++worked;<br>> <br>> goto capture_loop;<br>> }<br><br>Thanks,<br><br>-- <br>Best Regards,<br><br>Keedi Kim<br><br><br><div class="gmail_quote">2008/10/17 Colin Guthrie <span dir="ltr"><<a href="mailto:gmane@colin.guthr.ie">gmane@colin.guthr.ie</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Keedi Kim wrote:<br>
> Hi.<br>
><br>
> I followed PerfectSetup of pulseaudio wiki,<br>
> then aplay works well, but arecord doesn't.<br>
> ALSA's arecord terminates with<br>
> "pcm_read:1473: read error: Input/output error" message.<br>
><br>
> Does anybody has idea?<br>
<br>
</div>I know you've said that the package is using 1.0.17 but there is a<br>
chacne that the Ubuntu package updated the pulse plugin to the latest<br>
version in git (from the 1.0.18rc3 tree).<br>
<br>
If this is the case, then Takashi found a problem with recording via<br>
alsa with these recently on the alsa Mailing list.<br>
<br>
Lennart has yet to ACK this and an earlier message on the Alsa mailing<br>
list from a couple weeks back (unless he's done so privately to Takashi)<br>
so I'm guessing he's a little behind on things right now.<br>
<br>
In lieu of an ACK from Lennart, it may be worth trying out the patch<br>
from Takashi.<br>
<br>
<a href="http://thread.gmane.org/gmane.linux.alsa.devel/56875" target="_blank">http://thread.gmane.org/gmane.linux.alsa.devel/56875</a><br>
<br>
I'd also like to know if it works (not had a moment to try yet) so I can<br>
issue an update package for this.<br>
<br>
Col<br>
<br>
--<br>
<br>
Colin Guthrie<br>
gmane(at)<a href="http://colin.guthr.ie" target="_blank">colin.guthr.ie</a><br>
<a href="http://colin.guthr.ie/" target="_blank">http://colin.guthr.ie/</a><br>
<br>
Day Job:<br>
Tribalogic Limited [<a href="http://www.tribalogic.net/" target="_blank">http://www.tribalogic.net/</a>]<br>
Open Source:<br>
Mandriva Linux Contributor [<a href="http://www.mandriva.com/" target="_blank">http://www.mandriva.com/</a>]<br>
PulseAudio Hacker [<a href="http://www.pulseaudio.org/" target="_blank">http://www.pulseaudio.org/</a>]<br>
Trac Hacker [<a href="http://trac.edgewall.org/" target="_blank">http://trac.edgewall.org/</a>]<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
pulseaudio-discuss mailing list<br>
<a href="mailto:pulseaudio-discuss@mail.0pointer.de">pulseaudio-discuss@mail.0pointer.de</a><br>
<a href="https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss" target="_blank">https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss</a><br>
</div></div></blockquote></div><br><br clear="all"><br>