mirror of https://github.com/encounter/SDL.git
Android/openslES: some space and indentation to match SDL conventions
This commit is contained in:
parent
7dc92a7669
commit
365fd9c602
|
@ -50,8 +50,7 @@ static SLObjectItf outputMixObject = NULL;
|
||||||
//static SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
|
//static SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
|
||||||
|
|
||||||
// aux effect on the output mix, used by the buffer queue player
|
// aux effect on the output mix, used by the buffer queue player
|
||||||
static const SLEnvironmentalReverbSettings reverbSettings =
|
// static const SLEnvironmentalReverbSettings reverbSettings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
|
||||||
SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
|
|
||||||
|
|
||||||
// buffer queue player interfaces
|
// buffer queue player interfaces
|
||||||
static SLObjectItf bqPlayerObject = NULL;
|
static SLObjectItf bqPlayerObject = NULL;
|
||||||
|
@ -61,21 +60,19 @@ static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
|
||||||
static SLMuteSoloItf bqPlayerMuteSolo;
|
static SLMuteSoloItf bqPlayerMuteSolo;
|
||||||
static SLVolumeItf bqPlayerVolume;
|
static SLVolumeItf bqPlayerVolume;
|
||||||
|
|
||||||
|
#if 0
|
||||||
// recorder interfaces TODO
|
// recorder interfaces TODO
|
||||||
static SLObjectItf recorderObject = NULL;
|
static SLObjectItf recorderObject = NULL;
|
||||||
static SLRecordItf recorderRecord;
|
static SLRecordItf recorderRecord;
|
||||||
static SLAndroidSimpleBufferQueueItf recorderBufferQueue;
|
static SLAndroidSimpleBufferQueueItf recorderBufferQueue;
|
||||||
|
#endif
|
||||||
|
|
||||||
// pointer and size of the next player buffer to enqueue, and number of remaining buffers
|
// pointer and size of the next player buffer to enqueue, and number of remaining buffers
|
||||||
|
#if 0
|
||||||
static short *nextBuffer;
|
static short *nextBuffer;
|
||||||
static unsigned nextSize;
|
static unsigned nextSize;
|
||||||
static int nextCount;
|
static int nextCount;
|
||||||
|
#endif
|
||||||
static const char *sldevaudiorecorderstr = "SLES Audio Recorder";
|
|
||||||
static const char *sldevaudioplayerstr = "SLES Audio Player";
|
|
||||||
|
|
||||||
#define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr
|
|
||||||
#define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr
|
|
||||||
|
|
||||||
#define NUM_BUFFERS 2 /* -- Don't lower this! */
|
#define NUM_BUFFERS 2 /* -- Don't lower this! */
|
||||||
|
|
||||||
|
@ -83,11 +80,19 @@ static Uint8 *mixbuff = NULL;
|
||||||
static int next_buffer = 0;
|
static int next_buffer = 0;
|
||||||
static Uint8 *pmixbuff[NUM_BUFFERS];
|
static Uint8 *pmixbuff[NUM_BUFFERS];
|
||||||
|
|
||||||
static SDL_sem *playsem = NULL, *recsem = NULL;
|
static SDL_sem *playsem = NULL;
|
||||||
|
#if 0
|
||||||
|
static SDL_sem *recsem = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
//static SDL_AudioDevice* audioDevice = NULL;
|
//static SDL_AudioDevice* audioDevice = NULL;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
static const char *sldevaudiorecorderstr = "SLES Audio Recorder";
|
||||||
|
static const char *sldevaudioplayerstr = "SLES Audio Player";
|
||||||
|
|
||||||
|
#define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr
|
||||||
|
#define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr
|
||||||
static void openslES_DetectDevices( int iscapture )
|
static void openslES_DetectDevices( int iscapture )
|
||||||
{
|
{
|
||||||
LOGI( "openSLES_DetectDevices()" );
|
LOGI( "openSLES_DetectDevices()" );
|
||||||
|
@ -101,7 +106,8 @@ static void openslES_DetectDevices( int iscapture )
|
||||||
|
|
||||||
static void openslES_DestroyEngine(void);
|
static void openslES_DestroyEngine(void);
|
||||||
|
|
||||||
static int openslES_CreateEngine( void )
|
static int
|
||||||
|
openslES_CreateEngine(void)
|
||||||
{
|
{
|
||||||
SLresult result;
|
SLresult result;
|
||||||
|
|
||||||
|
@ -110,7 +116,6 @@ static int openslES_CreateEngine( void )
|
||||||
// create engine
|
// create engine
|
||||||
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
|
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("slCreateEngine failed");
|
LOGE("slCreateEngine failed");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +125,6 @@ static int openslES_CreateEngine( void )
|
||||||
// realize the engine
|
// realize the engine
|
||||||
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
|
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("RealizeEngine failed");
|
LOGE("RealizeEngine failed");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +134,6 @@ static int openslES_CreateEngine( void )
|
||||||
// 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 = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("EngineGetInterface failed");
|
LOGE("EngineGetInterface failed");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +149,6 @@ static int openslES_CreateEngine( void )
|
||||||
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
|
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
|
||||||
|
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("CreateOutputMix failed");
|
LOGE("CreateOutputMix failed");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -155,14 +157,12 @@ static int openslES_CreateEngine( void )
|
||||||
// realize the output mix
|
// realize the output mix
|
||||||
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
|
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("RealizeOutputMix failed");
|
LOGE("RealizeOutputMix failed");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error:;
|
error:
|
||||||
openslES_DestroyEngine();
|
openslES_DestroyEngine();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -173,13 +173,11 @@ static void openslES_DestroyPCMRecorder( void );
|
||||||
static void openslES_DestroyEngine(void)
|
static void openslES_DestroyEngine(void)
|
||||||
{
|
{
|
||||||
LOGI("openslES_DestroyEngine()");
|
LOGI("openslES_DestroyEngine()");
|
||||||
|
|
||||||
openslES_DestroyPCMPlayer();
|
openslES_DestroyPCMPlayer();
|
||||||
openslES_DestroyPCMRecorder();
|
openslES_DestroyPCMRecorder();
|
||||||
|
|
||||||
// destroy output mix object, and invalidate all associated interfaces
|
// destroy output mix object, and invalidate all associated interfaces
|
||||||
if (outputMixObject != NULL) {
|
if (outputMixObject != NULL) {
|
||||||
|
|
||||||
(*outputMixObject)->Destroy(outputMixObject);
|
(*outputMixObject)->Destroy(outputMixObject);
|
||||||
outputMixObject = NULL;
|
outputMixObject = NULL;
|
||||||
// outputMixEnvironmentalReverb = NULL;
|
// outputMixEnvironmentalReverb = NULL;
|
||||||
|
@ -187,7 +185,6 @@ static void openslES_DestroyEngine( void )
|
||||||
|
|
||||||
// destroy engine object, and invalidate all associated interfaces
|
// destroy engine object, and invalidate all associated interfaces
|
||||||
if (engineObject != NULL) {
|
if (engineObject != NULL) {
|
||||||
|
|
||||||
(*engineObject)->Destroy(engineObject);
|
(*engineObject)->Destroy(engineObject);
|
||||||
engineObject = NULL;
|
engineObject = NULL;
|
||||||
engineEngine = NULL;
|
engineEngine = NULL;
|
||||||
|
@ -197,16 +194,20 @@ static void openslES_DestroyEngine( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
// this callback handler is called every time a buffer finishes playing
|
// this callback handler is called every time a buffer finishes playing
|
||||||
static void bqPlayerCallback( SLAndroidSimpleBufferQueueItf bq, void *context )
|
static void
|
||||||
|
bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
{
|
{
|
||||||
static int t = 0;
|
static int t = 0;
|
||||||
|
|
||||||
// assert(bq == bqPlayerBufferQueue);
|
// assert(bq == bqPlayerBufferQueue);
|
||||||
// assert(NULL == context);
|
// assert(NULL == context);
|
||||||
|
|
||||||
// for streaming playback, replace this test by logic to find and fill the next buffer
|
// for streaming playback, replace this test by logic to find and fill the next buffer
|
||||||
#if 0
|
#if 0
|
||||||
if (--nextCount > 0 && NULL != nextBuffer && 0 != nextSize) {
|
if (--nextCount > 0 && NULL != nextBuffer && 0 != nextSize)
|
||||||
|
{
|
||||||
SLresult result;
|
SLresult result;
|
||||||
|
|
||||||
// enqueue another buffer
|
// enqueue another buffer
|
||||||
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
|
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
|
||||||
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
|
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
|
||||||
|
@ -215,44 +216,47 @@ static void bqPlayerCallback( SLAndroidSimpleBufferQueueItf bq, void *context )
|
||||||
(void) result;
|
(void) result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOGI("SLES: Playback Callmeback %u", t++);
|
LOGI("SLES: Playback Callmeback %u", t++);
|
||||||
|
|
||||||
SDL_SemPost(playsem);
|
SDL_SemPost(playsem);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openslES_CreatePCMRecorder( _THIS )
|
static int
|
||||||
|
openslES_CreatePCMRecorder(_THIS)
|
||||||
{
|
{
|
||||||
LOGE("openslES_CreatePCMRecorder not implimented yet!");
|
LOGE("openslES_CreatePCMRecorder not implimented yet!");
|
||||||
return SDL_SetError("openslES_CreatePCMRecorder not implimented yet!");
|
return SDL_SetError("openslES_CreatePCMRecorder not implimented yet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openslES_DestroyPCMRecorder( void )
|
static void
|
||||||
|
openslES_DestroyPCMRecorder(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openslES_CreatePCMPlayer( _THIS )
|
static int
|
||||||
|
openslES_CreatePCMPlayer(
|
||||||
|
_THIS)
|
||||||
{
|
{
|
||||||
SLDataFormat_PCM format_pcm;
|
SLDataFormat_PCM format_pcm;
|
||||||
SDL_AudioFormat test_format;
|
|
||||||
SLresult result;
|
SLresult result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
SDL_AudioFormat test_format;
|
||||||
test_format = SDL_FirstAudioFormat( this->spec.format );
|
test_format = SDL_FirstAudioFormat( this->spec.format );
|
||||||
|
|
||||||
while (test_format != 0) {
|
while (test_format != 0) {
|
||||||
|
|
||||||
if ( SDL_AUDIO_ISSIGNED(test_format) && SDL_AUDIO_ISINT(test_format ) ) break;
|
if (SDL_AUDIO_ISSIGNED(test_format) && SDL_AUDIO_ISINT(test_format)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
test_format = SDL_NextAudioFormat();
|
test_format = SDL_NextAudioFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( test_format == 0 ) {
|
if ( test_format == 0 ) {
|
||||||
|
// Didn't find a compatible format :
|
||||||
// Didn't find a compatible format :(
|
|
||||||
LOGI( "No compatible audio format!" );
|
LOGI( "No compatible audio format!" );
|
||||||
return SDL_SetError("No compatible audio format!");
|
return SDL_SetError("No compatible audio format!");
|
||||||
}
|
}
|
||||||
|
@ -265,8 +269,7 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
|
|
||||||
LOGI("Try to open %u hz %u bit chan %u %s samples %u",
|
LOGI("Try to open %u hz %u bit chan %u %s samples %u",
|
||||||
this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format),
|
this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format),
|
||||||
this->spec.channels, (test_format&0x1000) ? "BE" : "LE", this->spec.samples
|
this->spec.channels, (test_format & 0x1000) ? "BE" : "LE", this->spec.samples);
|
||||||
);
|
|
||||||
|
|
||||||
// configure audio source
|
// configure audio source
|
||||||
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2 };
|
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2 };
|
||||||
|
@ -278,10 +281,11 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
format_pcm.bitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
|
format_pcm.bitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
|
||||||
format_pcm.containerSize = SDL_AUDIO_BITSIZE(this->spec.format);
|
format_pcm.containerSize = SDL_AUDIO_BITSIZE(this->spec.format);
|
||||||
|
|
||||||
if ( SDL_AUDIO_ISBIGENDIAN( this->spec.format ) )
|
if (SDL_AUDIO_ISBIGENDIAN(this->spec.format)) {
|
||||||
format_pcm.endianness = SL_BYTEORDER_BIGENDIAN;
|
format_pcm.endianness = SL_BYTEORDER_BIGENDIAN;
|
||||||
else
|
} else {
|
||||||
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001)
|
#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001)
|
||||||
|
@ -304,19 +308,19 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000)
|
#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( this->spec.channels == 1 )
|
if (this->spec.channels == 1) {
|
||||||
format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
|
format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
|
||||||
else if ( this->spec.channels == 2 )
|
} else if (this->spec.channels == 2) {
|
||||||
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
|
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
|
||||||
else if ( this->spec.channels == 3 )
|
} else if (this->spec.channels == 3) {
|
||||||
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER;
|
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER;
|
||||||
else if ( this->spec.channels == 4 )
|
} else if (this->spec.channels == 4) {
|
||||||
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
|
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
|
||||||
SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT;
|
SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT;
|
||||||
else
|
} else {
|
||||||
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
|
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
|
||||||
SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT |
|
SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT | SL_SPEAKER_FRONT_CENTER;
|
||||||
SL_SPEAKER_FRONT_CENTER;
|
}
|
||||||
|
|
||||||
SLDataSource audioSrc = { &loc_bufq, &format_pcm };
|
SLDataSource audioSrc = { &loc_bufq, &format_pcm };
|
||||||
|
|
||||||
|
@ -335,10 +339,8 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
SL_BOOLEAN_FALSE,
|
SL_BOOLEAN_FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
result = (*engineEngine)->CreateAudioPlayer( engineEngine, &bqPlayerObject, &audioSrc, &audioSnk,
|
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrc, &audioSnk, 2, ids, req);
|
||||||
2, ids, req );
|
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("CreateAudioPlayer failed");
|
LOGE("CreateAudioPlayer failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +348,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// realize the player
|
// realize the player
|
||||||
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
|
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("RealizeAudioPlayer failed");
|
LOGE("RealizeAudioPlayer failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +355,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// get the play interface
|
// get the play interface
|
||||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
|
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("SL_IID_PLAY interface get failed");
|
LOGE("SL_IID_PLAY interface get failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// get the buffer queue interface
|
// get the buffer queue interface
|
||||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bqPlayerBufferQueue);
|
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bqPlayerBufferQueue);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("SL_IID_BUFFERQUEUE interface get failed");
|
LOGE("SL_IID_BUFFERQUEUE interface get failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -370,7 +369,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// register callback on the buffer queue
|
// register callback on the buffer queue
|
||||||
result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, NULL);
|
result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, NULL);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("RegisterCallback failed");
|
LOGE("RegisterCallback failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +376,8 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
#if 0
|
#if 0
|
||||||
// get the effect send interface
|
// get the effect send interface
|
||||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_EFFECTSEND, &bqPlayerEffectSend);
|
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_EFFECTSEND, &bqPlayerEffectSend);
|
||||||
if ( SL_RESULT_SUCCESS != result ) {
|
if (SL_RESULT_SUCCESS != result)
|
||||||
|
{
|
||||||
|
|
||||||
LOGE("SL_IID_EFFECTSEND interface get failed");
|
LOGE("SL_IID_EFFECTSEND interface get failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -395,7 +394,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// get the volume interface
|
// get the volume interface
|
||||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
|
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("SL_IID_VOLUME interface get failed");
|
LOGE("SL_IID_VOLUME interface get failed");
|
||||||
// goto failed;
|
// goto failed;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +401,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
// set the player's state to playing
|
// set the player's state to playing
|
||||||
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
|
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result) {
|
||||||
|
|
||||||
LOGE("Play set state failed");
|
LOGE("Play set state failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -411,7 +408,6 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
/* Create the audio buffer semaphore */
|
/* Create the audio buffer semaphore */
|
||||||
playsem = SDL_CreateSemaphore(NUM_BUFFERS - 1);
|
playsem = SDL_CreateSemaphore(NUM_BUFFERS - 1);
|
||||||
if (!playsem) {
|
if (!playsem) {
|
||||||
|
|
||||||
LOGE("cannot create Semaphore!");
|
LOGE("cannot create Semaphore!");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -419,24 +415,25 @@ static int openslES_CreatePCMPlayer( _THIS )
|
||||||
/* Create the sound buffers */
|
/* Create the sound buffers */
|
||||||
mixbuff = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
|
mixbuff = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
|
||||||
if (mixbuff == NULL) {
|
if (mixbuff == NULL) {
|
||||||
|
|
||||||
LOGE("mixbuffer allocate - out of memory");
|
LOGE("mixbuffer allocate - out of memory");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < NUM_BUFFERS; i ++ )
|
for (i = 0; i < NUM_BUFFERS; i++) {
|
||||||
pmixbuff[i] = mixbuff + i * this->spec.size;
|
pmixbuff[i] = mixbuff + i * this->spec.size;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failed:;
|
failed:
|
||||||
|
|
||||||
openslES_DestroyPCMPlayer();
|
openslES_DestroyPCMPlayer();
|
||||||
|
|
||||||
return SDL_SetError("Open device failed!");
|
return SDL_SetError("Open device failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openslES_DestroyPCMPlayer( void )
|
static void
|
||||||
|
openslES_DestroyPCMPlayer(void)
|
||||||
{
|
{
|
||||||
// destroy buffer queue audio player object, and invalidate all associated interfaces
|
// destroy buffer queue audio player object, and invalidate all associated interfaces
|
||||||
if (bqPlayerObject != NULL) {
|
if (bqPlayerObject != NULL) {
|
||||||
|
@ -452,43 +449,45 @@ static void openslES_DestroyPCMPlayer( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playsem) {
|
if (playsem) {
|
||||||
|
|
||||||
SDL_DestroySemaphore(playsem);
|
SDL_DestroySemaphore(playsem);
|
||||||
playsem = NULL;
|
playsem = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mixbuff )
|
if (mixbuff) {
|
||||||
SDL_free(mixbuff);
|
SDL_free(mixbuff);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openslES_OpenDevice( _THIS, void *handle, const char *devname, int iscapture )
|
static int
|
||||||
|
openslES_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||||
{
|
{
|
||||||
if (iscapture) {
|
if (iscapture) {
|
||||||
LOGI("openslES_OpenDevice( ) %s for capture", devname);
|
LOGI("openslES_OpenDevice( ) %s for capture", devname);
|
||||||
return openslES_CreatePCMRecorder(this);
|
return openslES_CreatePCMRecorder(this);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
LOGI("openslES_OpenDevice( ) %s for playing", devname);
|
LOGI("openslES_OpenDevice( ) %s for playing", devname);
|
||||||
|
|
||||||
return openslES_CreatePCMPlayer(this);
|
return openslES_CreatePCMPlayer(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void openslES_CloseDevice( _THIS )
|
static void
|
||||||
|
openslES_CloseDevice(_THIS)
|
||||||
{
|
{
|
||||||
if (this->iscapture) {
|
if (this->iscapture) {
|
||||||
LOGI("openslES_CloseDevice( ) for capture");
|
LOGI("openslES_CloseDevice( ) for capture");
|
||||||
return openslES_DestroyPCMRecorder( );
|
openslES_DestroyPCMRecorder();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
LOGI("openslES_CloseDevice( ) for playing");
|
LOGI("openslES_CloseDevice( ) for playing");
|
||||||
openslES_DestroyPCMPlayer();
|
openslES_DestroyPCMPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openslES_WaitDevice( _THIS )
|
static void
|
||||||
|
openslES_WaitDevice(_THIS)
|
||||||
{
|
{
|
||||||
LOGI("openslES_WaitDevice( )");
|
LOGI("openslES_WaitDevice( )");
|
||||||
|
|
||||||
|
@ -511,15 +510,15 @@ static void openslES_WaitDevice( _THIS )
|
||||||
//
|
//
|
||||||
// okay..
|
// okay..
|
||||||
|
|
||||||
|
static Uint8 *
|
||||||
static Uint8 *openslES_GetDeviceBuf( _THIS )
|
openslES_GetDeviceBuf(_THIS)
|
||||||
{
|
{
|
||||||
LOGI("openslES_GetDeviceBuf( )");
|
LOGI("openslES_GetDeviceBuf( )");
|
||||||
|
|
||||||
return pmixbuff[next_buffer];
|
return pmixbuff[next_buffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openslES_PlayDevice( _THIS )
|
static void
|
||||||
|
openslES_PlayDevice(_THIS)
|
||||||
{
|
{
|
||||||
SLresult result;
|
SLresult result;
|
||||||
|
|
||||||
|
@ -533,16 +532,21 @@ static void openslES_PlayDevice( _THIS )
|
||||||
}
|
}
|
||||||
|
|
||||||
next_buffer++;
|
next_buffer++;
|
||||||
if ( next_buffer >= NUM_BUFFERS ) next_buffer = 0;
|
if (next_buffer >= NUM_BUFFERS) {
|
||||||
|
next_buffer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openslES_Init( SDL_AudioDriverImpl * impl )
|
static int
|
||||||
|
openslES_Init(SDL_AudioDriverImpl * impl)
|
||||||
{
|
{
|
||||||
LOGI("openslES_Init() called");
|
LOGI("openslES_Init() called");
|
||||||
|
|
||||||
if ( !openslES_CreateEngine() ) return 0;
|
if (!openslES_CreateEngine()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LOGI("openslES_Init() - set pointers");
|
LOGI("openslES_Init() - set pointers");
|
||||||
|
|
||||||
|
@ -561,7 +565,8 @@ static int openslES_Init( SDL_AudioDriverImpl * impl )
|
||||||
|
|
||||||
LOGI("openslES_Init() - succes");
|
LOGI("openslES_Init() - succes");
|
||||||
|
|
||||||
return 1; /* this audio target is available. */
|
/* this audio target is available. */
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap openslES_bootstrap = {
|
AudioBootStrap openslES_bootstrap = {
|
||||||
|
|
Loading…
Reference in New Issue