History log of /system/media/opensles/libopensles/CEngine.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
227b8b5fe36d5385bbb23d63198bc8e72bfda5d3 15-Oct-2010 Glenn Kasten <gkasten@google.com> Fix bug 3101211, partial fix for bug 3101247

IEngine.c: fixed numerous problems found by API test in
Engine::QueryNumSupportedExtensions
Engine::QuerySupportedExtension
Engine::IsExtensionSupported

sles.c:
failed engine create due to resource error did not return correct value

locks.c:
The mutex lock log usually indicates there is a deadlock. However,
it can also happen when there is heavy lock contention, such as
during the multithread torture test. Since it may be may be normal
behavior, I downgraded this log to a warning.

CEngine.c, ThreadPool.h, sles_allinclusive.h, sync.c, Android.mk:
Thread torture test was crashing on all platforms. Partial fix for Android:
- disable sync thread on Android
- disable async realize and async add interface on Android as they are not well tested

COutputMix.c:
Multiple output mixes were incorrectly handled on desktop. The
changed lines are under a non-Android conditional, so don't affect
production builds. But they are necessary in order to develop the
multithread torture test and measure code coverage using it.

Change-Id: I9003e97e0f84d9dc106622b0c925384c8ed61a7e
/system/media/opensles/libopensles/CEngine.c
2a25d97e40dbd5dd9195195a3a269095a4932097 05-Oct-2010 Glenn Kasten <gkasten@google.com> Object an interface initialization/destroy cleanup

Prior to this, object and interface fields were being initialized
and deinitialized in random places. This resulted in some real and
potential leaks, especially in the case of partial object construction.
There were even some places where fields were not being initialized
at all.

Details:

Move destructor for AndroidEffectCapabilities from CEngine::Destroy
to IAndroidEffectCapabilities deinit hook.
Move destructor for equalizer preset names from CEngine::Destroy
to IEngine deinit hook.
In Object::Destroy, call deinitializer for each initialized interface,
regardless whether it was ever exposed.
Remove double initialization of mStepSize in IPlaybackRate constructor.
Remove obsolete logs.
Add expose hooks that are called when interface is requested in
Engine::Create... or by DynamicInterface::AddInterface.
Always initialize all interfaces, even if not exposed
Fix typos in same-line comments on INTERFACE_ constants.
Add new interface state INITIALIZED: uninitialized -> initialized -> exposed.
DynamicInterface::Remove sets interface state to initialized (but
not exposed), instead of uninitialized.
Add explicit constructor calls to initialize fields in C structs
(e.g. smart pointers), using placement new. See also build warning
which was turned off with -Wno-invalid-offsetof.
Add comments about per-instance fields not associated with an interface.
Add default initializations for all per-instance fields that are
not associated with an interface, in case the object is only partially
constructed and then needs to be destroyed due to an error.
Add placement new comments.
Update comments on private per-instance fields not associated with an interface.
Move effect clears from the containing object destructor
(CAudioPlayer_Destroy and COutputMix_Destroy) to the interface
destructor. In this process this caught a bug that environmental
reverb and preset reverb were not being destroyed properly for an
audio player.
Add comments on interface hooks.
Add entries for interface destructors.
Add placement new (explicit constructor) and explicit destructor calls
for C++ fields in C struct.
Fix template instantiation error.
Move explicit calls to IBufferQueue_Destroy (now renamed to
IBufferQueue_deinit) from CAudioPlayer_Destroy and CAudioRecorder_Destroy
to be implicit via the BufferQueue interface deinit hook.
ThreadSync interface destructor now logs a warning if
ThreadSync::EnterCriticalSection was active at Engine::Destroy
Add some comments.
Clean up gMonitorFp close code.
Fix typo in log message.
Fix DynamicInterface to handle distinction between UNINITIALIZED and
INITIALIZED states for an interface, and to call the optional expose hook.
Do not use memset per interface, because the size of the last interface is unknown.
Set the v-table pointer while lock is held.
Add curlies to if statements.
Log errors if interfaces active during Object::Destroy, instead of asserting.
Log a warning if interface requests an interface but it is not available,
and is optional.
Add log with the class name and address of each new object.
Mark only interfaces with init hooks as INITIALIZED; others are UNINITIALIZED.

