From: Takashi Iwai <tiwai@suse.de>
To: Trent Reed <treed0803@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: SND_PCM_STREAM_CAPTURE and SND_PCM_NONBLOCK producing strange artifacts
Date: Tue, 05 Jul 2016 08:52:44 +0200 [thread overview]
Message-ID: <s5hmvlwpoeb.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAL6pMWqXvZk0ZSQ+rPNRxjA5h8QT6nU_-NT_Gqh2AMUwjRGqJQ@mail.gmail.com>
On Sat, 02 Jul 2016 23:58:28 +0200,
Trent Reed wrote:
>
> (Ping)
>
> I'm afraid I still don't understand why this is failing. I found that a
> call to sdn_pcm_wait() when -EAGAIN is returned fixes the problem because
> it waits for samples to be ready, but I don't understand why it is a
> problem in the first place. Much of the sample code is written in a way
> that suggests that the call to snd_pcm_wait() is optional, and only
> required when directly reading/writing from the device (MMAP, I'm not doing
> this).
>
> I'm just wondering what is wrong with basically looping over a call to
> snd_pcm_readi() in non-blocking mode, reacting to errors, and capturing
> frames. This produces awful static (which is basically garbage samples), is
> it a requirement that I call snd_pcm_wait() when -EAGAIN is passed back to
> wait for a full period to be ready?
Well, in the API level, it should work as you expected. So there must
be definitely some bug(s). But it's hard to spot out, as there are
several layers behind the scene.
As a first shot, try to reproduce without alsa-lib plugins, i.e. only
with "hw" PCM device, if not done yet. Also, it's interesting to see
whether it happens with or without mmap r/w.
Another point is whether it depends on the parameter. Did you try
48kHz instead of 44.1kHz?
Takashi
>
> Thanks,
> - Trent Reed
>
>
> On Tue, Jun 28, 2016 at 7:27 PM, Trent Reed <treed0803@gmail.com> wrote:
>
> > Hey All,
> >
> > I've been banging my head against the wall for about a week on this bug.
> > The following gist shows my sample reproduction code:
> > https://gist.github.com/TReed0803/985c5d5c3d295245e19006a27be447c3
> >
> > I'm simply opening up a non-blocking PCM capture stream and writing the
> > contents of the reads to stdout.
> > (Originally, I was writing to the playback stream, but I was hearing this
> > strange static occasionally!)
> >
> > It's the static I'm trying to debug. It doesn't happen every time. In
> > fact, sometimes I'll go a few consecutive executions without hearing it.
> > I was able to capture some of the bad data, and I loaded it up in Audacity
> > for visualization:
> >
> > https://drive.google.com/file/d/0B-1aumGKQcQTcUJoZzIwRWhYSFE/view?usp=sharing
> >
> > It looks like the internal buffer occasionally is sending me more data
> > than it actually captured, and I end up either reading old PCM data from
> > the internal ring buffer, or (at the very beginning) a bunch of zeros.
> >
> > Can anyone help me understand what is going on? What could cause these
> > definitely incorrect samples to be recorded? (I get the same effect
> > regardless of hardware, but I will list hardware just in case.)
> >
> > I hope I have all the information you might need:
> > Hardware: Samson Meteor Mic (USB-Audio, USB Mixer) [Though, it even
> > happens with my built-in microphone]
> > ALSA version: Advanced Linux Sound Architecture Driver Version
> > k4.4.0-28-generic.
> > apt-cache policy (installed alsa-lib version): 1.1.0-0ubuntu1
> >
> > Thanks,
> > - Trent Reed
> >
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
next prev parent reply other threads:[~2016-07-05 6:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 2:27 SND_PCM_STREAM_CAPTURE and SND_PCM_NONBLOCK producing strange artifacts Trent Reed
2016-07-02 21:58 ` Trent Reed
2016-07-05 6:52 ` Takashi Iwai [this message]
[not found] ` <CAL6pMWpwpgLBmqEhDnqKPvQPYmnSy1S=19m6YL=5YMpHQRfLtw@mail.gmail.com>
2016-07-05 7:38 ` Takashi Iwai
2016-07-05 8:46 ` Trent Reed
2016-08-06 19:13 ` Trent Reed
2016-08-11 14:32 ` Takashi Iwai
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=s5hmvlwpoeb.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=treed0803@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.