I can't run ffplay because of errors of SDL_OpenAudio

Questions involving a Windows version of FFmpeg.
Post Reply
odoq7211
Posts: 1
Joined: Sat Nov 04, 2017 7:45 am

I can't run ffplay because of errors of SDL_OpenAudio

Post by odoq7211 » Sat Nov 04, 2017 7:56 am

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

jackyxinli
Posts: 6
Joined: Sun Jun 12, 2016 1:50 am

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

Post by jackyxinli » Mon Nov 27, 2017 7:40 am

yes, I got this too. Same codes was compiled under fedora or ubuntu can work.

jackyxinli
Posts: 6
Joined: Sun Jun 12, 2016 1:50 am

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

Post by jackyxinli » 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

jackyxinli
Posts: 6
Joined: Sun Jun 12, 2016 1:50 am

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

Post by jackyxinli » Wed Nov 29, 2017 2:43 am

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))) {
......
}

mblain
Posts: 1
Joined: Sat Mar 10, 2018 3:53 am

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

Post by mblain » Sat Mar 10, 2018 4:27 am


Post Reply