maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   ApkEnv support module development (https://talk.maemo.org/showthread.php?t=88250)

myname24 2012-12-14 21:20

Re: ApkEnv support module development
 
Quote:

Originally Posted by Art-O (Post 1304634)
I have Angry Birds Space version 1.2.3 so this probably doesn't work with any other versions.

But suprisingly it seems to work with Amazing Alex (i don't remember version)

previous version of angry birds /seasons/space work great . only the new ones and star wars .

B-RUNO 2012-12-14 21:42

Re: ApkEnv support module development
 
2 Attachment(s)
Quote:

Originally Posted by Art-O (Post 1304622)
I think that wrapper-generator is only used to make wrappers for
Android built in libraries (libc, gles, pthread etc. check apkenv source/compat directory) and it has nothing to do with modules.

Thanks Art-O your modules are working here, as you mentioned its missing sound but here follows the screenshot for The Amazing Alex running on the N900.

Art-O may ask how do you compile your modules if is not to much to ask :D.

Thanks for your contribution.
Regards

Art-O 2012-12-15 12:53

Re: ApkEnv support module development
 
Quote:

Originally Posted by B-RUNO (Post 1304652)
Art-O may ask how do you compile your modules if is not to much to ask :D.

Just drop [modulename].c into apkenv sources / modules folder and they get compiled with apkenv.

Quote:

Originally Posted by myname24 (Post 1304647)
previous version of angry birds /seasons/space work great . only the new ones and star wars .

New games use GLES2 so one needs to compile apkenv with:
GLES=2 make

But even when compiled with this they currently doesn't work and just SigFault when native_init is called. Does anyone have any ideas why this happens?

thp 2012-12-15 13:15

Re: ApkEnv support module development
 
Quote:

Originally Posted by Art-O (Post 1304295)
I started this ApkEnv support module development thread so that maybe we get more devs working on this.

Nice work there! :) Glad that somebody finally created a working module ;)

Quote:

Originally Posted by Art-O (Post 1304295)
which both lack sound support and I hope somebody could help with these.

Have a look at the nativeMixData function - all JNI methods take an JNIEnv * as their first method, the second one is the object on which the function is called (for our purposes, this is mostly "any" object - I usually pass a pointer to the global object there, but any random pointer should work). The third parameter is a long that you can use to pass an application-specific pointer. The fourth is a pointer to the buffer which is filled with audio data, and the fifth is the length of that buffer.

SDL has audio output built-in: SDL_OpenAudio() with the right parameters. At some point each game might open an AudioOutput and request a specific format (sample rate, channels, bitrate, buffer size, etc..). The SDL_AudioSpec "callback" then is a simple callback function that will be called by SDL and that should probably call some "native (audio) mixing data" function to fill the buffer.

Would be great if you could submit your modules as pull request to apkenv on Github :)

Art-O 2012-12-19 20:46

Re: ApkEnv support module development
 
Quote:

Originally Posted by thp (Post 1304800)
Have a look at the nativeMixData function - all JNI methods take an JNIEnv * as their first method, the second one is the object on which the function is called (for our purposes, this is mostly "any" object - I usually pass a pointer to the global object there, but any random pointer should work). The third parameter is a long that you can use to pass an application-specific pointer. The fourth is a pointer to the buffer which is filled with audio data, and the fifth is the length of that buffer.

Would be great if you could submit your modules as pull request to apkenv on Github :)

Hi, and thanks again for providing apkenv for us.

I have tryed to study this sound output for angry birds but I can't seem to figure out how to get it working. Thus far my code is this:

Typedef for nativeMixData:
Code:

typedef void (*angrybirds_mixdata_t)(JNIEnv *env, jobject obj, jlong paramLong, jbyteArray paramArrayOfByte, jint paramInt) SOFTFP;
Start audio output when CallVoidMethodV(startOutput) calls:
Code:

        /* Open the audio device */
        SDL_AudioSpec *desired, *obtained;

        desired = malloc(sizeof(SDL_AudioSpec));
        obtained = malloc(sizeof(SDL_AudioSpec));
        desired->freq=44100;
        desired->format=AUDIO_S16SYS;
        desired->channels=2;
        desired->samples=8192;
        desired->callback=my_audio_callback;
        desired->userdata=p0;

        if( SDL_InitSubSystem(SDL_INIT_AUDIO) < 0 )
            exit(-1);

        if ( SDL_OpenAudio(desired, obtained) < 0 )
            exit(-1);
       
        free(desired);
        SDL_PauseAudio(0);

