Fix a bug where sound would never be initialised if a game is started with it off, then later enabled.

This commit is contained in:
The Dax 2013-08-14 08:44:36 -04:00
parent 2463119471
commit 5b2483ee73
5 changed files with 34 additions and 3 deletions

View file

@ -74,6 +74,17 @@ volatile CoreState coreState = CORE_STEPPING;
volatile bool coreStatePending = false;
static volatile CPUThreadState cpuThreadState = CPU_THREAD_NOT_RUNNING;
bool IsAudioInitialised() {
return mixer != NULL;
}
void Audio_Init() {
if(mixer == NULL) {
mixer = new PSPMixer();
host->InitSound(mixer);
}
}
bool IsOnSeparateCPUThread() {
if (cpuThread != NULL) {
return cpuThread->get_id() == std::this_thread::get_id();
@ -82,6 +93,8 @@ bool IsOnSeparateCPUThread() {
}
}
bool CPU_NextState(CPUThreadState from, CPUThreadState to) {
if (cpuThreadState == from) {
cpuThreadState = to;
@ -148,8 +161,7 @@ void CPU_Init() {
host->AttemptLoadSymbolMap();
if (coreParameter.enableSound) {
mixer = new PSPMixer();
host->InitSound(mixer);
Audio_Init();
}
if (coreParameter.disableG3Dlog) {

View file

@ -44,7 +44,10 @@ void PSP_Shutdown();
void PSP_RunLoopUntil(u64 globalticks);
void PSP_RunLoopFor(int cycles);
void Audio_Init();
bool IsOnSeparateCPUThread();
bool IsAudioInitialised();
void GetSysDirectories(std::string &memstickpath, std::string &flash0path);

View file

@ -33,6 +33,7 @@
#include "base/timeutil.h"
#include "math/curves.h"
#include "Core/HW/atrac3plus.h"
#include "Core/System.h"
#ifdef _WIN32
namespace MainWindow {
@ -189,7 +190,7 @@ void GameSettingsScreen::CreateViews() {
root_->Add(leftColumn);
leftColumn->Add(new Spacer(new LinearLayoutParams(1.0)));
leftColumn->Add(new Choice(g->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
leftColumn->Add(new Choice(g->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle(this, &GameSettingsScreen::OnBack);
TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new LinearLayoutParams(800, FILL_PARENT, actionMenuMargins));
@ -327,6 +328,16 @@ void GameSettingsScreen::update(InputState &input) {
g_Config.iForceMaxEmulatedFPS = cap60FPS_ ? 60 : 0;
}
UI::EventReturn GameSettingsScreen::OnBack(UI::EventParams &e) {
screenManager()->finishDialog(this, DR_OK);
if(PSP_IsInited() && !IsAudioInitialised()) {
Audio_Init();
}
return UI::EVENT_DONE;
}
void GlobalSettingsScreen::CreateViews() {
using namespace UI;
root_ = new ScrollView(ORIENT_VERTICAL);

View file

@ -42,6 +42,7 @@ private:
// Event handlers
UI::EventReturn OnDownloadPlugin(UI::EventParams &e);
UI::EventReturn OnControlMapping(UI::EventParams &e);
UI::EventReturn OnBack(UI::EventParams &e);
// Temporaries to convert bools to int settings
bool cap60FPS_;

View file

@ -865,6 +865,10 @@ void AudioScreen::render() {
UICheckBox(GEN_ID, x, y += stride, a->T("Enable Atrac3+"), ALIGN_TOPLEFT, &g_Config.bEnableAtrac3plus);
}
if(PSP_IsInited() && !IsAudioInitialised()) {
Audio_Init();
}
// Show the download button even if not installed - might want to upgrade.
VLinear vlinear(30, 400, 20);
std::string atracString;