mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-20 12:34:50 +08:00
Implemented OpenSL-ES audio recording on Android
This commit is contained in:
@@ -783,6 +783,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
public static native void nativeSetenv(String name, String value);
|
||||
public static native void onNativeOrientationChanged(int orientation);
|
||||
public static native void nativeAddTouch(int touchId, String name);
|
||||
public static native void nativePermissionResult(int requestCode, boolean result);
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
@@ -1600,6 +1601,42 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void requestPermission(String permission, int requestCode) {
|
||||
if (mSingleton != null) {
|
||||
mSingleton.checkPermission(permission, requestCode);
|
||||
} else {
|
||||
nativePermissionResult(requestCode, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be overridden
|
||||
*/
|
||||
public void checkPermission(String permission, int requestCode) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
nativePermissionResult(requestCode, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{permission}, requestCode);
|
||||
} else {
|
||||
nativePermissionResult(requestCode, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
nativePermissionResult(requestCode, true);
|
||||
} else {
|
||||
nativePermissionResult(requestCode, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1076,7 +1076,7 @@ SDL_GetAudioDeviceName(int index, int iscapture)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
|
||||
if (iscapture && !current_audio.impl.HasCaptureSupport) {
|
||||
SDL_SetError("No capture support");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1230,7 +1230,7 @@ open_audio_device(const char *devname, int iscapture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
|
||||
if (iscapture && !current_audio.impl.HasCaptureSupport) {
|
||||
SDL_SetError("No capture support");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+336
-213
File diff suppressed because it is too large
Load Diff
@@ -32,14 +32,10 @@
|
||||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuff;
|
||||
int next_buffer;
|
||||
Uint8 *pmixbuff[NUM_BUFFERS];
|
||||
SDL_sem *playsem;
|
||||
#if 0
|
||||
SDL_sem *recsem;
|
||||
#endif
|
||||
};
|
||||
|
||||
void openslES_ResumeDevices(void);
|
||||
|
||||
@@ -123,6 +123,8 @@ SDL_bool Android_JNI_SetSystemCursor(int cursorID);
|
||||
SDL_bool Android_JNI_SupportsRelativeMouse(void);
|
||||
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled);
|
||||
|
||||
/* Request permission */
|
||||
SDL_bool Android_JNI_RequestPermission(const char *permission);
|
||||
|
||||
int SDL_GetAndroidSDKVersion(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user