I can see that this works as my_audio_callback function calls for more data:
Code:

void my_audio_callback(void *ud, Uint8 *stream, int len)
{
    printf("call mixdata (%i)\n",len);
    jlong tmplong = 0;
    jbyte* buffer = calloc(len,1);
    angrybirds_priv.native_mixdata(ENV(global), VM(global), (jlong)&tmplong, buffer, len);
    memcpy(stream,buffer,len);
    free(buffer);
}

But buffer seems to be completely empty (no audio data returned). Is that application-specific pointer important and is audio format correct or is problem with something else here?

PS. I do that pull request if I ever get this audio stuff working :)

thp 2012-12-20 11:12

Re: ApkEnv support module development
 
Quote:

Originally Posted by Art-O (Post 1306175)
But buffer seems to be completely empty (no audio data returned). Is that application-specific pointer important and is audio format correct or is problem with something else here?

When the AudioOutput gets created (NewObjectV), it gives you a long handle, the sample rate int, the number of channels int, the bitrate int and the buffer size int in the variable argument list. You need to use these, and especially pass the handle that you get as first parameter to the mixing function as third parameter. Also, there's no need to calloc/memcpy/free the buffer, you can directly provide the stream pointer to the mixing function.

Art-O 2012-12-20 18:42

Re: ApkEnv support module development
 
Quote:

Originally Posted by thp (Post 1306313)
When the AudioOutput gets created (NewObjectV), it gives you a long handle, the sample rate int, the number of channels int, the bitrate int and the buffer size int in the variable argument list. You need to use these, and especially pass the handle that you get as first parameter to the mixing function as third parameter. Also, there's no need to calloc/memcpy/free the buffer, you can directly provide the stream pointer to the mixing function.

Thanks for help, I finally got it working :D

I started new fork at https://github.com/Art-O/apkenv and made that pull request for this one.

Also updated attachment on front page.

Next stop Fruit Ninja audio ;)

B-RUNO 2012-12-20 20:43

Re: ApkEnv support module development
 
Quote:

Originally Posted by Art-O (Post 1306435)
Thanks for help, I finally got it working :D

I started new fork at https://github.com/Art-O/apkenv and made that pull request for this one.

Also updated attachment on front page.

Next stop Fruit Ninja audio ;)

Cheers Art-O you rock my friend the latest module work perfectly.
Appreciate regards

B-RUNO 2012-12-21 21:38

Re: ApkEnv support module development
 
1 Attachment(s)
Hey Art-O how do you locate the Init input and the OpenGL update methods on the decompiled apk.
Here is the screenshot of my decompiled apk.

Art-O 2012-12-21 23:52

Re: ApkEnv support module development
 
Quote:

Originally Posted by B-RUNO (Post 1306707)
Hey Art-O how do you locate the Init input and the OpenGL update methods on the decompiled apk.

When you start apkenv without proper module it reports needed methods for example angry birds:
Code:

Not supported yet, but found JNI methods:
    Java_com_rovio_ka3d_MyRenderer_nativeGetPossibleOrientations
    Java_com_rovio_ka3d_MyRenderer_nativePause
    Java_com_rovio_ka3d_MyRenderer_nativeResume
    JNI_OnLoad
    Java_com_rovio_ka3d_MyRenderer_nativeResize
    Java_com_rovio_ka3d_MyRenderer_nativeKeyInput
    Java_com_rovio_ka3d_MyRenderer_nativeInput
    Java_com_rovio_ka3d_MyRenderer_nativeUpdate
    ...

So just browse that treeview to com/rovio/ka3d/MyRenderer and there you can find all needed code written in java. Look for functions that start with "public native ..."


All times are GMT. The time now is 23:02.

vBulletin® Version 3.8.8