fixed #14148: Got an error while pressing home button at launch, after resuming from background, SimpileAudioEngine::playEffect will not be mute.

The error is: ERROR: [0x19e5fa000] >aurioc> 807: failed: '!pla' (enable 2, outf< 2 ch, 44100 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
This commit is contained in:
James Chen 2016-07-27 15:33:02 +08:00
parent ad25873821
commit 6efcf87b93
1 changed files with 23 additions and 12 deletions

View File

@ -353,18 +353,9 @@ static BOOL _mixerRateSet = NO;
free(defs);
}
- (id)init
{
if ((self = [super init])) {
//Create mutexes
_mutexBufferLoad = [[NSObject alloc] init];
asynchLoadProgress_ = 0.0f;
bufferTotal = CD_BUFFERS_START;
_buffers = (bufferInfo *)malloc( sizeof(_buffers[0]) * bufferTotal);
- (void) _lazyInitOpenAL
{
if (!functioning_) {
// Initialize our OpenAL environment
if ([self _initOpenAL]) {
//Set up the default source group - a single group that contains all the sources
@ -379,11 +370,29 @@ static BOOL _mixerRateSet = NO;
enabled_ = YES;
//Test whether get gain works for sources
[self _testGetGain];
CDLOG(@"OpenAL was initialized successfully!");
} else {
//Something went wrong with OpenAL
functioning_ = NO;
CDLOG(@"OpenAL failed to be initialized!");
}
}
}
- (id)init
{
if ((self = [super init])) {
//Create mutexes
_mutexBufferLoad = [[NSObject alloc] init];
asynchLoadProgress_ = 0.0f;
bufferTotal = CD_BUFFERS_START;
_buffers = (bufferInfo *)malloc( sizeof(_buffers[0]) * bufferTotal);
[self _lazyInitOpenAL];
}
return self;
}
@ -506,6 +515,8 @@ static BOOL _mixerRateSet = NO;
@synchronized(_mutexBufferLoad) {
[self _lazyInitOpenAL];
if (!functioning_) {
//OpenAL initialisation has previously failed
CDLOG(@"Denshion::CDSoundEngine - Loading buffer failed because sound engine state != functioning");