Change-Id: Ibb9c1b5f21e6195af6b20b2f7a5c7157905b735b
/system/media/opensles/libopensles/CEngine.c
182f822e7110bac4947ba8bded1c90ce8050c0fd 30-Sep-2010 Glenn Kasten <gkasten@google.com> Add new test, fix bugs found by test & code review

Bugs:
- EnvironmentalReverb::GetEnvironmentalReverbProperties left mutex
unlocked at end.
- buffer queue configuration test revealed not checking enough
combinations
- would have failed conformance test in a couple places
- replace peek locks by shared locks for SMP
- undocumented symbols were being exported by library
- fix handling of EffectSend for MIDI player

New test:
- Add reverb test

Miscellaneous:
- Move some FIXME to to-do list where they are easier to organize
- Fix typos in name of profile constant
- EffectSend::IsEnabled sets enabled = false for unsupported aux effect.
- Add curlies to if statements.
- Add more error logging.
- Fix indentation in switch statement.
- Add comments to makefile.

Details:
- Reduce visibility of libOpenSLESUT symbols.
- Use LOCAL_STATIC_LIBRARIES := libOpenSLESUT where needed in
applications.
- Move FIXME for OEM configuration, interface, SDL, Sndfile,
buffer queue, destroy to to-do list
- For SDL, disallow buffer queue with source not 44.1 kHz because it
is hard-wired to 44.1 kHz and there is no sample rate converter.
- return successful result for enabled effect send on unsupported
MIDI player
for future conformance testing

Change-Id: I39cb543169996f78c16e3ac363ea6157a9242743
/system/media/opensles/libopensles/CEngine.c
cc484cd4b7ede364e95209eb0468df3bc51f50e5 28-Sep-2010 Glenn Kasten <gkasten@google.com> Destroy for an unrealized engine was hanging

Change-Id: Ib11b15fe40726d2f9aad0c54fa66382824c95cfa
/system/media/opensles/libopensles/CEngine.c
51cb31b09f6af53402b3fbe7e9de29badc1155a2 21-Sep-2010 Glenn Kasten <gkasten@google.com> As part of API review, disable incomplete profiles

Don't compile dead code relating to unsupported features, but keep profiles for CT.
Move whole file conditionals from the source code to Android.mk,
by just not compiling the module for unsupported features.
There must an interface initialization hook present to expose an
interface implicitly or explicitly at object creation time, or
to dynamically add an interface after the object is created. As
a safety check, we also double-check for the initialization hook
when the application does a GetInterface.

Miscellaneous bug fixes:
- Fix warning "variable may be used uninitialized in this function".
- Fix build errors on SDL.
- Was using the wrong conditional for SDL.
- Fix typo mInterfaceContinued -> mInterfaceStates2 in AudioRecorder.
- Fix typo in IEngineCapabilities_init.

Other cleanup:
- Move ugly SDL-specific stuff out of the portable code.
- Combine duplicated code in CAudioPlayerDestroy and
CAudioRecorder_Destroy for freeing buffer queue memory.
- Add curlies to if and do statements.
- Line length 100.
- Decrease engine voices from 32 to 30 (based on max of 32 objects, 1 engine, 1 output mix).
- Disable IRecord_init log.
- Add symbolic link for Android configuration header file.
- Enable trace on Android.
- sl_int64_t is now unconditionally defined rather than only if
ANDROID defined, because it is used by OpenSLES_Android.h which
might be included by SDL also.
- Removed symlink for Android headers

Change-Id: I1a6389257bca09e3819923129a1193473e16669b
/system/media/opensles/libopensles/CEngine.c
03716fc64636a68ba59881508e80550b948f0f40 20-Sep-2010 Glenn Kasten <gkasten@google.com> Update logging

Fix bug in ifdef __cplusplus for OpenSLES_Android.h.
Clean up, simplify, and change level of a few log messages.
Use SL_LOGx macros instead of LOGx in SfPlayer.cpp.
Add comments regarding unsupported runtime log level checks.
Line length 100.

Change-Id: I52441ed6fbe9550248fa1b6944fc8e199f1f2724
/system/media/opensles/libopensles/CEngine.c
4f924ff768d761f53db6fa2dbfb794ba7a65e776 10-Sep-2010 Glenn Kasten <gkasten@google.com> Fix some race conditions and deadlocks.

Use strong reference counts to fix race conditions in these object dependencies:
- audio player on 3D Grouping
- MIDI player (or more specifically, the data sink locator) depends on LED or Vibra device
- audio player (or more specifically, the data sink locator) depends on output mix
Fix build errors on non-Android platforms.
Fix incorrect result code for EnvironmentalReverb::SetDensity.
Continue work on making Destroy more reliable:
- Destroy calls a pre-destroy hook, e.g. for Android audio players.
- Add new internal object state DESTROYING which is set when the pre-destroy hook returns.
- Abort (called by Destroy) now blocks until all async operations complete or are aborted.
Add curly braces around simple if and for statements.
Add extra parentheses around complex if expression in if statements.
Add more error logging in checkDataLocator.
Add Doxygen comments.
Remove spurious log entry when SL_DATALOCATOR_ANDROIDFD used.
Disable the unused Resume hooks, which are currently unused.
Remove some dead code in audio player create for Android.
Line length 100.
Prepare for fixing race condition in OutputMixExt by
moving mActiveMask and mTracks from IOutputMix to IOutputMixExt.
Update comments.
Continued work on Destroy reliability:
Do not poke around in mixer's data structures directly during
Object::Destroy for an audio player; instead ask the mixer nicely
and wait for it to do the job.
Move master copy of computed gains from Track to AudioPlayer, and then
let the mixer copy the gains locally when it needs them.
Add resume and predestroy hooks everywhere.
Predestroy hook returns a boolean.
/system/media/opensles/libopensles/CEngine.c
5bd7bea2bbc5133d26cdcd8b95d3452bd0116680 03-Sep-2010 Jean-Michel Trivi <jmtrivi@google.com> Implement SLAndroidEffectItf and SLAndroidEffectCapabilities.

Change-Id: Ia2cf6e3f0178189b0ed010690bc9906b61a746a7
/system/media/opensles/libopensles/CEngine.c
b0a0555e2fcad41d3ee0c45f0f75ed556dbee282 01-Sep-2010 Glenn Kasten <gkasten@google.com> Verify that no extant objects at engine shutdown

Log the total count and ID numbers of any stragglers.
Fix the order of steps in engine shutdown.
Add more comments.

Change-Id: I12b531bcd43c288f9988768193274bad6984748a
/system/media/opensles/libopensles/CEngine.c
bc1596c33e134859d3ae3182d641b2dd03405b5d 27-Aug-2010 Glenn Kasten <gkasten@google.com> Fix compile-problem on desktop, and SDL bug.

Fix bug caught by using gtest on desktop: SDL was not being shutdown properly when engine destroyed.
Fix compile problems on desktop for BassBoost, Equalizer, and Virtualizer.
Add new OpenSLESUT function: slesutResultToString.
Rename SDL_start to SDL_open to match SDL naming conventions.
Add SDL_close.
Add symlink for applications to use OpenSLESUT.h.

Change-Id: I6ef9895adc508b3b9570c79302c7a3046ca8246f
/system/media/opensles/libopensles/CEngine.c
974aacf14bfe6869b7d0cda3abcaef46af335487 26-Aug-2010 Glenn Kasten <gkasten@google.com> Fix bugs in BufferQueue automated test and related

Fix test bugs:
Clean up the player, mixer, and the engine (must be done in that order).
Re-enable 2 more tests; all 9 tests pass now.

Fix engine bugs:
IObject now has a de-init hook, which cleans up condition variable and mutex.
Run the de-initializers in reverse order so that IObject de-init hook is run last.
Replace the dedicated mEngine.mShutdownCond by the shared IObject condition variable.
Forgot to iniitalize mShtudownAck.
Unlocking the object mutex during CEngine_Destroy was bogus.

