Skip to content
Permalink
Browse files

Merge audio capture work back into the mainline.

  • Loading branch information
icculus committed Aug 28, 2016
2 parents 06dcdc7 + b6daf1f commit 2da1ec8354ee2ddb836cf56efc956185ed36cce2
Showing with 2,444 additions and 1,140 deletions.
  1. +1 −0 .hgignore
  2. +1 −1 BUGS.txt
  3. +0 −1 VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
  4. +0 −3 VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters
  5. +0 −1 VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
  6. +0 −3 VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
  7. +0 −1 VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
  8. +0 −3 VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
  9. +0 −1 VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj
  10. +0 −3 VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters
  11. +0 −1 VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
  12. +0 −3 VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters
  13. +0 −1 VisualC/SDL/SDL.vcxproj
  14. +0 −1 VisualC/SDL/SDL.vcxproj.filters
  15. +0 −4 VisualC/SDL/SDL_VS2008.vcproj
  16. +0 −2 Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
  17. +0 −8 Xcode/SDL/SDL.xcodeproj/project.pbxproj
  18. +3 −0 android-project/AndroidManifest.xml
  19. +63 −2 android-project/src/org/libsdl/app/SDLActivity.java
  20. +81 −14 include/SDL_audio.h
  21. +0 −4 premake/VisualC/VS2008/SDL2/SDL2.vcproj
  22. +0 −1 premake/VisualC/VS2010/SDL2/SDL2.vcxproj
  23. +0 −3 premake/VisualC/VS2010/SDL2/SDL2.vcxproj.filters
  24. +0 −1 premake/VisualC/VS2012/SDL2/SDL2.vcxproj
  25. +0 −3 premake/VisualC/VS2012/SDL2/SDL2.vcxproj.filters
  26. +0 −2 premake/Xcode-iOS/SDL2/SDL2.xcodeproj/project.pbxproj
  27. +0 −2 premake/Xcode/Xcode3/SDL2/SDL2.xcodeproj/project.pbxproj
  28. +0 −2 premake/Xcode/Xcode4/SDL2/SDL2.xcodeproj/project.pbxproj
  29. +323 −144 src/audio/SDL_audio.c
  30. +0 −3 src/audio/SDL_audio_c.h
  31. +0 −25 src/audio/SDL_audiomem.h
  32. +11 −7 src/audio/SDL_sysaudio.h
  33. +1 −1 src/audio/SDL_wave.c
  34. +101 −59 src/audio/alsa/SDL_alsa_audio.c
  35. +73 −36 src/audio/android/SDL_androidaudio.c
  36. +0 −2 src/audio/android/SDL_androidaudio.h
  37. +7 −18 src/audio/arts/SDL_artsaudio.c
  38. +110 −55 src/audio/bsd/SDL_bsdaudio.c
  39. +174 −57 src/audio/coreaudio/SDL_coreaudio.c
  40. +1 −0 src/audio/coreaudio/SDL_coreaudio.h
  41. +193 −88 src/audio/directsound/SDL_directsound.c
  42. +2 −1 src/audio/directsound/SDL_directsound.h
  43. +96 −63 src/audio/disk/SDL_diskaudio.c
  44. +2 −3 src/audio/disk/SDL_diskaudio.h
  45. +43 −31 src/audio/dsp/SDL_dspaudio.c
  46. +22 −5 src/audio/dummy/SDL_dummyaudio.c
  47. +213 −60 src/audio/emscripten/SDL_emscriptenaudio.c
  48. +6 −16 src/audio/esd/SDL_esdaudio.c
  49. +11 −20 src/audio/fusionsound/SDL_fsaudio.c
  50. +9 −15 src/audio/haiku/SDL_haikuaudio.cc
  51. +17 −20 src/audio/nacl/SDL_naclaudio.c
  52. +116 −50 src/audio/nas/SDL_nasaudio.c
  53. +6 −18 src/audio/paudio/SDL_paudio.c
  54. +22 −27 src/audio/psp/SDL_pspaudio.c
  55. +138 −43 src/audio/pulseaudio/SDL_pulseaudio.c
  56. +3 −0 src/audio/pulseaudio/SDL_pulseaudio.h
  57. +27 −46 src/audio/qsa/SDL_qsa_audio.c
  58. +1 −1 src/audio/qsa/SDL_qsa_audio.h
  59. +6 −17 src/audio/sndio/SDL_sndioaudio.c
  60. +7 −14 src/audio/sun/SDL_sunaudio.c
  61. +125 −48 src/audio/winmm/SDL_winmm.c
  62. +27 −37 src/audio/xaudio2/SDL_xaudio2.c
  63. +123 −27 src/core/android/SDL_android.c
  64. +4 −2 src/core/android/SDL_android.h
  65. +74 −0 src/core/windows/SDL_windows.c
  66. +3 −0 src/core/windows/SDL_windows.h
  67. +1 −0 src/dynapi/SDL_dynapi_overrides.h
  68. +1 −0 src/dynapi/SDL_dynapi_procs.h
  69. +7 −7 src/video/android/SDL_androidevents.c
  70. +16 −3 src/video/emscripten/SDL_emscriptenevents.c
  71. +4 −0 src/video/emscripten/SDL_emscriptenvideo.h
  72. +4 −0 test/Makefile.in
  73. +165 −0 test/testaudiocapture.c
