From 0453b1bbaed5f1dbc9e2139ba1166813ffce68c7 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 2 Jan 2012 14:59:00 +0000 Subject: [PATCH] Missed a file for android. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3951 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/snd_droid.c | 115 ++++++++++++++++++++++++++++++++++++++ engine/gl/gl_model.c | 5 +- 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 engine/client/snd_droid.c diff --git a/engine/client/snd_droid.c b/engine/client/snd_droid.c new file mode 100644 index 000000000..a14af0d3b --- /dev/null +++ b/engine/client/snd_droid.c @@ -0,0 +1,115 @@ +/* +this file is basically a copy of the SDL one +java code has a function or two which just periodically calls us to ask us to dump out audio for it +*/ +#include "quakedef.h" +#include +#include + +//static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static soundcardinfo_t *sys_sc = NULL; + + + +//transfer the 'dma' buffer into the buffer it requests, called from somewhere outside the game engine, prolly another thread. +JNIEXPORT jint JNICALL Java_com_fteqw_FTEDroidEngine_paintaudio(JNIEnv *env, jclass this, jbyteArray stream, jint len) +{ + int offset = 0; +// if (!pthread_mutex_lock(&mutex)) + { + soundcardinfo_t *sc = sys_sc; + if (sc) + { + int buffersize = sc->sn.samples*(sc->sn.samplebits/8); + + if (len > buffersize) + { + len = buffersize; //whoa nellie! + } + + if (len + sc->snd_sent%buffersize > buffersize) + { //buffer will wrap, fill in the rest + (*env)->SetByteArrayRegion(env, stream, offset, buffersize - (sc->snd_sent%buffersize), (char*)sc->sn.buffer + (sc->snd_sent%buffersize)); + offset += buffersize - sc->snd_sent%buffersize; + sc->snd_sent += buffersize - sc->snd_sent%buffersize; + len -= buffersize - (sc->snd_sent%buffersize); + if (len < 0) /*this must be impossible, surely?*/ + len = 0; + } + //and finish from the start + (*env)->SetByteArrayRegion(env, stream, offset, len, (char*)sc->sn.buffer + (sc->snd_sent%buffersize)); + sc->snd_sent += len; + } +// pthread_mutex_unlock(&mutex); + } + return offset; +} + + +static void Droid_Shutdown(soundcardinfo_t *sc) +{ +// pthread_mutex_lock(&mutex); + + sys_sc = NULL; + free(sc->sn.buffer); + +// pthread_mutex_unlock(&mutex); +} + +static unsigned int Droid_GetDMAPos(soundcardinfo_t *sc) +{ + sc->sn.samplepos = sc->snd_sent / (sc->sn.samplebits/8); + return sc->sn.samplepos; +} + +static void Droid_UnlockBuffer(soundcardinfo_t *sc, void *buffer) +{ +// pthread_mutex_unlock(&mutex); +} + +static void *Droid_LockBuffer(soundcardinfo_t *sc) +{ +// pthread_mutex_lock(&mutex); + return sc->sn.buffer; +} + +static void Droid_SetUnderWater(soundcardinfo_t *sc, qboolean uw) +{ +} + +static void Droid_Submit(soundcardinfo_t *sc) +{ +} + +static int Droid_InitCard (soundcardinfo_t *sc, int cardnum) +{ + if (sys_sc) + return 2; + +// if (!pthread_mutex_lock(&mutex)) + { + sc->sn.speed = 11025; + sc->sn.samplebits = 16; + sc->sn.numchannels = 1; + /*internal buffer should have 1 sec audio*/ + sc->sn.samples = sc->sn.speed*sc->sn.numchannels; + + sc->Lock = Droid_LockBuffer; + sc->Unlock = Droid_UnlockBuffer; + sc->SetWaterDistortion = Droid_SetUnderWater; + sc->Submit = Droid_Submit; + sc->Shutdown = Droid_Shutdown; + sc->GetDMAPos = Droid_GetDMAPos; + + sc->sn.buffer = malloc(sc->sn.samples*sc->sn.samplebits/8); + + sys_sc = sc; + +// pthread_mutex_unlock(&mutex); + + return 1; + } + return 0; +} +int (*pDroid_InitCard) (soundcardinfo_t *sc, int cardnum) = &Droid_InitCard; + diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index d83f660b7..b8b926194 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -1926,8 +1926,11 @@ qboolean RMod_LoadTexinfo (lump_t *l) for ( i=0 ; ivecs[0][j] = LittleFloat (in->vecs[0][j]); + out->vecs[1][j] = LittleFloat (in->vecs[1][j]); + } len1 = Length (out->vecs[0]); len2 = Length (out->vecs[1]); len1 = (len1 + len2)/2;