All of lore.kernel.org
 help / color / mirror / Atom feed
* plughw behaviour not consistent with hw
@ 2018-11-01  4:44 Stefano Antonelli
  2018-11-06  7:52 ` Takashi Sakamoto
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Antonelli @ 2018-11-01  4:44 UTC (permalink / raw)
  To: alsa-devel

Hello list,

I'm working on an application that requires a period time of 10ms.  The
hardware at the other end of the bus is a ulaw codec running at 8kHz.
 The application runs at 16kHz S16_LE and I was hoping to use the
plughw device to do sample rate conversion and ulaw encode/decode.
 This way the application doesn't need to change to accommodate this
ulaw codec.  However, it's not working and I don't know how to go about
debugging.  I'm hoping I can get some pointers here.

The problem is best illustrated by this output, first using plughw:
alsa_read: 10
alsa_read: 20
alsa_read: 0
alsa_read: 20
alsa_read: 0
alsa_read: 20
alsa_read: 0
alsa_read: 20
alsa_read: 0
alsa_read: 20

It would appear that plughw gives the correct period time on the first
call, but then subsequently buffers 2 periods before returning.  
Using hw with matching sample rate, sample format, and number of
samples:
alsa_read: 10
alsa_read: 10
alsa_read: 10
alsa_read: 10
alsa_read: 10
alsa_r
ead: 10
alsa_read: 10
alsa_read: 10
alsa_read: 10
alsa_read: 10

This code snippet generated the above output:

for (i = 0; i < 10; ++i) {
        gettimeofday(&time1, NULL);
	err = snd_pcm_readi (capture_handle, buf, NSMP); 
        if (err != NSMP) {
                printf ("read from audio interface failed "
                        " (%s)\n", snd_strerror (err));
                exit (1);
        }
        gettimeofday(&time2, NULL);
        printf("alsa_read: %d\n", getTimeDiff(time1, time2));
}

I have tried using the patch from here (without the environment
variable switch):

http://mailman.alsa-project.org/pipermail/alsa-devel/2008-October/01170
3.html

to print out the configuration of plughw's plugin chain, but it
generates no output.  I've verified the md5sum of the library after
compilation and it matches the one I compiled.  And I ran ldconfig
after replacing libasound.so.  So I don't know what's going on there.
 I definitely call snd_pcm_hw_params() when setting up the capture
device.  This is using alsa-lib-1.0.25.

Does anyone know why plughw might be acting the way it is and how I can
get it to deliver 10ms periods?  Equally appreciated would be any tips
on how to debug this problem.

Thanks,
Stef

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-06  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  4:44 plughw behaviour not consistent with hw Stefano Antonelli
2018-11-06  7:52 ` Takashi Sakamoto

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.