mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
SDL: Use SDL2 audio API for output.
This commit is contained in:
1 parent
daf07032a6
commit
141258c366
2 files changed
+23
-13
No files matched your search
+13
-7
@@ -29,7 +29,9 @@
|
||||
#ifdef SDL
|
||||
#include "SDL/SDLJoystick.h"
|
||||
#include "SDL_audio.h"
|
||||
#define MainAudioDeviceID SDL_AudioDeviceID
|
||||
#endif
|
||||
#define MainAudioDeviceID int
|
||||
#include "QtMain.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
#include "i18n/i18n.h"
|
||||
@@ -168,7 +170,7 @@ float CalculateDPIScale()
|
||||
#endif
|
||||
}
|
||||
|
||||
static int mainInternal(QApplication &a) {
|
||||
static int mainInternal(QApplication &a, MainAudioDeviceID &audioDev) {
|
||||
#ifdef MOBILE_DEVICE
|
||||
emugl = new MainUI();
|
||||
emugl->resize(pixel_xres, pixel_yres);
|
||||
@@ -194,7 +196,8 @@ static int mainInternal(QApplication &a) {
|
||||
fmt.callback = &mixaudio;
|
||||
fmt.userdata = (void *)0;
|
||||
|
||||
if (SDL_OpenAudio(&fmt, &ret_fmt) < 0) {
|
||||
audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
|
||||
if (audioDev <= 0) {
|
||||
ELOG("Failed to open audio: %s", SDL_GetError());
|
||||
} else {
|
||||
if (ret_fmt.samples != fmt.samples) // Notify, but still use it
|
||||
@@ -205,10 +208,10 @@ static int mainInternal(QApplication &a) {
|
||||
ELOG("Output audio format: %d (requested: %d)", ret_fmt.format, fmt.format);
|
||||
ELOG("Output audio channels: %d (requested: %d)", ret_fmt.channels, fmt.channels);
|
||||
ELOG("Provided output format does not match requirement, turning audio off");
|
||||
SDL_CloseAudio();
|
||||
SDL_CloseAudioDevice(audioDev);
|
||||
}
|
||||
SDL_PauseAudioDevice(audioDev, 0);
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
#else
|
||||
QScopedPointer<MainAudio> audio(new MainAudio());
|
||||
audio->run();
|
||||
@@ -608,12 +611,15 @@ int main(int argc, char *argv[])
|
||||
// TODO: Support other backends than GL, like Vulkan, in the Qt backend.
|
||||
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
|
||||
|
||||
int ret = mainInternal(a);
|
||||
MainAudioDeviceID audioDev = 0;
|
||||
int ret = mainInternal(a, audioDev);
|
||||
ILOG("Left mainInternal here.");
|
||||
|
||||
#ifdef SDL
|
||||
SDL_PauseAudio(1);
|
||||
SDL_CloseAudio();
|
||||
if (audioDev > 0) {
|
||||
SDL_PauseAudioDevice(audioDev, 1);
|
||||
SDL_CloseAudioDevice(audioDev);
|
||||
}
|
||||
#endif
|
||||
NativeShutdown();
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
+10
-6
@@ -582,7 +582,8 @@ int main(int argc, char *argv[]) {
|
||||
fmt.callback = &mixaudio;
|
||||
fmt.userdata = (void *)0;
|
||||
|
||||
if (SDL_OpenAudio(&fmt, &ret_fmt) < 0) {
|
||||
SDL_AudioDeviceID audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
|
||||
if (audioDev <= 0) {
|
||||
ELOG("Failed to open audio: %s", SDL_GetError());
|
||||
} else {
|
||||
if (ret_fmt.samples != fmt.samples) // Notify, but still use it
|
||||
@@ -593,12 +594,13 @@ int main(int argc, char *argv[]) {
|
||||
ELOG("Output audio format: %d (requested: %d)", ret_fmt.format, fmt.format);
|
||||
ELOG("Output audio channels: %d (requested: %d)", ret_fmt.channels, fmt.channels);
|
||||
ELOG("Provided output format does not match requirement, turning audio off");
|
||||
SDL_CloseAudio();
|
||||
SDL_CloseAudioDevice(audioDev);
|
||||
}
|
||||
|
||||
// Audio must be unpaused _after_ NativeInit()
|
||||
SDL_PauseAudioDevice(audioDev, 0);
|
||||
}
|
||||
|
||||
// Audio must be unpaused _after_ NativeInit()
|
||||
SDL_PauseAudio(0);
|
||||
if (joystick_enabled) {
|
||||
joystick = new SDLJoystick();
|
||||
} else {
|
||||
@@ -927,8 +929,10 @@ int main(int argc, char *argv[]) {
|
||||
graphicsContext->ShutdownFromRenderThread();
|
||||
delete graphicsContext;
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
SDL_CloseAudio();
|
||||
if (audioDev > 0) {
|
||||
SDL_PauseAudioDevice(audioDev, 1);
|
||||
SDL_CloseAudioDevice(audioDev);
|
||||
}
|
||||
SDL_Quit();
|
||||
#if PPSSPP_PLATFORM(RPI)
|
||||
bcm_host_deinit();
|
||||
|
||||
Reference in new issue
Block a user