Commit Graph

75 Commits (master)

Author SHA1 Message Date
Ian Fischer 9658f0dc27 Don't crash from a NULL device. 2013-07-17 22:12:54 -07:00
Aaron Culliney 46ad9cb7e1 test the correct obj for NULL and add some release logging for exceptional conditions 2013-07-10 19:23:04 -07:00
Aaron Culliney 7de1c1778d clean up some dead stores and some defensive coding for NULLs 2013-07-10 18:46:13 -07:00
Ryan Prichard 4921b53913 Revert part of "Switch audiotrack from JNI to BridgeKit."
* Restore the C file.

 * Revert the opensles.c changes.

 * Remove the AndroidAudioTrack class.  It is moved to BridgeKit.
2013-05-23 17:01:44 -07:00
Ryan Prichard 70217271b2 Switch audiotrack from JNI to BridgeKit.
It seems possible for two worker threads run concurrently, and when they
do, they trample on the global JNIEnv.  The AudioTrack.write call still
uses JNI for efficiency.
2013-05-23 16:11:01 -07:00
Marc Salem 81eb51319d Allow dedicated CPU time for high priority sources 2013-03-27 15:29:17 -07:00
Marc Salem 5616a5e90d Better management of buffers 2013-03-18 14:32:53 -07:00
Marc Salem 3b072a7138 Allow building in a different location 2013-03-18 12:58:21 -07:00
Marc Salem 65f9b65416 Expand list of models that get minimal buffering 2013-03-18 12:13:55 -07:00
Dmitry 5f779c800d Don't deadlock in alc_audiotrack_resume if audio was not playing. 2013-03-09 14:00:00 -08:00
Marc Salem 33c757593b Add Makefile with default arguments for ndk-build 2013-03-04 12:32:40 -08:00
Marc Salem b80e9d8f2c Fix ndk-build makefile and fix C99 compile errors 2013-03-04 12:21:27 -08:00
Marc Salem b77e73ea52 Add min sdk 8 to manifest 2013-03-04 12:07:30 -08:00
Marc Salem aa4ccadeef Support ARMv7a build without NEON 2013-02-12 21:15:33 -08:00
Marc Salem 559ef27135 Reduce buffer size if sample rate is 22k or less 2013-02-05 17:33:57 -08:00
Marc Salem 41695afd16 Fix build break 2013-02-03 19:17:24 -08:00
Marc Salem 9245e02e70 Less buffering for Kindle Fire 2013-01-29 13:30:07 -08:00
Marc Salem 092c6b20b9 Fix AudioTrack break 2013-01-29 12:10:24 -08:00
Marc Salem 6088afc49b Reduce warnings 2013-01-29 12:09:29 -08:00
Marc Salem 0165bd1cf3 Fix warnings 2013-01-25 12:03:08 -08:00
Marc Salem 2f73bdcf21 initial Android/OpenSL multiple context code 2013-01-09 17:19:25 -08:00
Marc Salem f83dd67491 Clean up warnings 2013-01-09 16:51:38 -08:00
Marc Salem 3d24e29d90 Missing parentheses 2013-01-09 14:04:29 -08:00
Marc Salem d7b90b6f37 reduce compile warnings 2013-01-08 14:46:05 -08:00
Marc Salem 3a36f7effe reduce comile warnings 2013-01-08 14:44:56 -08:00
Marc Salem 64f4849f20 Add console message to warn about dropped sounds 2013-01-08 14:43:54 -08:00
Joshua de6a762a71 Fixed resume to block until the audio thread is ready. 2013-01-08 11:27:17 -08:00
Joshua adc3e73bd1 Fixed issue where closing and then re-opening the audiotrack (Android 2.2 and below) would not reset the suspended state back to false/zero. 2013-01-08 11:27:16 -08:00
Eric Wing 448719f9b0 Moved CreateAudioPlayer related block from opensl_open_playback() to opensl_reset_playback(). This is to fix/properly support ALC_FREQUENCY. The problem is that if you set the frequency to say 22050, the playback is too fast (chipmunk). I believe this is because OpenAL Soft is changing its rate, but the OpenSL backend does not causing the mismatch.
The first problem in the OpenSL backend is that it hard codes the frequency to 44kHz.
The second problem is that the OpenSL backend initializes the player too early. I believe it is initializing at the device opening, and not the context creation where the ALC_FREQUENCY parameter is set/bound to.

So the solution is to move the CreateAudioPlayer stuff to this section which seems to be the reset_callback and respect the Frequency parameter passed through to the callback. I compared to the current mainline OpenAL Soft/OpenSL backend and their implementation seems to place the audio player creation in this same place so this at least makes this implementation more consistent with the official one.

