Get rid of the separate so file for OpenSL stuff, we haven't supported 2.2 for a long time

Code needs some cleanup, but that's for later.
This commit is contained in:
Henrik Rydgard 2015-07-19 17:27:02 +02:00
parent 7c24761d4d
commit e23e20d8a1
4 changed files with 10 additions and 33 deletions

View File

@ -8,6 +8,7 @@ LOCAL_MODULE := libnative
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES :=\
android/native_audio.cpp \
android/native-audio-so.cpp \
audio/wav_read.cpp \
audio/mixer.cpp.arm \
base/backtrace.cpp \

View File

@ -66,7 +66,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
}
// create the engine and output mix objects
extern "C" bool OpenSLWrap_Init(AndroidAudioCallback cb, int _FramesPerBuffer, int _SampleRate) {
bool OpenSLWrap_Init(AndroidAudioCallback cb, int _FramesPerBuffer, int _SampleRate) {
audioCallback = cb;
framesPerBuffer = _FramesPerBuffer;
if (framesPerBuffer == 0)
@ -150,7 +150,7 @@ extern "C" bool OpenSLWrap_Init(AndroidAudioCallback cb, int _FramesPerBuffer, i
}
// shut down the native audio system
extern "C" void OpenSLWrap_Shutdown() {
void OpenSLWrap_Shutdown() {
SLresult result;
ILOG("OpenSLWrap_Shutdown - stopping playback");
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_STOPPED);

View File

@ -1,8 +1,6 @@
#pragma once
// Header for dynamic loading
typedef int (*AndroidAudioCallback)(short *buffer, int num_samples);
typedef bool (*OpenSLWrap_Init_T)(AndroidAudioCallback cb, int framesPerBuffer, int sampleRate);
typedef void (*OpenSLWrap_Shutdown_T)();
bool OpenSLWrap_Init(AndroidAudioCallback cb, int _FramesPerBuffer, int _SampleRate);
void OpenSLWrap_Shutdown();

View File

@ -1,15 +1,10 @@
#include <dlfcn.h>
#include <errno.h>
#include "base/logging.h"
#include "android/native_audio.h"
#include "android/native-audio-so.h"
struct AudioState {
void *so;
AndroidAudioCallback s_cb;
OpenSLWrap_Init_T init_func;
OpenSLWrap_Shutdown_T shutdown_func;
AndroidAudioCallback callback;
bool playing;
int frames_per_buffer;
int sample_rate;
@ -17,31 +12,18 @@ struct AudioState {
static AudioState *state = 0;
bool AndroidAudio_Init(AndroidAudioCallback cb, std::string libraryDir, int optimalFramesPerBuffer, int optimalSampleRate) {
bool AndroidAudio_Init(AndroidAudioCallback callback, std::string libraryDir, int optimalFramesPerBuffer, int optimalSampleRate) {
if (state != 0) {
ELOG("Audio state already exists");
return false;
}
ILOG("Loading native audio library...");
std::string so_filename = libraryDir + "/libnative_audio.so";
void *the_so = dlopen(so_filename.c_str(), RTLD_LAZY);
if (!the_so) {
ELOG("Failed to find native audio library: %i: %s ", errno, dlerror());
return false;
}
state = new AudioState();
state->so = the_so;
state->s_cb = cb;
state->callback = callback;
state->playing = false;
state->init_func = (OpenSLWrap_Init_T)dlsym(state->so, "OpenSLWrap_Init");
state->shutdown_func = (OpenSLWrap_Shutdown_T)dlsym(state->so, "OpenSLWrap_Shutdown");
state->frames_per_buffer = optimalFramesPerBuffer ? optimalFramesPerBuffer : 256;
state->sample_rate = optimalSampleRate ? optimalSampleRate : 44100;
ILOG("OpenSLWrap init_func: %p shutdown_func: %p", (void *)state->init_func, (void *)state->shutdown_func);
return true;
}
@ -52,7 +34,7 @@ bool AndroidAudio_Resume() {
}
if (!state->playing) {
ILOG("Calling OpenSLWrap_Init_T...");
bool init_retval = state->init_func(state->s_cb, state->frames_per_buffer, state->sample_rate);
bool init_retval = OpenSLWrap_Init(state->callback, state->frames_per_buffer, state->sample_rate);
ILOG("Returned from OpenSLWrap_Init_T");
state->playing = true;
return init_retval;
@ -67,7 +49,7 @@ bool AndroidAudio_Pause() {
}
if (state->playing) {
ILOG("Calling OpenSLWrap_Shutdown_T...");
state->shutdown_func();
OpenSLWrap_Shutdown();
ILOG("Returned from OpenSLWrap_Shutdown_T ...");
state->playing = false;
return true;
@ -83,10 +65,6 @@ void AndroidAudio_Shutdown() {
if (state->playing) {
ELOG("Should not shut down when playing! Something is wrong!");
}
ILOG("dlclose");
dlclose(state->so);
ILOG("Returned from dlclose");
state->so = 0;
delete state;
state = 0;
ILOG("OpenSLWrap completely unloaded.");