Alsa buffer size max как изменить
Перейти к содержимому

Alsa buffer size max как изменить

  • автор:

arch, alsa, нет звука на displayPort’е

сейчас по новой накатил рач, и вот что имею (c воткнутым displayPort’ом):

$ aplay -L null Discard all samples (playback) or generate zero samples (capture) default:CARD=PCH HDA Intel PCH, ALC887-VD Analog Default Audio Device sysdefault:CARD=PCH HDA Intel PCH, ALC887-VD Analog Default Audio Device front:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog Front output / input surround21:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 2.1 Surround output to Front and Subwoofer speakers surround40:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 4.0 Surround output to Front and Rear speakers surround41:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=PCH,DEV=0 HDA Intel PCH, ALC887-VD Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers hdmi:CARD=HDMI,DEV=0 HDA ATI HDMI, HDMI 0 HDMI Audio Output hdmi:CARD=HDMI,DEV=1 HDA ATI HDMI, HDMI 1 HDMI Audio Output hdmi:CARD=HDMI,DEV=2 HDA ATI HDMI, HDMI 2 HDMI Audio Output hdmi:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 3 HDMI Audio Output hdmi:CARD=HDMI,DEV=4 HDA ATI HDMI, HDMI 4 HDMI Audio Output 
$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 9: HDMI 3 [HDMI 3] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 10: HDMI 4 [HDMI 4] Subdevices: 1/1 Subdevice #0: subdevice #0 

/etc/asound.conf — нету ~/.asound.conf — тоже

в alsamixer’е, что странно, при смене аудиокарты на default:1 HDA ATI HDMI (второй выбор — default:0 Realtec ALC887-VD) столбики неактивны. Ну т.е. совсем. По умолчанию они были замутены, но после unmute’а по центру просто OO в квадратиках. Выше должны быть столбики, но их нет

ещё что-то не так со speaker-test’ом. Говорит, что память выделить не может

$ speaker-test -c2 -Dhdmi:CARD=HDMI,DEV=0 speaker-test 1.2.5.1 Playback device is hdmi:CARD=HDMI,DEV=0 Stream parameters are 48000Hz, S16_LE, 2 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 64 to 8544000 Period size range from 32 to 4272000 Using max buffer size 8544000 Periods = 4 Unable to set hw params for playback: Cannot allocate memory Setting of hwparams failed: Cannot allocate memory 

видюха у меня rx460, с дровами не колдовал, ставился по минимуму

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

RustAudio / cpal Public

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reviewing and deciding upon a default buffer size strategy for ALSA #446

mitchmindtree opened this issue Jul 14, 2020 · 3 comments

Reviewing and deciding upon a default buffer size strategy for ALSA #446

mitchmindtree opened this issue Jul 14, 2020 · 3 comments

Comments

mitchmindtree commented Jul 14, 2020

#401 finally allows users to specify a fixed buffer size, allowing some control over the trade-off between energy efficiency and low latency.

The BufferSize::Default value allows the user to fallback to whatever the default buffer is provided by the host. However, ALSA is a bit of a special case in that the default size can be extreme, sometimes implying a delay from multiple seconds up to a minute — an impractical delay for the majority of applications. As a temporary workaround, #401 has opted to leave the BufferSize::Default branch to select a ~100ms delay to match what was previously hard-coded. I’ve opened this issue so that we can discuss a more suitable default strategy for ALSA.

See here and here for prior discussion on potential strategies. Of note, @sniperrifle2004 made the following suggestion:

As an alternative suggestion to the lowish 100ms aplay does this by default: Get the maximum buffer time. Cap it at half a second. Then restrict the period time to near a quarter of this buffer time (It’s where I got that metric from. aplay has been immensely useful as both a reference implementation and a tool) and then restrict the buffer time to near the chosen value.

The text was updated successfully, but these errors were encountered:

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting an ALSA audio buffer with 1024 bytes fails #1252

vanfanel opened this issue Jan 6, 2016 · 8 comments

Setting an ALSA audio buffer with 1024 bytes fails #1252

vanfanel opened this issue Jan 6, 2016 · 8 comments

