From 3f447246c2a77bf01c189bafe34be127cc7eb1d3 Mon Sep 17 00:00:00 2001 From: PioLing <964472638@qq.com> Date: Fri, 26 May 2023 17:02:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8SDL=5FOpenAudioDevice?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=89=93=E5=BC=80=E9=9F=B3=E9=A2=91=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=20(#2489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复SDL_OpenAudio()接口可能打开失败问题 --- player/SDLAudioDevice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/player/SDLAudioDevice.cpp b/player/SDLAudioDevice.cpp index 41835fb7..76093c89 100644 --- a/player/SDLAudioDevice.cpp +++ b/player/SDLAudioDevice.cpp @@ -33,9 +33,9 @@ SDLAudioDevice::SDLAudioDevice() { SDLAudioDevice *_this = (SDLAudioDevice *) userdata; _this->onReqPCM((char *) stream, len); }; - if (SDL_OpenAudio(&wanted_spec, &_audio_config) < 0) { - throw std::runtime_error("SDL_OpenAudio failed"); - } + if (SDL_OpenAudioDevice(NULL, 0, &wanted_spec, &_audio_config, SDL_AUDIO_ALLOW_ANY_CHANGE) < 0) { + throw std::runtime_error("SDL_OpenAudioDevice failed"); + } InfoL << "actual audioSpec, " << "freq:" << _audio_config.freq << ", format:" << hex << _audio_config.format << dec