@@ -120,6 +120,7 @@ test/testbounds
test/torturethread
test/testdisplayinfo
test/testqsort
test/testaudiocapture
test/*.exe
test/*.dSYM
buildbot
@@ -1,7 +1,7 @@

Bugs are now managed in the SDL bug tracker, here:

http://bugzilla.libsdl.org/
https://bugzilla.libsdl.org/

You may report bugs there, and search to see if a given issue has already
been reported, discussed, and maybe even fixed.
@@ -81,7 +81,6 @@
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
@@ -174,9 +174,6 @@
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audiomem.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -208,7 +208,6 @@
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
@@ -159,9 +159,6 @@
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audiomem.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -73,7 +73,6 @@
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
@@ -174,9 +174,6 @@
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audiomem.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -287,7 +287,6 @@
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
@@ -420,9 +420,6 @@
<ClInclude Include="..\..\include\SDL_clipboard.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audiomem.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -81,7 +81,6 @@
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
@@ -174,9 +174,6 @@
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audiomem.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -294,7 +294,6 @@
<ClInclude Include="resource.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
@@ -230,7 +230,6 @@
<ClInclude Include="resource.h" />
<ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
<ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
<ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
@@ -771,10 +771,6 @@
RelativePath="..\..\src\audio\SDL_audiodev_c.h"
>
</File>
<File
RelativePath="..\..\src\audio\SDL_audiomem.h"
>
</File>
<File
RelativePath="..\..\src\audio\SDL_audiotypecvt.c"
>
@@ -376,7 +376,6 @@
FD99B9440DD52EDC00FB1D6B /* SDL_audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audio.c; sourceTree = "<group>"; };
FD99B9450DD52EDC00FB1D6B /* SDL_audio_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_audio_c.h; sourceTree = "<group>"; };
FD99B9460DD52EDC00FB1D6B /* SDL_audiocvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audiocvt.c; sourceTree = "<group>"; };
FD99B9490DD52EDC00FB1D6B /* SDL_audiomem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_audiomem.h; sourceTree = "<group>"; };
FD99B94A0DD52EDC00FB1D6B /* SDL_audiotypecvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audiotypecvt.c; sourceTree = "<group>"; };
FD99B94B0DD52EDC00FB1D6B /* SDL_mixer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_mixer.c; sourceTree = "<group>"; };
FD99B9520DD52EDC00FB1D6B /* SDL_sysaudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysaudio.h; sourceTree = "<group>"; };
@@ -795,7 +794,6 @@
FD99B9440DD52EDC00FB1D6B /* SDL_audio.c */,
FD99B9450DD52EDC00FB1D6B /* SDL_audio_c.h */,
FD99B9460DD52EDC00FB1D6B /* SDL_audiocvt.c */,
FD99B9490DD52EDC00FB1D6B /* SDL_audiomem.h */,
FD99B94A0DD52EDC00FB1D6B /* SDL_audiotypecvt.c */,
FD99B94B0DD52EDC00FB1D6B /* SDL_mixer.c */,
FD99B9520DD52EDC00FB1D6B /* SDL_sysaudio.h */,
@@ -64,7 +64,6 @@
04BD002812E6671800899322 /* SDL_audiocvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDB612E6671700899322 /* SDL_audiocvt.c */; };
04BD002912E6671800899322 /* SDL_audiodev.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDB712E6671700899322 /* SDL_audiodev.c */; };
04BD002A12E6671800899322 /* SDL_audiodev_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB812E6671700899322 /* SDL_audiodev_c.h */; };
04BD002B12E6671800899322 /* SDL_audiomem.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB912E6671700899322 /* SDL_audiomem.h */; };
04BD002C12E6671800899322 /* SDL_audiotypecvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDBA12E6671700899322 /* SDL_audiotypecvt.c */; };
04BD002D12E6671800899322 /* SDL_mixer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDBB12E6671700899322 /* SDL_mixer.c */; };
04BD003412E6671800899322 /* SDL_sysaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDC212E6671700899322 /* SDL_sysaudio.h */; };
@@ -218,7 +217,6 @@
04BD024412E6671800899322 /* SDL_audiocvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDB612E6671700899322 /* SDL_audiocvt.c */; };
04BD024512E6671800899322 /* SDL_audiodev.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDB712E6671700899322 /* SDL_audiodev.c */; };
04BD024612E6671800899322 /* SDL_audiodev_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB812E6671700899322 /* SDL_audiodev_c.h */; };
04BD024712E6671800899322 /* SDL_audiomem.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB912E6671700899322 /* SDL_audiomem.h */; };
04BD024812E6671800899322 /* SDL_audiotypecvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDBA12E6671700899322 /* SDL_audiotypecvt.c */; };
04BD024912E6671800899322 /* SDL_mixer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDBB12E6671700899322 /* SDL_mixer.c */; };
04BD025012E6671800899322 /* SDL_sysaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDC212E6671700899322 /* SDL_sysaudio.h */; };
@@ -563,7 +561,6 @@
DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDA112E6671700899322 /* SDL_coreaudio.h */; };
DB313F7717554B71006C0E22 /* SDL_audio_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB512E6671700899322 /* SDL_audio_c.h */; };
DB313F7817554B71006C0E22 /* SDL_audiodev_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB812E6671700899322 /* SDL_audiodev_c.h */; };
DB313F7917554B71006C0E22 /* SDL_audiomem.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDB912E6671700899322 /* SDL_audiomem.h */; };
DB313F7A17554B71006C0E22 /* SDL_sysaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDC212E6671700899322 /* SDL_sysaudio.h */; };
DB313F7B17554B71006C0E22 /* SDL_wave.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDC412E6671700899322 /* SDL_wave.h */; };
DB313F7C17554B71006C0E22 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD612E6671700899322 /* blank_cursor.h */; };
@@ -864,7 +861,6 @@
04BDFDB612E6671700899322 /* SDL_audiocvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audiocvt.c; sourceTree = "<group>"; };
04BDFDB712E6671700899322 /* SDL_audiodev.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audiodev.c; sourceTree = "<group>"; };
04BDFDB812E6671700899322 /* SDL_audiodev_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_audiodev_c.h; sourceTree = "<group>"; };
04BDFDB912E6671700899322 /* SDL_audiomem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_audiomem.h; sourceTree = "<group>"; };
04BDFDBA12E6671700899322 /* SDL_audiotypecvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_audiotypecvt.c; sourceTree = "<group>"; };
04BDFDBB12E6671700899322 /* SDL_mixer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_mixer.c; sourceTree = "<group>"; };
04BDFDC212E6671700899322 /* SDL_sysaudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysaudio.h; sourceTree = "<group>"; };
@@ -1307,7 +1303,6 @@
04BDFDB612E6671700899322 /* SDL_audiocvt.c */,
04BDFDB712E6671700899322 /* SDL_audiodev.c */,
04BDFDB812E6671700899322 /* SDL_audiodev_c.h */,
04BDFDB912E6671700899322 /* SDL_audiomem.h */,
04BDFDBA12E6671700899322 /* SDL_audiotypecvt.c */,
04BDFDBB12E6671700899322 /* SDL_mixer.c */,
04BDFDC212E6671700899322 /* SDL_sysaudio.h */,
@@ -1840,7 +1835,6 @@
04BD001912E6671800899322 /* SDL_coreaudio.h in Headers */,
04BD002712E6671800899322 /* SDL_audio_c.h in Headers */,
04BD002A12E6671800899322 /* SDL_audiodev_c.h in Headers */,
04BD002B12E6671800899322 /* SDL_audiomem.h in Headers */,
04BD003412E6671800899322 /* SDL_sysaudio.h in Headers */,
04BD003612E6671800899322 /* SDL_wave.h in Headers */,
04BD004212E6671800899322 /* blank_cursor.h in Headers */,
@@ -1996,7 +1990,6 @@
04BD024312E6671800899322 /* SDL_audio_c.h in Headers */,
04BD024612E6671800899322 /* SDL_audiodev_c.h in Headers */,
AAC070FD195606770073DCDF /* SDL_opengles2_gl2.h in Headers */,
04BD024712E6671800899322 /* SDL_audiomem.h in Headers */,
04BD025012E6671800899322 /* SDL_sysaudio.h in Headers */,
04BD025212E6671800899322 /* SDL_wave.h in Headers */,
04BD025D12E6671800899322 /* blank_cursor.h in Headers */,
@@ -2151,7 +2144,6 @@
DB313F7717554B71006C0E22 /* SDL_audio_c.h in Headers */,
DB313F7817554B71006C0E22 /* SDL_audiodev_c.h in Headers */,
AAC070FE195606770073DCDF /* SDL_opengles2_gl2.h in Headers */,
DB313F7917554B71006C0E22 /* SDL_audiomem.h in Headers */,
DB313F7A17554B71006C0E22 /* SDL_sysaudio.h in Headers */,
DB313F7B17554B71006C0E22 /* SDL_wave.h in Headers */,
DB313F7C17554B71006C0E22 /* blank_cursor.h in Headers */,
@@ -17,6 +17,9 @@
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- if you want to capture audio, uncomment this. -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->

