Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML Audio is broken in Ubuntu 20  (Read 9237 times)

0 Members and 1 Guest are viewing this topic.

laser_beamer

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML Audio is broken in Ubuntu 20
« on: September 26, 2021, 05:48:53 pm »
It seems in Ubuntu 20, the sound is broken.

Even something has simple as:

#include "Sound.hpp"

int main()
{
    Sound sound("sound.wav");
    sound.play();

    return 0;
}

Gives an error that starts with:

ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': Device or resource busy
Failed to open the audio device

And you get the same error using Music

This error happens sometimes and sometimes it doesn't. Upon research it has to do with OpenAL using alsa and apparently alsa can now only be used by 1 device at at time, so if someone alsa is already being used, the device is busy.

At times I was able to fix this error by finding the process using alsa by using:

        fuser -v /dev/snd/*

as per this link: https://stackoverflow.com/questions/526132/finding-processes-using-alsa-sound-fast
and then running `kill -9 <process-id>` on the process id found.

That did work, until it didn't.

I also tried to switch OpenAL to use pulse instead of alsa, by setting drivers=pulse in /etc/openal/alsoft.conf
as per this link: https://www.reddit.com/r/linuxaudio/comments/d8mxpi/psa_force_openal_to_use_pulseaudio_when_gaming_on/

It didn't work, in fact it changed the error to start with:

Failed to open the audio device
An internal OpenAL call failed in SoundBuffer.cpp(46).
Expression:
   alGenBuffers(1, &m_buffer)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

so drivers=pulse is a device that can't be opened? Or it doesn't recognize it?

So I changed that back.

I also had found another solution that involved using jack instead of alsa, which worked a couple days ago, then it stopped working too. Although I forget where the website for those instructions were.

Why does this sound system have to suddenly break just because I am using Ubuntu 20? Why can't SFML have some way of making sure the audio works in any environment? This is not an error that is supposed to be. This error is not my bug, it's just because people try to make things not work cohesively together.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Audio is broken in Ubuntu 20
« Reply #1 on: September 27, 2021, 08:11:13 am »
Hi

You've put a lot of effort into debugging your problem, that's nice. Unfortunately, this is an issue between OpenAL and the underlying audio driver, there's probably nothing much that we can do at the SFML level.

What you could do, is try a simple program or example that directly uses OpenAL, to see if the issue persists.

If it does, then you'd better ask OpenAL people for support. If not, then there might be something to do in SFML  ;)
Laurent Gomila - SFML developer