Added Android audio backend

This *should* add the Android audio backend. I do not have any idea how
to do this properly, but I figured that this might work for the moment.
There's probably a lot of testing required for this to work.
This commit is contained in:
Jan Holthuis 2015-04-14 23:08:32 +02:00
parent a65b752592
commit 1c1e779500
3 changed files with 29 additions and 3 deletions

View File

@ -0,0 +1,4 @@
#pragma once
#include "oslib/audiostream.h"
extern audiobackend_t audiobackend_android;

View File

@ -3,6 +3,7 @@
#include "oslib/oslib.h"
#include "audiostream.h"
#include "oslib/audiobackend_directsound.h"
#include "oslib/audiobackend_android.h"
#include "oslib/audiobackend_alsa.h"
#include "oslib/audiobackend_oss.h"
@ -73,6 +74,9 @@ void RegisterAllAudioBackends() {
#if HOST_OS==OS_WINDOWS
RegisterAudioBackend(&audiobackend_directsound);
#endif
#if ANDROID
RegisterAudioBackend(&audiobackend_android);
#endif
#if USE_OSS
RegisterAudioBackend(&audiobackend_oss);
#endif

View File

@ -16,6 +16,7 @@
#include "rend/TexCache.h"
#include "hw/maple/maple_devs.h"
#include "hw/maple/maple_if.h"
#include "oslib/audiobackend_android.h"
#include "util.h"
@ -485,21 +486,38 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_initControllers(JNIEn
env->ReleaseBooleanArrayElements(controllers, controllers_body, 0);
}
#if 0
u32 PushAudio(void* frame, u32 amt, bool wait)
// Audio Stuff
u32 androidaudio_push(void* frame, u32 amt, bool wait)
{
verify(amt==SAMPLE_COUNT);
//yeah, do some audio piping magic here !
jenv->SetShortArrayRegion(jsamples,0,amt*2,(jshort*)frame);
return jenv->CallIntMethod(emu,writemid,jsamples,wait);
}
#endif
void androidaudio_init()
{
// Nothing to do here...
}
void androidaudio_term()
{
// Move along, there is nothing to see here!
}
bool os_IsAudioBuffered()
{
return jenv->CallIntMethod(emu,writemid,jsamples,-1)==0;
}
audiobackend_t audiobackend_android = {
"android", // Slug
"Android Audio", // Name
&androidaudio_init,
&androidaudio_push,
&androidaudio_term
};
int get_mic_data(u8* buffer)
{
jbyteArray jdata = (jbyteArray)jenv->CallObjectMethod(sipemu,getmicdata);