<!-- Create a Java class extending SDLActivity and place it in a
directory under src matching the package, e.g.
src/com/gamemaker/game/MyGame.java
@@ -59,6 +59,7 @@

// Audio
protected static AudioTrack mAudioTrack;
protected static AudioRecord mAudioRecord;

/**
* This method is called by SDL before loading the native shared libraries.
@@ -106,6 +107,7 @@ public static void initialize() {
mJoystickHandler = null;
mSDLThread = null;
mAudioTrack = null;
mAudioRecord = null;
mExitCalledFromJava = false;
mBrokenLibraries = false;
mIsPaused = false;
@@ -544,7 +546,7 @@ public static Surface getNativeSurface() {
/**
* This method is called by SDL using JNI.
*/
public static int audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
@@ -623,13 +625,72 @@ public static void audioWriteByteBuffer(byte[] buffer) {
/**
* This method is called by SDL using JNI.
*/
public static void audioQuit() {
public static int captureOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);

Log.v(TAG, "SDL capture: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");

// Let the user pick a larger buffer if they really want -- but ye
// gods they probably shouldn't, the minimums are horrifyingly high
// latency already
desiredFrames = Math.max(desiredFrames, (AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);

if (mAudioRecord == null) {
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
channelConfig, audioFormat, desiredFrames * frameSize);

// see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
Log.e(TAG, "Failed during initialization of AudioRecord");
mAudioRecord.release();
mAudioRecord = null;
return -1;
}

mAudioRecord.startRecording();
}

Log.v(TAG, "SDL capture: got " + ((mAudioRecord.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioRecord.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");

return 0;
}

/** This method is called by SDL using JNI. */
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
return mAudioRecord.read(buffer, 0, buffer.length);
}

/** This method is called by SDL using JNI. */
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
return mAudioRecord.read(buffer, 0, buffer.length);
}


/** This method is called by SDL using JNI. */
public static void audioClose() {
if (mAudioTrack != null) {
mAudioTrack.stop();
mAudioTrack.release();
mAudioTrack = null;
}
}

/** This method is called by SDL using JNI. */
public static void captureClose() {
if (mAudioRecord != null) {
mAudioRecord.stop();
mAudioRecord.release();
mAudioRecord = null;
}
}


// Input

/**

0 comments on commit 2da1ec8

Please sign in to comment.