Page 1 of 1

I can't run ffplay because of errors of SDL_OpenAudio

Posted: Sat Nov 04, 2017 7:56 am
by odoq7211
I can't run ffplay because of errors of SDL_OpenAudio. Is anyone meet this problem?
SDL_OpenAudio (2 channels, 44100 Hz): WASAPI can't initialize audio client
SDL_OpenAudio (1 channels, 44100 Hz): WASAPI can't initialize audio client

Re: I can't run ffplay because of errors of SDL_OpenAudio

Posted: Mon Nov 27, 2017 7:40 am
by jackyxinli
yes, I got this too. Same codes was compiled under fedora or ubuntu can work.

Re: I can't run ffplay because of errors of SDL_OpenAudio

Posted: Mon Nov 27, 2017 7:47 am
by jackyxinli
set environment SDL_AUDIODRIVER can resolve this problem, it seems like SDL2 can not work on WASAPI.
Under windows 7, directsound and winmm both solved.

https://stackoverflow.com/questions/468 ... 4-binaries

Re: I can't run ffplay because of errors of SDL_OpenAudio

Posted: Wed Nov 29, 2017 2:43 am
by jackyxinli
I find a new method to resolve this problem, the ffplay not call CoInitialize according to error message. So, add code to call CoInitialize, ffplay can work. And the same time, I checked SDL2's source code, the WASAPI module doesn't set member ProvidesOwnCallbackThread, so SDL2 should call CoInitialize before open audio device. But no idea why ffplay gives us this error message.

here is my modification look like.

#ifdef _WIN32
#include <windows.h>
#endif

static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb_channels, int wanted_sample_rate, struct AudioParams *audio_hw_params)
{
......
#ifdef _WIN32
CoInitialize(NULL);
#endif
while (!(audio_dev = SDL_OpenAudioDevice(NULL, 0, &wanted_spec, &spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))) {
......
}

Re: I can't run ffplay because of errors of SDL_OpenAudio

Posted: Sat Mar 10, 2018 4:27 am
by mblain

Re: I can't run ffplay because of errors of SDL_OpenAudio

Posted: Thu Jan 17, 2019 3:27 pm
by StormFiber
jackyxinli wrote:
Mon Nov 27, 2017 7:47 am
set environment SDL_AUDIODRIVER can resolve this problem, it seems like SDL2 can not work on WASAPI.
Under windows 7, directsound and winmm both solved.

https://stackoverflow.com/questions/468 ... 4-binaries
add code to call CoInitialize, ffplay can work. And the same time, I checked SDL2's source code, the WASAPI module doesn't set member ProvidesOwnCallbackThread, so SDL2 should call CoInitialize before open audio device. But no idea why ffplay gives us this error message.