Closed Bug 859805 Opened 7 years ago Closed 7 years ago
libcubeb fails to initialize on Android 2
I'm getting working video WebRTC calls on a Galaxy S2 with Android 2.3.6, but audio fails. Looking at the logs seems to indicate libcubeb doesn't work correctly on Android 2.3.x: E/libOpenSLES(25487): slCreateEngine while another engine 0x513918 is active E/libOpenSLES(25487): slCreateEngine while another engine 0x513918 is active I/WindowOrientationListener( 2705): orientation = 344.26178 Tilt = 33.827026 -- -2 , 7 , 5 W/AudioFlinger( 2588): RecordThread: buffer overflow E/libOpenSLES(25487): slCreateEngine while another engine 0x513918 is active I/Gecko - Cubeb(25487): _ZN7android10AudioTrackC1EijiiijPFviPvS1_ES1_iitm: OK I/Gecko - Cubeb(25487): _ZN7android10AudioTrackD1Evtm: OK I/Gecko - Cubeb(25487): _ZNK7android10AudioTrack7latencyEvtm: OK I/Gecko - Cubeb(25487): _ZNK7android10AudioTrack9initCheckEvtm: OK I/Gecko - Cubeb(25487): error while loading _ZN7android10AudioTrack16getMinFrameCountEPi19audio_stream_type_tjtm: Symbol not found: tm I/Gecko - Cubeb(25487): _ZN7android10AudioTrack5startEvtm: OK I/Gecko - Cubeb(25487): _ZN7android10AudioTrack5pauseEvtm: OK I/Gecko - Cubeb(25487): _ZN7android10AudioTrack11getPositionEPjtm: OK I/Gecko - Cubeb(25487): _ZN7android10AudioTrack17setMarkerPositionEjtm: OK I/Gecko - Cubeb(25487): Could not find all the symbols we need. I/Gecko (25487): WARNING: cubeb_init failed: file /home/morbo/hg/mozilla-central/content/media/AudioStream.cpp, line 90
We assume that if the AudioTrack has a ctor signature of _ZN7android10AudioTrackC1EijiiijPFviPvS1_ES1_ii then we're on Android 2.3+ and that _ZN7android10AudioTrack16getMinFrameCountEPi19audio_stream_type_tj will be available. In this case, the former symbol is present and the latter is not. It should be easy to fix this by changing the detection to look for getMinFrameCount directly and fall back to the Froyo code if not available.
Er, wait, shouldn't get be getting the OpenSL libcubeb backend on 2.3 anyway?
This compiles, but I haven't been able to test it.
So, on Gingerbread (2.3), the mangled symbold for getMinFrameCount is: _ZN7android10AudioTrack16getMinFrameCountEPiij android::AudioTrack::getMinFrameCount(int*, int, unsigned int) while on ICS, the second int is a |audio_stream_type_t|, which is an enum with the same values, so we can load the old symbol, but pass the same value (3) as second parameter. However the enum that define the channel layout is similar on froyo and gingerbread, but different on ICS, so I made more adjustments to the code. And yeah, you're right that we should be using OpenSL on 2.3 (in fact, I had to comment out the opensl in cubeb.c so that cubeb picked the audiotrack backend, on my 2.3 device), but it could be great the audiotrack backend as a fallback, if, like here, OpenSL does not work for some reason.
Attachment #735777 - Flags: review?(kinetik)
Comment on attachment 735777 [details] [diff] [review] Add the mangled symbol for legacy getMinFrameCount on Android 2.3.x, and similar adjustments. r= Thanks, this is better than my approach.
Attachment #735777 - Flags: review?(kinetik) → review+
Oh, and "E/libOpenSLES(25487): slCreateEngine while another engine 0x513918 is active" probably explains the AudioTrack fallback, because according to http://mobilepearls.com/labs/native-android-api/opensles/, "OpenSL ES for Android supports a single engine per application, and up to 32 objects." :-(
That's going to hurt, because both WebRTC and libcubeb will try to open OpenSLES. I'm surprised things work on Android 4+ at all, they must have lifted that restriction.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
You need to log in before you can comment on or make changes to this bug.