Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
b2104a90
Commit
b2104a90
authored
Aug 14, 2010
by
Paul Hunkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on the sound system
parent
9c7acc66
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
6 deletions
+75
-6
config.cfg
android/config.cfg
+1
-0
app-android.cpp
android/testproject/jni/app-android.cpp
+35
-1
lesson05.c
android/testproject/jni/lesson05.c
+2
-2
SDL_androidaudio.c
src/audio/android/SDL_androidaudio.c
+37
-3
SDL_androidaudio.o
src/audio/android/SDL_androidaudio.o
+0
-0
No files found.
android/config.cfg
0 → 100644
View file @
b2104a90
ANDROID_NDK=/home/paul/Projects/gsoc/sdk/android-ndk-r4
android/testproject/jni/app-android.cpp
View file @
b2104a90
...
@@ -26,6 +26,7 @@ static long _getTime(void){
...
@@ -26,6 +26,7 @@ static long _getTime(void){
}
}
JNIEnv
*
mEnv
=
NULL
;
JNIEnv
*
mEnv
=
NULL
;
JNIEnv
*
mAudioThreadEnv
=
NULL
;
//See the note below for why this is necessary
JavaVM
*
mVM
=
NULL
;
JavaVM
*
mVM
=
NULL
;
//Main activity
//Main activity
...
@@ -35,6 +36,7 @@ jclass mActivityInstance;
...
@@ -35,6 +36,7 @@ jclass mActivityInstance;
jmethodID
midCreateGLContext
;
jmethodID
midCreateGLContext
;
jmethodID
midFlipBuffers
;
jmethodID
midFlipBuffers
;
jmethodID
midEnableFeature
;
jmethodID
midEnableFeature
;
jmethodID
midUpdateAudio
;
extern
"C"
int
SDL_main
();
extern
"C"
int
SDL_main
();
extern
"C"
int
Android_OnKeyDown
(
int
keycode
);
extern
"C"
int
Android_OnKeyDown
(
int
keycode
);
...
@@ -54,6 +56,7 @@ static const int FEATURE_ACCEL = 2;
...
@@ -54,6 +56,7 @@ static const int FEATURE_ACCEL = 2;
//Accelerometer data storage
//Accelerometer data storage
float
fLastAccelerometer
[
3
];
float
fLastAccelerometer
[
3
];
/*******************************************************************************
/*******************************************************************************
Functions called by JNI
Functions called by JNI
*******************************************************************************/
*******************************************************************************/
...
@@ -77,8 +80,10 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved){
...
@@ -77,8 +80,10 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved){
midCreateGLContext
=
mEnv
->
GetStaticMethodID
(
cls
,
"createGLContext"
,
"()V"
);
midCreateGLContext
=
mEnv
->
GetStaticMethodID
(
cls
,
"createGLContext"
,
"()V"
);
midFlipBuffers
=
mEnv
->
GetStaticMethodID
(
cls
,
"flipBuffers"
,
"()V"
);
midFlipBuffers
=
mEnv
->
GetStaticMethodID
(
cls
,
"flipBuffers"
,
"()V"
);
midEnableFeature
=
mEnv
->
GetStaticMethodID
(
cls
,
"enableFeature"
,
"(II)V"
);
midEnableFeature
=
mEnv
->
GetStaticMethodID
(
cls
,
"enableFeature"
,
"(II)V"
);
midUpdateAudio
=
mEnv
->
GetStaticMethodID
(
cls
,
"updateAudio"
,
"([B)V"
);
if
(
!
midCreateGLContext
||
!
midFlipBuffers
||
!
midEnableFeature
){
if
(
!
midCreateGLContext
||
!
midFlipBuffers
||
!
midEnableFeature
||
!
midUpdateAudio
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Bad mids
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Bad mids
\n
"
);
}
else
{
}
else
{
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Good mids
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Good mids
\n
"
);
...
@@ -200,3 +205,32 @@ extern "C" void Android_EnableFeature(int featureid, bool enabled){
...
@@ -200,3 +205,32 @@ extern "C" void Android_EnableFeature(int featureid, bool enabled){
featureid
,
(
int
)
enabled
);
featureid
,
(
int
)
enabled
);
}
}
extern
"C"
void
Android_UpdateAudioBuffer
(
unsigned
char
*
buf
,
int
len
){
//Annoyingly we can't just call into Java from any thread. Because the audio
//callback is dispatched from the SDL audio thread (that wasn't made from
//java, we have to do some magic here to let the JVM know about the thread.
//Because everything it touches on the Java side is static anyway, it's
//not a big deal, just annoying.
if
(
!
mAudioThreadEnv
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Need to set up audio thread env
\n
"
);
mJVM
->
AttachCurrentThread
(
&
mAudioThreadEnv
,
NULL
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: ok
\n
"
);
}
jbyteArray
arr
=
mAudioThreadEnv
->
NewByteArray
(
len
);
//blah. We probably should rework this so we avoid the copy.
mAudioThreadEnv
->
SetByteArrayRegion
(
arr
,
0
,
len
,
(
jbyte
*
)
buf
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: copied
\n
"
);
mAudioThreadEnv
->
CallStaticVoidMethod
(
mActivityInstance
,
midUpdateAudio
,
arr
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: invoked
\n
"
);
}
android/testproject/jni/lesson05.c
View file @
b2104a90
...
@@ -428,7 +428,7 @@ void testAudio(){
...
@@ -428,7 +428,7 @@ void testAudio(){
while
(
SDL_GetAudioStatus
()
==
SDL_AUDIO_PLAYING
){
while
(
SDL_GetAudioStatus
()
==
SDL_AUDIO_PLAYING
){
//__android_log_print(ANDROID_LOG_INFO, "SDL","Still playing\n");
//__android_log_print(ANDROID_LOG_INFO, "SDL","Still playing\n");
//
SDL_Delay(100);
SDL_Delay
(
100
);
}
}
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"Closing down
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"Closing down
\n
"
);
...
@@ -511,7 +511,7 @@ int SDL_main( int argc, char **argv )
...
@@ -511,7 +511,7 @@ int SDL_main( int argc, char **argv )
resizeWindow
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
resizeWindow
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
//
testAudio();
testAudio
();
/* wait for events */
/* wait for events */
...
...
src/audio/android/SDL_androidaudio.c
View file @
b2104a90
...
@@ -29,13 +29,38 @@
...
@@ -29,13 +29,38 @@
#include "../SDL_audio_c.h"
#include "../SDL_audio_c.h"
#include "SDL_androidaudio.h"
#include "SDL_androidaudio.h"
extern
void
Android_UpdateAudioBuffer
(
unsigned
char
*
buf
,
int
len
);
#include <android/log.h>
#include <android/log.h>
static
int
static
int
AndroidAUD_OpenDevice
(
_THIS
,
const
char
*
devname
,
int
iscapture
)
AndroidAUD_OpenDevice
(
_THIS
,
const
char
*
devname
,
int
iscapture
)
{
{
SDL_AudioFormat
test_format
=
SDL_FirstAudioFormat
(
this
->
spec
.
format
);
int
valid_datatype
=
0
;
//TODO: Sample rates etc
//TODO: Sample rates etc
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"AndroidAudio Open
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"AndroidAudio Open
\n
"
);
this
->
hidden
=
SDL_malloc
(
sizeof
(
*
(
this
->
hidden
)));
if
(
!
this
->
hidden
)
{
SDL_OutOfMemory
();
return
0
;
}
SDL_memset
(
this
->
hidden
,
0
,
(
sizeof
*
this
->
hidden
));
while
((
!
valid_datatype
)
&&
(
test_format
))
{
this
->
spec
.
format
=
test_format
;
switch
(
test_format
)
{
case
AUDIO_S8
:
/*case AUDIO_S16LSB: */
valid_datatype
=
1
;
break
;
default:
test_format
=
SDL_NextAudioFormat
();
break
;
}
}
return
1
;
return
1
;
}
}
...
@@ -45,13 +70,11 @@ AndroidAUD_PlayDevice(_THIS)
...
@@ -45,13 +70,11 @@ AndroidAUD_PlayDevice(_THIS)
{
{
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"AndroidAudio Play
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"AndroidAudio Play
\n
"
);
//playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
//playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
#if 0
#if 0
// sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
// sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
// sound->rate = 22050; /* sample rate = 22050Hz */
// sound->rate = 22050; /* sample rate = 22050Hz */
// sound->vol = 127; /* volume [0..127] for [min..max] */
// sound->vol = 127; /* volume [0..127] for [min..max] */
// sound->pan = 64; /* balance [0..127] for [left..right] */
// sound->pan = 64; /* balance [0..127] for [left..right] */
...
@@ -64,6 +87,15 @@ AndroidAUD_PlayDevice(_THIS)
...
@@ -64,6 +87,15 @@ AndroidAUD_PlayDevice(_THIS)
static
Uint8
*
static
Uint8
*
AndroidAUD_GetDeviceBuf
(
_THIS
)
AndroidAUD_GetDeviceBuf
(
_THIS
)
{
{
//__android_log_print(ANDROID_LOG_INFO, "SDL", "****** get device buf\n");
// sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
// sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
Android_UpdateAudioBuffer
(
this
->
hidden
->
mixbuf
,
this
->
hidden
->
mixlen
);
return
this
->
hidden
->
mixbuf
;
/* is this right? */
return
this
->
hidden
->
mixbuf
;
/* is this right? */
}
}
...
@@ -71,12 +103,14 @@ static void
...
@@ -71,12 +103,14 @@ static void
AndroidAUD_WaitDevice
(
_THIS
)
AndroidAUD_WaitDevice
(
_THIS
)
{
{
/* stub */
/* stub */
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"****** wait device buf
\n
"
);
}
}
static
void
static
void
AndroidAUD_CloseDevice
(
_THIS
)
AndroidAUD_CloseDevice
(
_THIS
)
{
{
/* stub */
/* stub */
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"****** close device buf
\n
"
);
}
}
static
int
static
int
...
...
src/audio/android/SDL_androidaudio.o
deleted
100644 → 0
View file @
9c7acc66
File deleted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment