We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4780 - failed SDL_OpenAudioDevice and SDL_GetAudioDeviceName with plain ALSA
Summary: failed SDL_OpenAudioDevice and SDL_GetAudioDeviceName with plain ALSA
Status: RESOLVED WORKSFORME
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.12
Depends on:
Blocks:
 
Reported: 2019-08-30 18:43 UTC by Balashoff Vadim
Modified: 2019-10-27 04:02 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Balashoff Vadim 2019-08-30 18:43:25 UTC
I have Gentoo x86_64. There are external USB soundcard E-MU 0404. I have NO pulseaudio at all. I use .asoundrc and set there pcm.usb_dmix and so on.

Mplayer works fine. Almost all games works fine. There are some Unity games though, where are missing sounds.
And I have no sound in UnrealEngine4 Editor at all.
Exploring sources I figured out that the problem with two functions: SDL_OpenAudioDevice and SDL_GetAudioDeviceName.

Both of them are failed.

for example, I've tried to compile this code
https://wiki.libsdl.org/SDL_OpenAudio
I get this in console:
INFO: Failed to open audio:


My system info:
------
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: USB [E-MU 0404 | USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: USB [E-MU 0404 | USB], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
-----
Comment 1 Ryan C. Gordon 2019-09-02 04:23:16 UTC
Right before the call to SDL_OpenAudio(), can you put this:


printf("audio driver is %s\n", SDL_GetCurrentAudioDriver());


And see what it reports? It's weird that the ALSA driver didn't actually report an error message when failing, and I just want to make sure you didn't end up somewhere else by accident.

--ryan.
Comment 2 Balashoff Vadim 2019-09-02 08:39:45 UTC
> printf("audio driver is %s\n", SDL_GetCurrentAudioDriver());

audio driver is (null)
Error opening audio device: 

I've test it on two different computers: Core i7 (one integrated soundcard) and Z440 (two soundcards). Same output on both of them.
On both of computers mplayer and many games play sound fine (many of games use SDL as output).
Comment 3 Ryan C. Gordon 2019-09-04 04:28:29 UTC
> audio driver is (null)

Did you call SDL_Init(SDL_INIT_AUDIO) at the start of your program? The example code at the wiki doesn't either, although it's meant to be just a snippet and not a complete program.

--ryan.
Comment 4 Balashoff Vadim 2019-09-04 05:08:15 UTC
> Did you call SDL_Init(SDL_INIT_AUDIO) at the start of your program?

Following code output empty line.

#include <SDL2/SDL.h>
#include <iostream>

int main()
{
        SDL_Init( SDL_INIT_EVERYTHING );
        std::cout << SDL_GetError() << std::endl;
        atexit( SDL_Quit );
        int count = SDL_GetNumAudioDevices(0);
        for (int i = 0; i < count; ++i)
        {
                std::cout << "Device " << i << ": " << SDL_GetAudioDeviceName(i, 0) << std::endl;
        }
        return 0;
}
Comment 5 Lomax 2019-09-11 21:52:51 UTC
I believe myself to also be affected by this bug; I get "Unable to open mixer: 'No such audio device'" on two separate systems when trying to use SDL2_mixer, neither of which have Pulseaudio installed. Other applications using the audio hardware through ALSA work perfectly fine, though I cannot say anything about other software using SDL2 - I'm not sure I have any installed.
Comment 6 Lomax 2019-09-13 21:36:27 UTC
> I believe myself to also be affected by this bug

I was wrong; I had just misconfigured my build. SDL2-2.0.10 works fine with the ALSA driver and a USB soundcard for me.
Comment 7 Ryan C. Gordon 2019-09-20 20:47:34 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 8 Ryan C. Gordon 2019-09-20 20:48:41 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 9 Ryan C. Gordon 2019-10-16 17:26:15 UTC
Honestly, I suspect the original report was due to an SDL accidentally build without ALSA support.

Balashoff, if you're inclined, if you rebuild SDL from scratch, the configure script should write something like this at the end of its run:


    Audio drivers   : disk dummy [...] alsa(dynamic)


Somewhere on that line it should say "alsa" or "alsa(dynamic)" if SDL is built with ALSA support.

(if you didn't build SDL from scratch, let's figure out where it got built, too.)

--ryan.
Comment 10 Ryan C. Gordon 2019-10-27 04:02:02 UTC
Resolving this bug as WORKSFORME. If you are still having this problem, please check my comments about making sure ALSA support was built into SDL, and if necessary, please reopen this bug!

Thanks,
--ryan.