[alsa-devel] Measuring Device Throughput - MMAP vs. RW
Pavel Hofman
pavhofman at gmail.com
Tue Sep 10 21:27:15 CEST 2019
On Tue, Sep 10, 2019 at 9:48 AM Pavel Hofman <pavhofman at gmail.com> wrote:
> Thanks. IIUC, if I call snd_pcm_status() in that mmap_commit method, get
> data between e.g. 10 seconds, and divide the increase of status._ptr
> https://github.com/michaelwu/alsa-lib/blob/afb2fbd0e554e42e51325c3197a176ea96a74203/include/sound/asound.h#L422
> by increase of status.tstamp, I should get the the most precise available
> soundcard rate estimate referenced to system time.
>
>
Upon hard-coding params->tstamp_mode = SND_PCM_TSTAMP_ENABLE in
snd_pcm_hw_sw_params, the snd_pcm_hw_status method started returning hw_ptr
and tstamp. The variance of the rate calculated by these values is
perfectly acceptable for my purpose, I will use this method. 10 sec
averages of the previously "jittery" mmap arecord:
STATUS MMAP: time: 6679.12, card = 1, device = 0, averaged samplerate:
191995.485933
STATUS MMAP: time: 6689.14, card = 1, device = 0, averaged samplerate:
191995.833616
STATUS MMAP: time: 6699.17, card = 1, device = 0, averaged samplerate:
191995.589371
STATUS MMAP: time: 6709.20, card = 1, device = 0, averaged samplerate:
191995.647669
STATUS MMAP: time: 6719.22, card = 1, device = 0, averaged samplerate:
191995.740024
STATUS MMAP: time: 6729.25, card = 1, device = 0, averaged samplerate:
191995.709675
STATUS MMAP: time: 6739.28, card = 1, device = 0, averaged samplerate:
191995.588850
STATUS MMAP: time: 6749.30, card = 1, device = 0, averaged samplerate:
191995.706994
STATUS MMAP: time: 6759.33, card = 1, device = 0, averaged samplerate:
191995.641393
STATUS MMAP: time: 6769.36, card = 1, device = 0, averaged samplerate:
191995.530104
STATUS MMAP: time: 6779.38, card = 1, device = 0, averaged samplerate:
191995.764419
Do you think there is any chance a code generating the average throughput
into some file identified with card/device IDs, all of that enabled by some
environment variable, would be acceptable into upstream pcm_hw.c? It will
be a key part of the working async usb gadget. The current version
https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/function/f_uac2.c
does not comply with USB-audio v. 2 specs due to the missing async feedback
endpoint, and works only for the adaptive mode (requires resampling).
Thanks,
Pavel.
> Thanks.
>
> Pavel.
>
More information about the Alsa-devel
mailing list