question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SDL2 audio provider is not working in some Linux distributions.

See original GitHub issue

Versions

  • Python: 3.7
  • Kivy: 1.11.1
  • Kivy installation method: pip
  • OS: reported by users in Ubuntu 18.04, Xubuntu 19.04, Debian.

Description

I’ve seen some issue reports (for example, https://github.com/kivy/kivy/issues/6536 and https://github.com/kivy/kivy/issues/6512) that cannot reproduce audio using SDL2. It was also reported with ffpyplayer, but seems to be patched in the latest release (see https://github.com/matham/ffpyplayer/issues/71#issuecomment-554074454).

I’ve been trying different things to make it work, and finally I realised that the problem is the way the wheel is built in pip. If you try to install with pip install https://github.com/kivy/kivy/archive/stable.zip (or with the dev branch) and sdl2 installed, it works because pip builds a fresh wheel. It is not really neccesary to download and compile sdl2 from the web, it is enough to install the sdl2 package from distro repositories.

Code and Logs

Example:

import os

os.environ["KIVY_AUDIO"] = "sdl2"

from kivy.core.audio import SoundLoader

sound = SoundLoader.load('mytest.wav')
if sound:
    print("Sound found at %s" % sound.source)
    print("Sound is %.3f seconds" % sound.length)
    sound.play()

where mytest.wav is any audio file supported by SDL2.

Please, make sure that you see something like:

[INFO   ] [Audio       ] Providers: audio_sdl2

in your log, to ensure that audio_sdl2 is installed and being used.

If you try and have the same issue I’m reporting, you should see something like this:

[CRITICAL] [AudioSDL2   ] Unable to open mixer: b'No such audio device'
[WARNING] Deprecated property "<AliasProperty name=filename>" of object "<kivy.core.audio.audio_sdl2.SoundSDL2>" was accessed, it will be removed in a future version
[WARNING] [AudioSDL2   ] Unable to load (...): b"Audio device hasn't been opened"

If you need help with testing or something, just tell me.

Greetings.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
albertascommented, Dec 8, 2019

Was getting the same error on Ubuntu 18.04. Reinstalled kivy using your suggested way:

pip install https://github.com/kivy/kivy/archive/stable.zip

And the problem is gone. Thank your @Franccisco.

0reactions
pablojimenezmateocommented, Apr 28, 2020

Was getting the same error on Ubuntu 18.04. Reinstalled kivy using your suggested way:

pip install https://github.com/kivy/kivy/archive/stable.zip

And the problem is gone. Thank your @Franccisco.

I’m having the same issue and this did not fix my problem, I’m still getting the same output. I’m in Ubuntu 18.04.

Following @johnlawrenceaspden instructions the audio works but just for a fraction of a second, the output seems fine:

[INFO   ] [SoundFFPy   ] Using ffpyplayer 4.3.2.dev0
[INFO   ] [Audio       ] Providers: audio_ffpyplayer, audio_sdl2 
xclip version 0.12
Copyright (C) 2001-2008 Kim Saunders et al.
Distributed under the terms of the GNU GPL
[INFO   ] [Clipboard   ] Provider: xclip
[INFO   ] [CutBuffer   ] cut buffer support enabled
[INFO   ] [GL          ] NPOT texture support is available
[WARNING] Deprecated property "<AliasProperty name=filename>" of object "<kivy.core.audio.audio_sdl2.SoundSDL2 object at 0x7fcebf69b2f0>" was accessed, it will be removed in a future version
Sound found at /home/gef/Documents/Hobbes-many/kivy/media/audio/rain.wav
Sound is 300.404 seconds
Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
SDL2 audio provider is not working in some Linux distributions.
Read more >
Couldn't open audio device: No available audio device
I am running Ubuntu 11.04. I have been using SDL for OpenGL for a while now without any problems, but when I recently...
Read more >
Installing Kivy — Kivy 2.1.0 documentation
sdl2 ==x.y.z , you can now do pip install "kivy[sdl2]" to automatically install the correct sdl2 for the Kivy version). gstreamer : The...
Read more >
sdl C/C++ Package - JFrog ConanCenter - Conan.io
audio. graphics. keyboard. opengl. sdl2. Zlib. License. 2.26.0. Version. 4,233. Downloads ... See https://github.com/bincrafters/community/issues/696.
Read more >
Linux - Wikipedia
Linux ; Developer, Community contributors, Linus Torvalds ; Written in · C, assembly languages, and others ; OS family, Unix-like ; Working state,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found