issue #1284: changed some names to make the code more readable

This commit is contained in:
mustime 2012-07-26 16:22:23 +08:00
parent bfc53e3453
commit 2e335f6dee
2 changed files with 19 additions and 20 deletions

View File

@ -188,14 +188,14 @@ int getFileDescriptor(AudioPlayer * player, const char * filename, off_t & start
/********************************************************************************** /**********************************************************************************
* engine * engine
**********************************************************************************/ **********************************************************************************/
static SLObjectItf engineObject = NULL; static SLObjectItf g_pEngineObject = NULL;
static SLEngineItf engineEngine; static SLEngineItf g_pEngineEngine = NULL;
static SLObjectItf outputMixObject = NULL; static SLObjectItf g_pOutputMixObject = NULL;
bool initAudioPlayer(AudioPlayer* player, const char* filename) bool initAudioPlayer(AudioPlayer* player, const char* filename)
{ {
// configure audio sink // configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject}; SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, g_pOutputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL}; SLDataSink audioSnk = {&loc_outmix, NULL};
// configure audio source // configure audio source
@ -212,8 +212,7 @@ bool initAudioPlayer(AudioPlayer* player, const char* filename)
// create audio player // create audio player
const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME}; const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME};
const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
SLresult result = (*g_pEngineEngine)->CreateAudioPlayer(g_pEngineEngine, &(player->fdPlayerObject), &(player->audioSrc), &audioSnk, 3, ids, req);
SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &(player->fdPlayerObject), &(player->audioSrc), &audioSnk, 3, ids, req);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
// realize the player // realize the player
@ -252,28 +251,28 @@ void OpenSLEngine::createEngine()
LOGD("createEngine"); LOGD("createEngine");
// create engine // create engine
if (engineObject == NULL) if (g_pEngineObject == NULL)
{ {
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL); result = slCreateEngine(&g_pEngineObject, 0, NULL, 0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
// realize the engine // realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); result = (*g_pEngineObject)->Realize(g_pEngineObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
// get the engine interface, which is needed in order to create other objects // get the engine interface, which is needed in order to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine); result = (*g_pEngineObject)->GetInterface(g_pEngineObject, SL_IID_ENGINE, &g_pEngineEngine);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
// create output mix // create output mix
const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB}; const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
const SLboolean req[1] = {SL_BOOLEAN_FALSE}; const SLboolean req[1] = {SL_BOOLEAN_FALSE};
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req); result = (*g_pEngineEngine)->CreateOutputMix(g_pEngineEngine, &g_pOutputMixObject, 1, ids, req);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
} }
// realize the output mix // realize the output mix
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE); result = (*g_pOutputMixObject)->Realize(g_pOutputMixObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
} }
@ -292,16 +291,16 @@ void OpenSLEngine::closeEngine()
sharedList().clear(); sharedList().clear();
// destroy output mix interface // destroy output mix interface
if (outputMixObject != NULL) { if (g_pOutputMixObject != NULL) {
(*outputMixObject)->Destroy(outputMixObject); (*g_pOutputMixObject)->Destroy(g_pOutputMixObject);
outputMixObject = NULL; g_pOutputMixObject = NULL;
} }
// destroy opensl engine // destroy opensl engine
if (engineObject != NULL) { if (g_pEngineObject != NULL) {
(*engineObject)->Destroy(engineObject); (*g_pEngineObject)->Destroy(g_pEngineObject);
engineObject = NULL; g_pEngineObject = NULL;
engineEngine = NULL; g_pEngineEngine = NULL;
} }
} }

View File

@ -5,7 +5,7 @@
#define PLAYSTATE_PLAYING 3 #define PLAYSTATE_PLAYING 3
#define FILE_NOT_FOUND -1 #define FILE_NOT_FOUND -1
OpenSLEngine * s_pOpenSL = 0; static OpenSLEngine * s_pOpenSL = 0;
static SimpleAudioEngineOpenSL * s_pEngine = 0; static SimpleAudioEngineOpenSL * s_pEngine = 0;
SimpleAudioEngineOpenSL::SimpleAudioEngineOpenSL() SimpleAudioEngineOpenSL::SimpleAudioEngineOpenSL()