Comments

vanfanel commented Jan 6, 2016

While trying to code an audio program that needs to have near no delay, I found out that I can’t setup ALSA to use an audio buffer with a size of 1024 bytes on the Raspberry Pi.
It seems like a small enough buffer, but for a 44100 Hz, 16 bit, stereo stream, a 2048 bytes buffer would cause a delay of:
2048 buffer size / (44100 frames per second * 4 bytes per frame) = 11.6 ms, which is pretty high for realtime audio. 1024 bytes would cause a more acceptabe ~6 ms delay.

This is the failing code: it works on my desktop PC using stock Ubuntu kernel:

#define SOUND_SAMPLERATE 44100 int alsa_init () < snd_pcm_t *pcm_handle; snd_pcm_hw_params_t *hwparams = NULL; snd_pcm_uframes_t buffer_size_frames; snd_pcm_uframes_t period_size_frames; size_t buffer_size_bytes; size_t period_size_bytes; const char *alsa_dev = strdup("plughw:0,0"); snd_pcm_open(&pcm_handle, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0); snd_pcm_hw_params_malloc(&hwparams); int periodsize = 512; int periods = 2; if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) < fprintf(stderr, "Can not configure this PCM device.\n"); return(-1); >if (snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) < fprintf(stderr, "Error setting access.\n"); return(-1); >if (snd_pcm_hw_params_set_format(pcm_handle, hwparams, SND_PCM_FORMAT_S16_LE) < 0) < fprintf(stderr, "Error setting format.\n"); return(-1); >int exact_rate = SOUND_SAMPLERATE; if (snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &exact_rate, 0) < 0) < fprintf(stderr, "Error setting rate.\n"); return(-1); >if (SOUND_SAMPLERATE != exact_rate) < fprintf(stderr, "The rate %d Hz is not supported by your hardware. Using %d Hz instead.\n", SOUND_SAMPLERATE, exact_rate); >if (snd_pcm_hw_params_set_channels(pcm_handle, hwparams, 2) < 0) < fprintf(stderr, "Error setting channels.\n"); return(-1); >if (snd_pcm_hw_params_set_periods(pcm_handle, hwparams, periods , 0) < 0) < fprintf(stderr, "Error setting periods.\n"); return(-1); >if (snd_pcm_hw_params_set_buffer_size(pcm_handle, hwparams, (periodsize * periods)>>2) < 0) < fprintf(stderr, "Error setting buffersize.\n"); return(-1); >if (snd_pcm_hw_params(pcm_handle, hwparams) < 0) < fprintf(stderr, "Error setting HW params.\n"); return(-1); >> 

It’s failing on snd_pcm_hw_params_set_buffer_size() with a buffersize of 1024 bytes (512 bytes periodsize * 2 periods),while it works fine on my Ubuntu X86 workstation.
I am using the stock Raspbian kernel. I could build my own kernel if it would help.
Any idea on how to overcome this? Or is this a hardware limit?

The text was updated successfully, but these errors were encountered:

Does ALSA buffer size have a hardware-defined upper limit?

I have a Raspberry Pi with an i2s MEMS mic attached. I’m recording audio from it, using the SOX library, and trying to increase my ALSA buffer_size. My ALSA buffer_size is currently 65536, but I want to increase this. Is there any theoretical limit to the buffer size? How large can it be? Thanks!

user2989813
asked Mar 24, 2017 at 21:14
user2989813 user2989813
283 1 1 gold badge 5 5 silver badges 16 16 bronze badges

1 Answer 1

The theoretical limit is 2^32 frames. But the practical limit is whatever your hardware actually supports.

To read the current maximum buffer size, call snd_pcm_hw_params_get_buffer_size_max() («current» because it might be constrained by other hardware parameters, such as the sample rate or number of channels).

answered Mar 24, 2017 at 21:37
175k 17 17 gold badges 219 219 silver badges 261 261 bronze badges

  • audio
  • raspberry-pi
  • mp3
  • alsa
    The Overflow Blog
Related
Hot Network Questions

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.10.27.43697

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *