From: Takashi Iwai <tiwai@suse.de>
To: "Cyril.Coquilleau@UTBM.fr" <Cyril.Coquilleau@utbm.fr>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: capture with non-interleaved mode
Date: Tue, 14 Oct 2003 18:05:53 +0200 [thread overview]
Message-ID: <s5hn0c3u7mm.wl@alsa2.suse.de> (raw)
In-Reply-To: <1066145440.3f8c16a008002@webmail.utbm.fr>
At Tue, 14 Oct 2003 17:30:40 +0200,
Cyril.Coquilleau@UTBM.fr wrote:
>
> > >Hi. I'm developping a signal processing program which needs to compute data
> >
> > >from each channel of soundcards separately.
> > >After searches I found that I must open the soundcard with the
> > >SND_PCM_ACCESS_RW_NONINTERLEAVED flag but it doesn't works well : for each
> >
> > >readn operation i get the -32 error code . Meanwhile, I tested capture in
> > >interleaved mode and it works well.
> > >I had to use hw:x,y for the interleaved capture and plughw:x,y for the
> > non-
> > >interleaved capture, I don't know if non-interleaved capture works with
> > hw:x,y.
> >
> > [ We need a FAQ ... ]
> >
> > ALSA's "hw" devices can only be used with parameters that match
> > capabilities offered by the underlying hardware. There's not much
> > hardware out there that supports non-interleaved I/O, so as a result,
> > most "hw" devices can't do this. The Hammerfall and ice1712 series are
> > notable exceptions. But there is a corollary: if you were using a
> > hammerfall, the "hw" device cannot do interleaved I/O either.
> >
> > as to your error, its probably a bug in your code. JACK uses
> > non-interleaved mode by default, and it works with both plughw and hw
> > models of many different kinds. if you posted the relevant parts of it
> > here, somebody can probably help you.
> >
> >
>
> I join the relevant parts of the source (without error handlers) :
>
> #define BUF_SIZE 128
>
> struct snd_card
> {
> snd_pcm_t *handle;
> snd_pcm_hw_params_t *params;
>
> short inputBuffer[BUF_SIZE*2];
> void *buffer[2];
> };
> typedef struct snd_card snd_card_t;
>
> int
> main (....)
> {
> char card_id[32];
> int err;
> itn card = 0;
> snd_card_t *card1;
>
> card1 = calloc(1,sizeof(snd_card_t));
> card1->buffer[0] = card1->inputBuffer;
> card1->buffer[1] = &card1->inputBuffer[BUF_SIZE];
> snprintf (card_id, 32, "plughw:%d", card);
>
> snd_pcm_open (&card1->handle, card_id, SND_PCM_STREAM_CAPTURE, 0);
> snd_pcm_hw_params_malloc (&card1->params);
> snd_pcm_hw_params_any (card1->handle, card1->params);
> snd_pcm_hw_params_set_channels (card1->handle, card1->params, 2);
> snd_pcm_hw_params_set_access (card1->handle, card1->params,
> SND_PCM_ACCESS_RW_NONINTERLEAVED);
> snd_pcm_hw_params_set_format (card1->handle, card1->params,
> SND_PCM_FORMAT_S16_LE);
> snd_pcm_hw_params_set_rate_near (card1->handle, card1->params, ECHANT, 0);
> snd_pcm_hw_params (card1->handle, card1->params);
> snd_pcm_hw_params_free (card1->params);
> snd_pcm_prepare (card1->handle);
>
> while (...)
> {
> err = snd_pcm_readn (card1->handle, card1->buffer, BUF_SIZE);
> printf("err=%d, buff=%d\n", err, card1->buffer[0]);
> ...
> }
> ...
> }
>
>
>
> And here is the result of printf
> err=-32, buff=-1
-32 is EPIPE. it's likely buffer under/overrun.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
next prev parent reply other threads:[~2003-10-14 16:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-14 11:56 capture with non-interleaved mode Cyril.Coquilleau@UTBM.fr
2003-10-14 12:19 ` Paul Davis
2003-10-14 15:30 ` Cyril.Coquilleau@UTBM.fr
2003-10-14 16:05 ` Takashi Iwai [this message]
2003-10-15 19:09 ` Cyril.Coquilleau@UTBM.fr
2003-10-16 12:04 ` Paul Davis
-- strict thread matches above, loose matches on Subject: below --
2003-10-19 19:46 Cyril.Coquilleau@UTBM.fr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hn0c3u7mm.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=Cyril.Coquilleau@utbm.fr \
--cc=alsa-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox