jackaudio / jack2

jack2 codebase
GNU General Public License v2.0
2.22k stars 376 forks source link

Automatic samplerate selection is working bad? #279

Open MarioMey opened 7 years ago

MarioMey commented 7 years ago

I connected a Logitech C920 to Jack (48k, 1024frames, 3p) using: alsa_in -j webcam-mic -c 2 -d hw:C920 -v It sounds terribly bad and console says:

... WARNING: Rate doesn't match (requested 48000Hz, get 32000Hz) WARNING: buffer size does not match: (requested 2048, got 1365) WARNING: period size does not match: (requested 1024, got 682) ...

It seems that this mic doesn't support 48000, but 32000. Ok, if alsa_in selects automatically that samplerate... what about buffer size and period size? 1365? 682?

This does the trick alsa_in -j webcam-mic -c 2 -d hw:C920 -r 32000 -v By telling alsa_in to set samplerate to 32000, that warning messages disappears. Nothing about samplerate (it's ok, I told it to use 32000), but neither about buffer and period size.

Why this is happening? How do I know if device supports 2048 buffer size and 1024 period size that alsa_in requested? If this an alsa_in issue or device issue?

More info of this webcam mic.

mario@circo3d-md:~$ arecord --dump-hw-params -Dhw:C920 /dev/zero
Recording WAVE '/dev/zero' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:C920":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: [16000 32000]
PERIOD_TIME: [1000 8192000]
PERIOD_SIZE: [16 131072]
PERIOD_BYTES: [64 524288]
PERIODS: [2 1024]
BUFFER_TIME: [1000 16384000]
BUFFER_SIZE: [32 262144]
BUFFER_BYTES: [128 1048576]
TICK_TIME: ALL
--------------------
arecord: set_params:1299: Sample format non available
Available formats:
- S16_LE

Complete log of first command:

mario@circo3d-md:~$ alsa_in -j mic_webcam -d hw:C920 -v
Jack: JackClient::SetupDriverSync driver sem in flush mode
Jack: JackPosixSemaphore::Connect name = jack_sem.1000_default_mic_webcam
Jack: JackPosixSemaphore::Connect sem_getvalue 0
Jack: Clock source : system clock via clock_gettime
Jack: JackLibClient::Open name = mic_webcam refnum = 4
WARNING: Rate doesn't match (requested 44100Hz, get 32000Hz)
WARNING: buffer size does not match: (requested 2048, got 1486)
WARNING: period size does not match: (requested 1024, got 743)
selected sample format: 16bit
Jack: JackClient::PortRegister ref = 4 name = mic_webcam:capture_1 type = 32 bit float mono audio port_index = 11
Jack: JackClient::PortRegister ref = 4 name = mic_webcam:capture_2 type = 32 bit float mono audio port_index = 12
Jack: JackClient::Activate
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackClient::kBufferSizeCallback buffer_size = 1024
Jack: JackClient::Init : period = 23219 computation = 100 constraint = 23219
Jack: JackPosixThread::AcquireRealTimeImp priority = 93
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 2
Jack: JackClient::kActivateClient name = mic_webcam ref = 4 
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: WaitGraphChange...
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
delay = 3197
res: 1.378125,  diff = 0.000000,    offset = -70.000000 
res: 1.378125,  diff = 0.000000,    offset = -83.000000 
res: 1.378125,  diff = 0.000000,    offset = -164.000000 
^Cres: 1.378125,    diff = 0.000000,    offset = -139.000000 
Jack: JackClient::Deactivate
Jack: JackClient::Deactivate res = 0
Jack: JackPosixThread::Kill
Jack: jack_client_close
Jack: JackClient::Close ref = 4
Jack: JackClient::Deactivate
Jack: JackSocketClientChannel::Stop
Jack: JackPosixThread::Kill
Jack: JackClientSocket::Close
Jack: JackClientSocket::Close
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_mic_webcam
Jack: JackLibClient::~JackLibClient
Jack: JackShmReadWritePtr1::~JackShmReadWritePtr1 3
Jack: Succeeded in unlocking 422 byte memory area
Jack: JackLibGlobals Destroy 1a61f0c0
Jack: ~JackLibGlobals
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_system
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_freewheel
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_dbusapi
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_qjackctl
Jack: no message buffer overruns
Jack: JackPosixThread::Stop
Jack: JackPosixThread::ThreadHandler : exit
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 1
Jack: Succeeded in unlocking 1186 byte memory area
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 0
Jack: Succeeded in unlocking 82274202 byte memory area
Jack: jack_client_close res = 0
mario@circo3d-md:~$

Complete log with second command:

mario@circo3d-md:~$ alsa_in -j mic_webcam -d hw:C920 -r 32000 -p 1024 -v
Jack: JackClient::SetupDriverSync driver sem in flush mode
Jack: JackPosixSemaphore::Connect name = jack_sem.1000_default_mic_webcam
Jack: JackPosixSemaphore::Connect sem_getvalue 0
Jack: Clock source : system clock via clock_gettime
Jack: JackLibClient::Open name = mic_webcam refnum = 4
selected sample format: 16bit
Jack: JackClient::PortRegister ref = 4 name = mic_webcam:capture_1 type = 32 bit float mono audio port_index = 11
Jack: JackClient::PortRegister ref = 4 name = mic_webcam:capture_2 type = 32 bit float mono audio port_index = 12
Jack: JackClient::Activate
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackClient::kBufferSizeCallback buffer_size = 1024
Jack: JackClient::Init : period = 23219 computation = 100 constraint = 23219
Jack: JackPosixThread::AcquireRealTimeImp priority = 93
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 2
Jack: JackClient::kActivateClient name = mic_webcam ref = 4 
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: WaitGraphChange...
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
Jack: JackClient::ClientNotify ref = 4 name = mic_webcam notify = 18
delay = 3101
res: 1.378125,  diff = 0.000000,    offset = -38.000000 
res: 1.378125,  diff = 0.000000,    offset = -51.000000 
res: 1.378125,  diff = 0.000000,    offset = -100.000000 
res: 1.378125,  diff = 0.000000,    offset = -92.000000 
res: 1.378125,  diff = 0.000000,    offset = -75.000000 
res: 1.378125,  diff = 0.000000,    offset = -135.000000 
^Cres: 1.378325,    diff = -15.552336,  offset = -121.000000 
Jack: JackClient::Deactivate
Jack: JackClient::Deactivate res = 0
Jack: JackPosixThread::Kill
Jack: jack_client_close
Jack: JackClient::Close ref = 4
Jack: JackClient::Deactivate
Jack: JackSocketClientChannel::Stop
Jack: JackPosixThread::Kill
Jack: JackClientSocket::Close
Jack: JackClientSocket::Close
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_mic_webcam
Jack: JackLibClient::~JackLibClient
Jack: JackShmReadWritePtr1::~JackShmReadWritePtr1 3
Jack: Succeeded in unlocking 422 byte memory area
Jack: JackLibGlobals Destroy 463580c0
Jack: ~JackLibGlobals
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_system
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_freewheel
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_dbusapi
Jack: JackPosixSemaphore::Disconnect name = jack_sem.1000_default_qjackctl
Jack: no message buffer overruns
Jack: JackPosixThread::Stop
Jack: JackPosixThread::ThreadHandler : exit
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 1
Jack: Succeeded in unlocking 1186 byte memory area
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 0
Jack: Succeeded in unlocking 82274202 byte memory area
Jack: jack_client_close res = 0
mario@circo3d-md:~$
MarioMey commented 7 years ago

Debian-Mate 9, x64 Jack 1.9.11