jackaudio / jack1

jack1 codebase
Other
250 stars 71 forks source link

jackd does not report the final configured rate correctly for alsa device #53

Closed tomty89 closed 6 years ago

tomty89 commented 7 years ago

So I have a USB audio class device that supports only 16Bit/48KHz signal. I confirmed that by checking the hardware parameters with aplay -l. Windows also told me so.

HW Params of device "hw:W2":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: [1000 2730667)
PERIOD_SIZE: [48 131072]
PERIOD_BYTES: [192 524288]
PERIODS: [2 1024]
BUFFER_TIME: [2000 5461334)
BUFFER_SIZE: [96 262144]
BUFFER_BYTES: [384 1048576]
TICK_TIME: ALL
--------------------

When I start jackd on it with -r 44100, neither does it tell me that this rate can't be used with that device, nor does it report back the fact that it started the device with the only supported rate (48000):

[tom@localhost ~]$ jackd -d alsa -d hw:W2 -r 44100 -P
jackd 0.125.0
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

JACK compiled with System V SHM support.
loading driver ..
apparent rate = 44100
creating alsa driver ... hw:W2|-|1024|2|44100|0|0|nomon|swmeter|-|32bit
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback

I once thought that maybe jack use libsamplerate or zita-resampler to resample the mix before sending it off to the device. But I read from an old issue that jack does not do that. Finally mpv showed me that I was wrong:

[cplayer] Starting playback...
[af] Audio filter chain:
[af]   [in] 44100Hz stereo 2ch floatp
[af]   [out] 44100Hz stereo 2ch floatp
[af]   [ao] 44100Hz stereo 2ch floatp
[ao] Trying audio driver 'jack'
[ao/jack] requested format: 44100 Hz, stereo channels, floatp
[ao/jack] Channel layouts:
[ao/jack]  - waveext
[ao/jack] result: stereo
[ao/jack] using soft-buffer of 9600 samples.
[cplayer] AO: [jack] 48000Hz stereo 2ch floatp
[cplayer] AO: Description: JACK audio output
[af] Adding filter lavrresample 
[af] Audio filter chain:
[af]   [in] 44100Hz stereo 2ch floatp
[af]   [lavrresample] 48000Hz stereo 2ch floatp [a]
[af]   [out] 48000Hz stereo 2ch floatp
[af]   [ao] 48000Hz stereo 2ch floatp
[cplayer] starting audio playback
[cplayer] playback restart complete

So jackd did open the device with the rate 48000. It just didn't tell me that.