Miscellaneous logging and debugging improvements:
Track the source code location of the most recent mutex unlock.
Add more trace log options for detailed leave reasons.
Improve performance of trace log when disabled.
Turn on assert checking.
Check return value of pthread_cond_destroy and pthread_mutex_destroy.
Add comment.
Line length 100.

Change-Id: I23b7b495d439894b2fd31295a38cb73ef7b6be2e
/system/media/opensles/libopensles/CEngine.c
ff9f51f17b6c00beaa51698e22873a979c7b3ff6 27-Jul-2010 Glenn Kasten <gkasten@google.com> Back port to Eclair.

Change-Id: Ib5fbb2f877a02891c0cd8f55c0fa2a46a12adffb
/system/media/opensles/libopensles/CEngine.c
10ee2bc6119445f4339ecef998c40c9cc95057cd 24-Jul-2010 Glenn Kasten <gkasten@google.com> Add and update comments and use typedefs more.

Add Doxygen-style comments and convert some existing comments to Doxygen style.
Use typedef instead of struct as type name, e.g. rename struct Track to Track.

Change-Id: I251476c68304c9734210fcc5fe01d89544345af2
/system/media/opensles/libopensles/CEngine.c
1f5702ed2239c79b701aa8cc3c675798b34a9656 09-Jul-2010 Jean-Michel Trivi <jmtrivi@google.com> Use the AudioEffect framework to implement SLEqualizerItf.
EQ presets are stored in the engine because they need to be
available during the duration of the application, not just
during the life of the AudioPlayer that uses EQ.
Change-Id: Ib55ce32b54a4dca134831a87bc5bd2ae8c111035
/system/media/opensles/libopensles/CEngine.c
158dbd1a71a890d29490198c8e5019081ac94ac3 14-Jul-2010 Glenn Kasten <gkasten@google.com> Logging and comments to make testing easier.

Add utility function to print an IID.
checkDataFormat now prints a detailed log on invalid format.
Use SL_LOGE and SL_LOGV for logging instead of fprintf, we can easily redirect to standard Android logging eventually.
Add Doxygen-style comments.
Log more specific error message on invalid data format.
Use the full copyright header in one file.

Change-Id: I2342e29f57e97c3b5d94cb219d00e767a75e93fa
/system/media/opensles/libopensles/CEngine.c
f51f5c6ec99ebc8f2c833a68f232bc1c874a7f2f 09-Jul-2010 Glenn Kasten <gkasten@google.com> Bug fix and general code cleanup.

Trace debug now uses Android logging by LOGV/LOGE.
Added SL Utility Toolkit for OpenSL ES, similar to OpenAL UT.
Add a -DUSE_TRACE instead of -DNDEBUG and add it commented out to Android.mk.
LOGE for error returns, LOGV for all entry and exit.
Rename debug.c to trace.c.
slutPrintIID prints the symbolic name if known.
Fix bug in slQueryNumSupportedEngineInterfaces and
slQuerySupportedEngineInterfaces which were not
skipping over unavailable interfaces.
Use USE_CONFORMANCE to return SL_RESULT_FEATURE_UNSUPPORTED when not supported
and make some interfaces unavailable depending on USE_CONFORMANCE.
Move most FIXME to separate bug/to-do list.
Fix possible intermediate overflow in duration computation for sndfile.
Line length 100.
Address code review comments, disable LOG.
/system/media/opensles/libopensles/CEngine.c
15f9f5e609265dff9d6036af38bea084c42a702a 24-Jun-2010 Glenn Kasten <gkasten@google.com> Gain and transport attributes at mutex unlock.

Update both interface and player copies of mute/solo.
Move synchronous gain and transport updates to mutex unlock exclusive.
Update sync thread logic.
Keep track of player position using tracks in PCM frame units.
Implement solo.
Various volume-related fixes.
Mute solo fields are only in IMuteSolo, but IMuteSolo is
immediately after IVolume to make it easier to find.
Move Android volume fields into audio player.
Fix printf missing newline.
Only one copy of mute and solo.
Clean up comments.
Line length 100.
SDL gain and transport updates are synchronous.
Fix unused variable warnings.
Use symbol for number of stereo channels.
Rearrange fields to save memory.
Add comments.
Fix problems introduced during the last merge.

