PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.45k stars 303 forks source link

portaudio broken between 2011 and 2014, not seeing devices on ALSA #524

Open ukisensei opened 3 years ago

ukisensei commented 3 years ago

My setup:

Issue/ Observation:

  1. Audacity not see cs46xx devices (only onboard USB sound & vup/ downmix devices). On startup (in txt console) following error shows up, multiple times: "Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 924"
  2. But ALSA tools, and Ardour see cs46xx, and they are able to capture/ output sound. but: only with period_size setting to "512".

Research/ Results: After, successlessly, having tried to configure period_size parm per ALSA config space, I followd a different approach: I swapped the libportaudio versions, and that worked around this issue:

Conclusion/ pending...: Seems, something has broken on the way from portaudio svn2011XXX up to => 2014XXX regarding the handling of devices which not support period_size >512

Cu

philburk commented 3 years ago

Thanks for the report.

ALSA v1.1.7 seems to have come out in October 2018. https://www.alsa-project.org/wiki/Detailed_changes_v1.1.6_v1.1.7

ALSA v1.1.8 seems to have come out in January 2019. https://www.alsa-project.org/wiki/Detailed_changes_v1.1.7_v1.1.8

ukisensei commented 3 years ago

Hello philburk,

thanks for your attention and putting the post title more precise. However, the mentioned behaviour I do notice from portaudio version 19+svn2014XXX, as noted above, not from v19.6 only, and the latter I think is a later version, is it.

I also followed the two ALSA changelog links you kindly provided, unfortunately, they do not mention any "period_size" regarding change.

Regards

xyzzy42 commented 3 years ago

It's probably related to commit 28f9ee09658dc7 from 2013. This change the probe code to also try to set a period size instead of just a buffer size. Since setting the period size is what fails it probably worked before this.

But this seems like bug in the ALSA driver. I looked at the driver, and if CONFIG_SND_CS46XX_NEW_DSP is set it should allow power of two period sizes in bytes between 32 and 2048, so should accept PA's size. If that config option is not enabled, it will only allow a size of 2048 bytes. But it should still work I would think, returning period sizeof 2048 bytes as nearest to PA's request of 128 frames.

Check if CONFIG_SND_CS46XX_NEW_DSP is defined in your kernel build. It will probably work better if it is.

RossBencina commented 2 years ago

We need more information on how widespread this is. Can anyone else reproduce this issue?