Merge pull request #1879 from unknownbrackets/minor

Fix sceAudio shutdown and bogus priority errors
This commit is contained in:
Henrik Rydgård 2013-05-21 01:07:09 -07:00
commit b2701f4421
4 changed files with 24 additions and 9 deletions

View File

@ -40,6 +40,12 @@ void AudioChannel::DoState(PointerWrap &p)
p.DoMarker("AudioChannel"); p.DoMarker("AudioChannel");
} }
void AudioChannel::reset()
{
__AudioWakeThreads(*this);
clear();
}
void AudioChannel::clear() void AudioChannel::clear()
{ {
reserved = false; reserved = false;
@ -49,8 +55,7 @@ void AudioChannel::clear()
sampleAddress = 0; sampleAddress = 0;
sampleCount = 0; sampleCount = 0;
sampleQueue.clear(); sampleQueue.clear();
waitingThreads.clear();
__AudioWakeThreads(*this);
} }
// There's a second Audio api called Audio2 that only has one channel, I guess the 8 channel api was overkill. // There's a second Audio api called Audio2 that only has one channel, I guess the 8 channel api was overkill.
@ -224,7 +229,7 @@ u32 sceAudioChRelease(u32 chan) {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} }
DEBUG_LOG(HLE, "sceAudioChRelease(%i)", chan); DEBUG_LOG(HLE, "sceAudioChRelease(%i)", chan);
chans[chan].clear(); chans[chan].reset();
chans[chan].reserved = false; chans[chan].reserved = false;
return 1; return 1;
} }
@ -340,7 +345,7 @@ u32 sceAudioOutput2GetRestSample(){
u32 sceAudioOutput2Release(){ u32 sceAudioOutput2Release(){
DEBUG_LOG(HLE,"sceAudioOutput2Release()"); DEBUG_LOG(HLE,"sceAudioOutput2Release()");
chans[PSP_AUDIO_CHANNEL_OUTPUT2].clear(); chans[PSP_AUDIO_CHANNEL_OUTPUT2].reset();
chans[PSP_AUDIO_CHANNEL_OUTPUT2].reserved = false; chans[PSP_AUDIO_CHANNEL_OUTPUT2].reserved = false;
return 0; return 0;
} }
@ -390,7 +395,7 @@ u32 sceAudioSRCChRelease() {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} }
DEBUG_LOG(HLE, "sceAudioSRCChRelease()"); DEBUG_LOG(HLE, "sceAudioSRCChRelease()");
chans[PSP_AUDIO_CHANNEL_SRC].clear(); chans[PSP_AUDIO_CHANNEL_SRC].reset();
chans[PSP_AUDIO_CHANNEL_SRC].reserved = false; chans[PSP_AUDIO_CHANNEL_SRC].reserved = false;
return 0; return 0;
} }

View File

@ -81,6 +81,7 @@ struct AudioChannel
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
void reset();
void clear(); void clear();
}; };

View File

@ -878,9 +878,13 @@ void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValu
if (optionAddr) { if (optionAddr) {
SceKernelSMOption smoption; SceKernelSMOption smoption;
Memory::ReadStruct(optionAddr, &smoption);; Memory::ReadStruct(optionAddr, &smoption);;
priority = smoption.priority; if (smoption.priority != 0) {
priority = smoption.priority;
}
attr = smoption.attribute; attr = smoption.attribute;
stacksize = smoption.stacksize; if (smoption.stacksize != 0) {
stacksize = smoption.stacksize;
}
stackPartition = smoption.mpidstack; stackPartition = smoption.mpidstack;
} }
u32 error; u32 error;
@ -900,9 +904,13 @@ void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValu
// TODO: Do these always take effect, or do they not override optionAddr? // TODO: Do these always take effect, or do they not override optionAddr?
if (module->nm.module_start_func != 0 && module->nm.module_start_func != (u32)-1) { if (module->nm.module_start_func != 0 && module->nm.module_start_func != (u32)-1) {
entryAddr = module->nm.module_start_func; entryAddr = module->nm.module_start_func;
priority = module->nm.module_start_thread_priority; if (module->nm.module_start_thread_priority != 0) {
priority = module->nm.module_start_thread_priority;
}
attr = module->nm.module_start_thread_attr; attr = module->nm.module_start_thread_attr;
stacksize = module->nm.module_start_thread_stacksize; if (module->nm.module_start_thread_stacksize != 0) {
stacksize = module->nm.module_start_thread_stacksize;
}
} else { } else {
// TODO: Fix, check return value? Or do we call nothing? // TODO: Fix, check return value? Or do we call nothing?
RETURN(moduleId); RETURN(moduleId);

View File

@ -61,6 +61,7 @@ u32 sceVaudioChRelease() {
if (!chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved) { if (!chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved) {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} else { } else {
chans[PSP_AUDIO_CHANNEL_VAUDIO].reset();
chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved = false; chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved = false;
vaudioReserved = false; vaudioReserved = false;
return 0; return 0;