Change-Id: I121fcbe4189b06850983941f540942a745fc51fb
/system/media/opensles/libopensles/CEngine.c
7e5dd9fa6ab032d7eeaac79bee4370a133eda8c2 21-Jun-2010 Glenn Kasten <gkasten@google.com> Continued bug fixing.

Remove obsolete FIXMEs.
Fix copyright notices on two files.
Move interface ID lookup function to separate source file,
and replace O(n) linear search by O(1) perfect hash.
Use symbolic constants instead of magic numbers in SndFile and DeviceVolume.
Remove blank lines at EOF.
Pre-compute max index of devices at engine creation time.
Fix mute and gain bugs on SDL/SndFile.
Add interface name lookup function for debugging.

Change-Id: I31686c2bf874c9778e193648b74b6ab061950f8a
/system/media/opensles/libopensles/CEngine.c
bcf6e4f2a46544f599f6c77354650c6aad91ea5d 14-Jun-2010 Glenn Kasten <gkasten@google.com> More work on asynchronous operations.

Improve interface handling.
Interface state is kept using array of 4-bit fields instead of
separate bit-masks; this is simpler and uses less memory.
Better error handling in EffectSend.
Keep track of interfaces that have been gotten.
Asynchronous AddInterface and ResumeInterface.
Closures are now allocated dynamically.
Add resume hook.
Fix 2 bugs introduced during last effort.
Line length 100.
Continue asynchronous DynamicInterfaceManagement.
Implement asynchronous Object::Resume.
AbortAsyncOperation for Realize and Resume phase 1.
Implement asynchronous abort during phase 1.
ThreadPool bug fixes.
When destroying ThreadPool, free memory used by pending closures.
Don't enqueue additional closures while ThreadPool is shutting down.
Update comments and assertions.
Use 8-bits per interface state instead of 4-bits.
List official object states explicitly.
Add comments.
/system/media/opensles/libopensles/CEngine.c
437f9ab9914ea61112aa496a047162a0d22194cd 07-Jun-2010 Glenn Kasten <gkasten@google.com> Add note about bug in IMuteSolo channel count.

Change-Id: Iccb78019bbbffaa98eaa8877258d88a77c979e48

Remove spurious NDEBUG, init in same order as .h.

Change-Id: Ia30b30ce4dbc8f074632c275583b7ef6069141dc

Implement asynchronous Object.Realize

Added ThreadPool mechanism for asynchronous operations.
Fixed off-by-one bug in BufferQueue that didn't use the last buffer.
Added engine hooks for Realize and Destroy.
Realize hook and callback are now called with mutex unlocked.
Added new Object states realizing 1 and realizing 2, mapped to unrealized.
Asynchronous realize on an engine is forced to be synchronous.
Engine initialization now done at Realize, not during CreateEngine.

Change-Id: I9c11461dbeab97aec04f8266f268cfd16086b5a7

Port to Android.

Change-Id: I0fff9f32e4d374230ab940e00fe6b8429b143ed3

Shutdown the sync thread when engine is destroyed.

Change-Id: I197267e5eaa4a49cacb34bc6e6f9c6fa92b381b5

Mutex unlocked during the initialization phase of DynamicInterfaceManagement.AddInterface.

Change-Id: I16000a2c4f1f9e93075f08ac2eaad6a8f12ba9da

Dynamic interface removal is done with mutex unlocked.

Change-Id: I5317d859dee680ca1c96e803388f2475f7795099

Normalize SLboolean input parameters.

Store non-zero boolean value as SL_BOOLEAN_TRUE rather than original value.
Line length 100.

Change-Id: I867ae8dd328b1427be98dfd148e32fcba38ce409

More input parameter checks.

Line length 100.
Fix a few build warnings.

Change-Id: I78fb1415fed649e05a370cf60e015a7fe13ffe8c

Address code review comments.

Change-Id: Ic7f2c70ded42f3d0e5e92f173cf80e084e54fc89
/system/media/opensles/libopensles/CEngine.c