Skip to content
New issue

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

Sine example fails #9

Open
nnmm opened this issue Feb 18, 2017 · 9 comments
Open

Sine example fails #9

nnmm opened this issue Feb 18, 2017 · 9 comments

Comments

@nnmm
Copy link

nnmm commented Feb 18, 2017

The sine example produces only glitchy stuttering for me and appears to crash. Console output:

2 backends available.
Connected to backend: ALSA
ALSA lib pcm_dmix.c:968:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:545:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dsnoop.c:545:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
Using output device: Playback/recording through the PulseAudio sound server
Output format: float 32-bit LE
Sample rate: 48000
err: unrecoverable streaming failure
Output channel layout: Stereo
Pause for 1s
Unpausing
sine: [...]/rsoundio/target/debug/build/rsoundio-4469f7eb07188f71/out/libsoundio-1.1.0/src/soundio.c:394: soundio_device_unref: Assertion `device->ref_count >= 0' failed.

You can see that I inserted a print statement to see the number of available backends, but other than ALSA, it's just the Dummy. I also tried changing the SioFormat to Float64LE, but that didn't work.

Libsoundio's sio_sine test runs fine and sounds clear. It also reports a different backend that's not available in rsoundio:

Backend: PulseAudio
Output device: Built-in Audio Analog Stereo
Software latency: 2.000000

uname -a is Linux [computer name] 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux and the rustc version is 1.15.1 (021bd294c 2017-02-08)

I'm new to audio programming, so I hope this is helpful and not just a simple mistake on my side. If this issue is missing any information, I'm happy to clarify.

@klingtnet
Copy link
Owner

Thanks for opening the issue, there is a problem with the PulseAudio backend but I haven't found the problem, yet. See #7 for details.

@klingtnet
Copy link
Owner

Oops, looks like ALSA is broken, too. Can you try JACK?
I've used rsoundio with JACK and it works fine.

@nnmm
Copy link
Author

nnmm commented Feb 18, 2017

Thanks for your quick response! So, I installed JACK (apt install jackd):

The following additional packages will be installed:
  jackd2 jackd2-firewire libconfig++9v5 libffado2 libjack-jackd2-0 libxml++2.6-2v5
  python-dbus python-gi qjackctl
Suggested packages:
  jack-tools meterbridge python-dbus-doc python-dbus-dbg python-gi-cairo
The following packages will be REMOVED:
  libjack-dev libjack0 librtaudio-dev
The following NEW packages will be installed:
  jackd jackd2 jackd2-firewire libconfig++9v5 libffado2 libjack-jackd2-0
  libxml++2.6-2v5 python-dbus python-gi qjackctl

This caused another backend to be available in rsoundio, but it was PulseAudio, not JACK. I'm pretty confused as to why. PulseAudio actually produces a sine tone. It does have some crackling, unlike sio_sine, and the crackling gets a lot worse with --release turned on. The crash at the end still happens with PulseAudio.

JACK on the other hand didn't show up in sio_sine nor rsoundio. What I did was start qtjackctl and press start, which spins up three jackdbus processes and blocks all other sound drivers.

As an aside: I thought maybe I have to rebuild libsoundio for JACK to be recognized by it, but JACK is also not found by the libsoundio CMake script:

System Dependencies
-------------------
* threads                      : OK
* JACK       (optional)        : not found
* PulseAudio (optional)        : OK
* ALSA       (optional)        : OK
* CoreAudio  (optional)        : not found
* WASAPI     (optional)        : not found

@nnmm
Copy link
Author

nnmm commented Feb 18, 2017

The libjack-jackd2-dev package was what was missing for libsoundio to compile with JACK; playing a sine with ./sio_sine --backend jack works now. Still, only PulseAudio, ALSA and Dummy show up in rsoundio, even after cargo clean.

@klingtnet
Copy link
Owner

klingtnet commented Feb 19, 2017

rsoundio links against a system libsoundio installation and if none was found it builds one.
The sole purpose of the build.rs was to have libsoundio available in my CI integration container. It builds libsoundio in debug mode and w/o JACK and PulseAudio because the CI server has no sound device and only uses the dummy interface.

You can try to change the CMake flags in build.rs or to build and install libsoundio system-wide (at least for Arch Linux there is a package).

@nnmm
Copy link
Author

nnmm commented Feb 19, 2017

You're right, I needed to do sudo make install.after rebuilding libsoundio with JACK. JACK works fine in rsoundio, no popping or crackling. The failed assertion, however, is still there.

By the way, my problem with PulseAudio is not identical to the one in #7, for me it's just crackling, although both might of course have a common cause. ALSA also has different symptoms.

@klingtnet
Copy link
Owner

klingtnet commented Feb 19, 2017

I would love to fix this issue, actually I planned to do for quite some time, but I am quite busy with work and other things.
Nonetheless, I have this issue on my radar and will fix it sooner or later.

@nnmm
Copy link
Author

nnmm commented Feb 21, 2017

I understand, I am in a similar position or I would try looking into it myself.

@klingtnet
Copy link
Owner

klingtnet commented Feb 21, 2017

Great, don't hesitate to ask if you've any questions.
There are also a lot of thinks to improve, e.g. there are still some memory allocations in the write callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants