Beispiel #1
0
int main(int argc, char** argv) {

    struct Engine *e;
    if((e = initEngine(argc, argv)) == NULL){
        releaseEngine(e); //OK if called twice by NULL check
        return(EXIT_FAILURE);
    }
        
    engineRun(e);
    
    releaseEngine(e);
    return (EXIT_SUCCESS);
}
SLESAudioTrack::SLESAudioTrack(int samplerate, int bitsPerSample, int channel):engineObject(NULL),engineEngine(NULL),
                                 outputMixObject(NULL),
                                 bqPlayerObject(NULL),bqPlayerPlay(NULL),
                                 bqPlayerBufferQueue(NULL),bqPlayerEffectSend(NULL),
                                 bqPlayerMuteSolo(NULL),bqPlayerVolume(NULL){
    if(SL_RESULT_SUCCESS == createEngine()){
        if(SL_RESULT_SUCCESS != createBufferQueueAudioPlayer(samplerate, bitsPerSample, channel)){
            releaseEngine();
        }
    }
}
SLresult SLESAudioTrack::createEngine(){
    SLresult result;

    // create engine
    result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
    if(SL_RESULT_SUCCESS != result){
        return result;
    }

    // realize the engine
    result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
    if(SL_RESULT_SUCCESS != result){
        releaseEngine();
        return result;
    }

    // get the engine interface, which is needed in order to create other objects
    result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
    if(SL_RESULT_SUCCESS != result){
        releaseEngine();
        return result;
    }

    // create output mix, with environmental reverb specified as a non-required interface
    const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
    const SLboolean req[1] = {SL_BOOLEAN_FALSE};
    result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
    if(SL_RESULT_SUCCESS != result){
        releaseEngine();
        return result;
    }

    // realize the output mix
    result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
    if(SL_RESULT_SUCCESS != result){
        releaseEngine();
        return result;
    }
    return result;
}
Beispiel #4
0
void Game::destroyGame()
{
	releaseEngine();
};
void SLESAudioTrack::release(){
    releaseBufferQueueAudioPlayer();
    releaseEngine();
}