mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Cleanup up unnecessary audio init functions
This commit is contained in:
parent
5fae4f36db
commit
f5472ba0d8
@ -30,9 +30,7 @@ public:
|
||||
virtual bool InitGraphics(std::string *error_string, GraphicsContext **ctx) = 0;
|
||||
virtual void ShutdownGraphics() = 0;
|
||||
|
||||
virtual void InitSound() = 0;
|
||||
virtual void UpdateSound() {}
|
||||
virtual void ShutdownSound() = 0;
|
||||
virtual void PollControllers() {}
|
||||
virtual void ToggleDebugConsoleVisibility() {}
|
||||
|
||||
|
@ -156,24 +156,6 @@ std::string GetGPUBackendDevice() {
|
||||
return gpuBackendDevice;
|
||||
}
|
||||
|
||||
bool IsAudioInitialised() {
|
||||
return audioInitialized;
|
||||
}
|
||||
|
||||
void Audio_Init() {
|
||||
if (!audioInitialized) {
|
||||
audioInitialized = true;
|
||||
host->InitSound();
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_Shutdown() {
|
||||
if (audioInitialized) {
|
||||
audioInitialized = false;
|
||||
host->ShutdownSound();
|
||||
}
|
||||
}
|
||||
|
||||
bool CPU_IsReady() {
|
||||
if (coreState == CORE_POWERUP)
|
||||
return false;
|
||||
@ -302,10 +284,6 @@ bool CPU_Init(std::string *errorString) {
|
||||
|
||||
host->AttemptLoadSymbolMap();
|
||||
|
||||
if (g_CoreParameter.enableSound) {
|
||||
Audio_Init();
|
||||
}
|
||||
|
||||
CoreTiming::Init();
|
||||
|
||||
// Init all the HLE modules
|
||||
@ -353,9 +331,6 @@ void CPU_Shutdown() {
|
||||
CoreTiming::Shutdown();
|
||||
__KernelShutdown();
|
||||
HLEShutdown();
|
||||
if (g_CoreParameter.enableSound) {
|
||||
Audio_Shutdown();
|
||||
}
|
||||
|
||||
pspFileSystem.Shutdown();
|
||||
mipsr4k.Shutdown();
|
||||
|
@ -100,10 +100,6 @@ void Core_UpdateDebugStats(bool collectStats);
|
||||
// Increments or decrements an internal counter. Intended to be used by debuggers.
|
||||
void Core_ForceDebugStats(bool enable);
|
||||
|
||||
void Audio_Init();
|
||||
void Audio_Shutdown();
|
||||
bool IsAudioInitialised();
|
||||
|
||||
void UpdateLoadedFile(FileLoader *fileLoader);
|
||||
|
||||
// NOTE: These are almost all derived from g_Config.memStickDirectory directly -
|
||||
|
@ -34,9 +34,7 @@ public:
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
|
||||
void ShutdownGraphics() override {}
|
||||
|
||||
void InitSound() override;
|
||||
void UpdateSound() override {}
|
||||
void ShutdownSound() override;
|
||||
|
||||
bool AttemptLoadSymbolMap() override {
|
||||
auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
|
||||
|
@ -164,8 +164,6 @@ private slots:
|
||||
// Sound
|
||||
void audioAct() {
|
||||
g_Config.bEnableSound = !g_Config.bEnableSound;
|
||||
if (PSP_IsInited() && !IsAudioInitialised())
|
||||
Audio_Init();
|
||||
}
|
||||
|
||||
// Cheats
|
||||
|
@ -1343,11 +1343,6 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
void GameSettingsScreen::onFinish(DialogResult result) {
|
||||
if (g_Config.bEnableSound) {
|
||||
if (PSP_IsInited() && !IsAudioInitialised())
|
||||
Audio_Init();
|
||||
}
|
||||
|
||||
Reporting::Enable(enableReports_, "report.ppsspp.org");
|
||||
Reporting::UpdateConfig();
|
||||
if (!g_Config.Save("GameSettingsScreen::onFinish")) {
|
||||
|
@ -27,9 +27,7 @@ public:
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
|
||||
void ShutdownGraphics() override {}
|
||||
|
||||
void InitSound() override;
|
||||
void UpdateSound() override {}
|
||||
void ShutdownSound() override;
|
||||
|
||||
bool AttemptLoadSymbolMap() override {return false;}
|
||||
void SetWindowTitle(const char *message) override {}
|
||||
|
@ -218,23 +218,6 @@ int Win32Mix(short *buffer, int numSamples, int bits, int rate) {
|
||||
static LogListener *logger = nullptr;
|
||||
Path boot_filename;
|
||||
|
||||
void NativeHost::InitSound() {
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
iOSCoreAudioInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeHost::ShutdownSound() {
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
iOSCoreAudioShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
||||
void QtHost::InitSound() { }
|
||||
void QtHost::ShutdownSound() { }
|
||||
#endif
|
||||
|
||||
std::string NativeQueryConfig(std::string query) {
|
||||
char temp[128];
|
||||
if (query == "screenRotation") {
|
||||
@ -911,6 +894,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
}
|
||||
|
||||
INFO_LOG(SYSTEM, "NativeInitGraphics completed");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,15 +66,9 @@ void UWPHost::ShutdownGraphics() {
|
||||
void UWPHost::SetWindowTitle(const char *message) {
|
||||
}
|
||||
|
||||
void UWPHost::InitSound() {
|
||||
}
|
||||
|
||||
void UWPHost::UpdateSound() {
|
||||
}
|
||||
|
||||
void UWPHost::ShutdownSound() {
|
||||
}
|
||||
|
||||
void UWPHost::PollControllers() {
|
||||
for (const auto& device : this->input)
|
||||
{
|
||||
|
@ -17,9 +17,7 @@ public:
|
||||
void PollControllers() override;
|
||||
void ShutdownGraphics() override;
|
||||
|
||||
void InitSound() override;
|
||||
void UpdateSound() override;
|
||||
void ShutdownSound() override;
|
||||
|
||||
bool AttemptLoadSymbolMap() override;
|
||||
void SaveSymbolMap() override;
|
||||
|
@ -917,10 +917,6 @@ namespace MainWindow {
|
||||
|
||||
case ID_EMULATION_SOUND:
|
||||
g_Config.bEnableSound = !g_Config.bEnableSound;
|
||||
if (g_Config.bEnableSound) {
|
||||
if (PSP_IsInited() && !IsAudioInitialised())
|
||||
Audio_Init();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_HELP_OPENWEBSITE:
|
||||
|
@ -175,9 +175,6 @@ void WindowsHost::SetWindowTitle(const char *message) {
|
||||
PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
|
||||
}
|
||||
|
||||
void WindowsHost::InitSound() {
|
||||
}
|
||||
|
||||
// UGLY!
|
||||
extern WindowsAudioBackend *winAudioBackend;
|
||||
|
||||
@ -186,9 +183,6 @@ void WindowsHost::UpdateSound() {
|
||||
winAudioBackend->Update();
|
||||
}
|
||||
|
||||
void WindowsHost::ShutdownSound() {
|
||||
}
|
||||
|
||||
void WindowsHost::PollControllers() {
|
||||
static int checkCounter = 0;
|
||||
static const int CHECK_FREQUENCY = 71;
|
||||
|
@ -39,9 +39,7 @@ public:
|
||||
void PollControllers() override;
|
||||
void ShutdownGraphics() override;
|
||||
|
||||
void InitSound() override;
|
||||
void UpdateSound() override;
|
||||
void ShutdownSound() override;
|
||||
|
||||
bool AttemptLoadSymbolMap() override;
|
||||
void SaveSymbolMap() override;
|
||||
|
@ -30,9 +30,7 @@ public:
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override {return false;}
|
||||
void ShutdownGraphics() override {}
|
||||
|
||||
void InitSound() override {}
|
||||
void UpdateSound() override {}
|
||||
void ShutdownSound() override {}
|
||||
|
||||
bool AttemptLoadSymbolMap() override { g_symbolMap->Clear(); return false; }
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
#import "Common/System/System.h"
|
||||
#import "Common/System/NativeApp.h"
|
||||
#import "Core/System.h"
|
||||
@ -16,59 +17,59 @@
|
||||
// for AVAudioSessionInterruptionNotification
|
||||
-(void) handleAudioSessionInterruption:(NSNotification *)notification {
|
||||
NSNumber *interruptionType = notification.userInfo[AVAudioSessionInterruptionTypeKey];
|
||||
|
||||
|
||||
// Sanity check in case it's somehow not an NSNumber
|
||||
if (![interruptionType respondsToSelector:@selector(unsignedIntegerValue)]) {
|
||||
return; // Lets not crash
|
||||
}
|
||||
|
||||
|
||||
switch ([interruptionType unsignedIntegerValue]) {
|
||||
case AVAudioSessionInterruptionTypeBegan:
|
||||
INFO_LOG(SYSTEM, "ios audio session interruption beginning");
|
||||
if (g_Config.bEnableSound) {
|
||||
Audio_Shutdown();
|
||||
iOSCoreAudioShutdown();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case AVAudioSessionInterruptionTypeEnded:
|
||||
INFO_LOG(SYSTEM, "ios audio session interruption ending");
|
||||
if (g_Config.bEnableSound) {
|
||||
/*
|
||||
/*
|
||||
* Only try to reinit audio if in the foreground, otherwise
|
||||
* it may fail. Instead, trust that applicationDidBecomeActive
|
||||
* will do it later.
|
||||
*/
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
||||
Audio_Init();
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
||||
iOSCoreAudioInit();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
// This will be called when the iOS's shared media process was reset
|
||||
// This will be called when the iOS's shared media process was reset
|
||||
// Registered in application:didFinishLaunchingWithOptions:
|
||||
// for AVAudioSessionMediaServicesWereResetNotification
|
||||
-(void) handleMediaServicesWereReset:(NSNotification *)notification {
|
||||
INFO_LOG(SYSTEM, "ios media services were reset - reinitializing audio");
|
||||
|
||||
|
||||
/*
|
||||
When media services were reset, Apple recommends:
|
||||
1) Dispose of orphaned audio objects (such as players, recorders,
|
||||
1) Dispose of orphaned audio objects (such as players, recorders,
|
||||
converters, or audio queues) and create new ones
|
||||
2) Reset any internal audio states being tracked, including all
|
||||
2) Reset any internal audio states being tracked, including all
|
||||
properties of AVAudioSession
|
||||
3) When appropriate, reactivate the AVAudioSession instance using the
|
||||
3) When appropriate, reactivate the AVAudioSession instance using the
|
||||
setActive:error: method
|
||||
We accomplish this by shutting down and reinitializing audio
|
||||
*/
|
||||
|
||||
|
||||
if (g_Config.bEnableSound) {
|
||||
Audio_Shutdown();
|
||||
Audio_Init();
|
||||
iOSCoreAudioShutdown();
|
||||
iOSCoreAudioInit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,14 +92,14 @@
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.viewController = [[ViewController alloc] init];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil];
|
||||
|
||||
|
||||
self.window.rootViewController = self.viewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -108,18 +109,18 @@
|
||||
|
||||
-(void) applicationWillResignActive:(UIApplication *)application {
|
||||
if (g_Config.bEnableSound) {
|
||||
Audio_Shutdown();
|
||||
iOSCoreAudioShutdown();
|
||||
}
|
||||
|
||||
NativeMessageReceived("lost_focus", "");
|
||||
|
||||
NativeMessageReceived("lost_focus", "");
|
||||
}
|
||||
|
||||
-(void) applicationDidBecomeActive:(UIApplication *)application {
|
||||
if (g_Config.bEnableSound) {
|
||||
Audio_Init();
|
||||
iOSCoreAudioInit();
|
||||
}
|
||||
|
||||
NativeMessageReceived("got_focus", "");
|
||||
|
||||
NativeMessageReceived("got_focus", "");
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
|
@ -8,6 +8,8 @@
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
#import "DisplayManager.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
|
||||
#import <GLKit/GLKit.h>
|
||||
#include <cassert>
|
||||
|
||||
@ -254,7 +256,7 @@ static LocationHelper *locationHelper;
|
||||
return;
|
||||
}
|
||||
|
||||
Audio_Shutdown();
|
||||
iOSCoreAudioShutdown();
|
||||
|
||||
if (threadEnabled) {
|
||||
threadEnabled = false;
|
||||
|
@ -388,7 +388,6 @@ class LibretroHost : public Host
|
||||
LibretroHost() {}
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
|
||||
void ShutdownGraphics() override {}
|
||||
void InitSound() override {}
|
||||
void UpdateSound() override
|
||||
{
|
||||
int hostAttemptBlockSize = __AudioGetHostAttemptBlockSize();
|
||||
@ -399,7 +398,6 @@ class LibretroHost : public Host
|
||||
int samples = __AudioMix(audio, hostAttemptBlockSize, SAMPLERATE);
|
||||
AudioBufferWrite(audio, samples);
|
||||
}
|
||||
void ShutdownSound() override {}
|
||||
bool AttemptLoadSymbolMap() override { return false; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user