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

SDL2 audio provider is not working in some Linux distributions. #6601

Open
ghost opened this issue Nov 17, 2019 · 5 comments
Open

SDL2 audio provider is not working in some Linux distributions. #6601

ghost opened this issue Nov 17, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 17, 2019

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, #6536 and #6512) that cannot reproduce audio using SDL2. It was also reported with ffpyplayer, but seems to be patched in the latest release (see matham/ffpyplayer#71 (comment)).

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.

@albertas
Copy link

albertas commented 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.

@matham
Copy link
Member

matham commented Dec 9, 2019

Unfortunately, for ffpyplayer, I was unable to get sdl2 mixer to work for manylinux wheels. Only when I removed mixer and used sdl2 alone, did audio start working again.

It probably can be figured out by compiling mixer and its deps from source on centos and figuring out which .so are the problem and how to provide the correct ones. But it would take a very long time to do that - I spent some time for ffpyplayer and couldn't work it out.

We can maybe look at what other sdl2 based projects do for their manylinux wheels.

@LukasSliacky
Copy link

LukasSliacky commented Jan 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.

Thanks @franccisco, @albertas. After reinstall it works on Xubuntu 19.04 too.

@johnlawrenceaspden
Copy link

johnlawrenceaspden commented Feb 6, 2020

Same issue on debian, and the fix for me required installation of the kivy dependencies:

So:
sudo apt-get install python-pip build-essential git python python-dev ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev

Followed by:

pip uninstall kivy

and then:

pip install --no-binary kivy kivy

builds kivy locally without using the pre-compiled wheel.

That creates a version of kivy that recognises sdl2 as an audio provider, and also works.

Without doing the dependencies, the new kivy can't see sdl2 as a possible provider, even though I did have libsdl2-dev libsdl2-mixer-dev installed, and sdl2 was working on my system via pysdl2

Don't know if that helps kivy dev, but it might help someone finding this bug report while trying to fix the problem.

@pablojimenezmateo
Copy link

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

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

5 participants