This implementation does suggest to me that it doesn't handle multiple contexts well/correctly, but that is a problem independent of this fix.
2013-01-08 11:27:16 -08:00
Eric Wing dbef5ed4d6 Modified OpenSL ES backend to dynamically set the bufferCount based on the current Android OS version (at runtime). My previous change to lower it from 8 to 4 did in fact give us reports that Android 4.1 playback was breaking up. Marc Salem did warn me that this was a possibility because the 4.1 timing characteristics/requirements changed drastically. So the change is to check for the current OS version and set the bufferCount to 8 if >=4.1 and 4 if below 4.1.
One tricky modification is that JNI is needed in the opensles.c backend which impacts a function pointer previously not being set and is sensitive to initialization order. This changes the logic slightly to ensure initialization is correct and not overwritten by AudioTrack initialization.

Thanks to Josh Quick for help on the JNI code to get the Android API version number.
2013-01-08 11:27:16 -08:00
Eric Wing c5984e2280 Lowered bufferCount in OpenSL ES implementation from 8 to 4 because the base case latency of playing a single sound was terrible/worse than the Audiotrack version (which already contained my latency tweaks from the Martins Mozelko branch).
Lowering this value may negatively affect the mixing throughput for lots of sources. But this is a balancing act to not make the latency worse than the Audiotrack backend.

I tested on Kindle Fire (2.3), Nexus 7 (4.1), Motorola Xoom (3.?), Galaxy SII (2.3.4). In all cases, the latency seems to be about on par with the Audiotrack backend. Somewhat more subjective, the OpenSL ES backend with this change sounded a little cleaner to me.

I picked 4 somewhat arbitrarily. Being burned by non-power-of-two things before, I liked going from 4 to 8 and the latency improved to where I wanted it.

The latency is not really noticable on the Nexus 7 running 4.1 regardless of this change. This suggests a future fix dynamically change this constant back to 8 if running on 4.1+ if the Apportable values were well picked/tested to begin with.
2013-01-08 11:27:16 -08:00
Eric Wing 5d0763b364 Added #include <stdint.h> because the existing attempt to define if needed is causing redefinition errors in our complex project involving both pure C and C++ code. 2013-01-08 11:27:15 -08:00
Eric Wing ed15aa6ab2 Trivial fix to move int declaration to top because Android gcc defaults to C89 mode instead of C99. 2013-01-08 11:27:15 -08:00
Marc Salem b210d8e336 Only mix first two channels on android 2012-12-17 17:23:13 -08:00
Marc Salem 5136d4d204 Don't return error from alGetError() if there is no context 2012-11-08 15:58:04 -08:00
Marc Salem b8cadf5d51 fix makefile regression 2012-10-22 17:38:32 -07:00
Dmitry Skiba a5cc589a42 Made alBufferDataStatic to be alias for alBufferData. 2012-09-20 15:07:56 -07:00
Philippe Hausler f967eea5b7 avoid variable shadowing 2012-08-25 15:27:20 -07:00
Dmitry Skiba e05fc48629 Stop playback when we outght to. 2012-08-10 12:01:15 -07:00
Marc Salem 0b27808644 Make source limits configurable 2012-08-09 15:08:10 -07:00
Dmitry Skiba 6af28c7540 Don't suspend closed device. 2012-07-30 13:50:24 -07:00
Marc Salem 3984b64a1c Minimum cap on sources set to 4 2012-07-18 16:16:52 -07:00
Marc Salem ce354c8727 Script to fixup clang asm for binutils 2012-07-17 14:01:36 -07:00
Marc Salem b05a172f24 If there are no sources, have a more sensible cap on the number of sources 2012-07-17 13:54:53 -07:00
Marc Salem 8c6cc6ba4c Fail out of loop in callback if suspended 2012-07-17 13:35:06 -07:00
Marc Salem b84d760972 Avoid starting multiple threads if there are gratuitous lifecycle events 2012-07-17 13:33:15 -07:00
Marc Salem 265d8e9be3 Use -O3 2012-07-17 12:56:50 -07:00
Marc Salem 732c83453e Increase wait time, should be 5ms 2012-07-16 14:52:18 -07:00
Marc Salem b37787be4c Some tweaks to fix distortion on Jelly Bean 2012-07-16 14:52:11 -07:00
Ian Fischer bf85cd1993 Use android-ndk-r8. Make RELEASE_LOG available as well. 2012-07-13 14:25:42 -07:00