History log of /system/media/opensles/libopensles/CAudioPlayer.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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/CAudioPlayer.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/CAudioPlayer.c
ec3a5a5555af3ed612b70dc54ef96998a9256b9a 28-Sep-2010 Glenn Kasten <gkasten@google.com> Add MuteSolo checks for audio player and fix bugs

The specification says "This [SLMuteSoloItf] interface cannot be
exposed on a player whose audio format is mono." This has a lot of
implications ...

Deny an explicit interface request for SLMuteSoloItf at audio player
creation time if the player is known pre-realize to have mono channel
count (e.g. PCM buffer queue).

Deny a GetInterface on MuteSolo if channel count is known to be mono,
but allow it if the channel count is still unknown.

When DynamicSource (or its replacement) is implemented, it will be
possible for the application to have done a GetInterface successfully,
and then to change the source such that the MuteSolo interface is
no longer valid. In that case, return SL_RESULT_FEATURE_UNSUPPORTED
for most MuteSolo operations, if called when channel count is unknown
or is mono. We _do_ allow MuteSolo::GetChannelCount to succeed if
channel count is known to be mono.

Enhance the URI-based mute solo test to check some of the above,
and the interactive buffer queue test to get and test the channel count.

Add curly braces to if statements.

Other bug fixes:
- Do not rely on peek locks; they don't work on SMP.
- Channel count and sample rate were not being set correctly
for buffer queue data source audio players.
- CreateAudioPlayer and AudioRecorder were both referring to
application pointers more than once, with the possibility of
reading inconsistent data.

Change-Id: Ie0109cbddc0aff8a56c0b53d989fb2be823e627b
/system/media/opensles/libopensles/CAudioPlayer.c
3ac54e4d6e699467b608a4f0eda6023d50d3cd61 23-Sep-2010 Glenn Kasten <gkasten@google.com> Fix bug found by BufferQueue automated test

Fix bug for destroying partially constructed audio player.
Remove obsolete logging.

Change-Id: Ib186153bf50ed1311c021d53711ec90d000bdee2
/system/media/opensles/libopensles/CAudioPlayer.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/CAudioPlayer.c
31df22b193ea7c7c331d26a27fa6756a89c8ec3c 17-Sep-2010 Glenn Kasten <gkasten@google.com> Improve reliability of Object::Destroy / Create

Separated object construction from publishing, for better safety
with respect to the sync and debugger thread. Unpublished objects
exist and have an ID slot reserved, but the ID is not assigned.
Destroy of an unpublished object does the right thing.

Add pre-destroy checks:

- COutputMix all platforms: add check for players attached to
output mix. Object:: Destroy on an output mix that has at least
one attached player is a no-op, but will log an error.

- COutputMix for SDL: now asks the mixer callback to unlink output
mix from engine, and then blocks until SDL mixer callback
acknowledges the request; this avoids a race condition where the
SDL thread calls the mixer during destroy.

- C3DGroup: add check for players in group.
Object::Destroy on a 3D group that contains at least one player
is a no-op, but will log an error.

Object::Destroy on an audio player that is part of a 3D group now
removes the player from the 3D group during destroy.

Remove redundant field:

- CAudioPlayer.mOutputMix duplicated a field in DataSink.DataLocator_OutputMix;
removed mOutputMix and replaced by function CAudioPlayer_GetOutputMix
which gets the output mix from the data sink.

Remove dead code:

- IOutputMixExt_Destroy was obsolete.

Miscellaneous changes not related to destroy:
- Fixed an ancient bug in the class table for Listener object -
was using wrong offset for interfaces.
- Add curly braces around if, else, for bodies
- Add parentheses around complex conditionals
- Add some logging
- Fix indentation.
- Line length 100

Change-Id: I0035fe356e2a28c1932b5d265f881377aa77dc58
/system/media/opensles/libopensles/CAudioPlayer.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/CAudioPlayer.c
66f75c45c9aea410b1f913d76995661e72571b67 31-Aug-2010 Glenn Kasten <gkasten@google.com> Fix problems found by the mute solo test.

Bug fixes for USE_OUTPUTMIXEXT (desktop):
- SL_PLAYEVENT_HEADATNEWPOS was broken
- GetPosition is now accurate, with or without seeking
- Fix race condition between AudioPlayer and Track
- Duration is updated if initial estimate is too low (e.g. if unknown is reported as zero)
- GetPosition while pending Seek now returns that value so the Seek appears synchronous
- Remove useless code to retry Enqueues; now drop decoded data if Enqueue fails
For all source files touched, add curlies to the "if" statements.

Change-Id: I1f70d8e683bc92831848af20857347d45c6407a9
/system/media/opensles/libopensles/CAudioPlayer.c
9c03f04a9c6cc2a821182c8be8f2efe964a27efe 13-Aug-2010 Glenn Kasten <gkasten@google.com> Make internal implicit interfaces safer.

Add IsInterfaceInitialized.
Don't directly manipulate a buffer queue.
Call the interface via it's named entry points, not the v-table as it may not be initialized/available.
GetInterface enables the v-table not init.
Update Doxygen comments.
Line length 100.
Allow bool, true, and false in C code.
Add a verbose option to seek torture test.

Change-Id: I37c42834422759b881d2ffe4b171d9aa284fde98
/system/media/opensles/libopensles/CAudioPlayer.c
6aa121077e8981b7d9f46471bdaa1a11211057e8 27-Jul-2010 Glenn Kasten <gkasten@google.com> Fix leak of track slot when audio player destroyed

Move the link from audio player to associated output mix / track
from the effect send interface up to the audio player class.
Add some more comments.
Line length 100.

Change-Id: I4e2de5e673709e686f066d0bd852bac17996810f
/system/media/opensles/libopensles/CAudioPlayer.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/CAudioPlayer.c
23c38816f7c210afae5072fd44658c98fec7e119 17-Jul-2010 Glenn Kasten <gkasten@google.com> Buffer queue and audio player maintenance.

Known problems on Android only (SDL is ok):
High latency on first enqueue, or first after buffer underrun
Play after stop does not resume the current buffer.

Improvements:
Implement BufferQueue::Clear for both Android and SDL.
Play::SetPlayState to Stopped now works for SDL (not yet for Android), and
sets play cursor to start of current buffer.
Play::Pause and Play::Stop while playing now block until done for SDL.
SDL now calls buffer queue callback after each buffer completion, instead of when mixer needs a buffer.
Move SF_INFO sfinfo to CAudioPlayer so we always have good stuff like the sample rate etc.
BufferQueue::Enqueue on a successful enqueue to a formerly empty queue
now kicks off an attribute change followed by a synchronous call to a
hook when first buffer enqueued. Currently unused but could be a way to reduce latency.
Minor comment changes.
Add interface_cond_broadcast.
More logging of errors.
Include source file and line number in logs.
sles_to_android.cpp: needs code for #if 0 sections.
Disable trace logging of BufferQueue::Enqueue and GetState.
Fix printf warnings.
Fix typo in number of interfaces requested at CreateAudioPlayer.
Remove spurious printf and while loop.
Line length 100.
Add intermediate play states which need to be re-mapped.
Fix printf format warnings.
Re-organize the buffer queue initialization.
Implement true seeking based on position for libsndfile.
SndFile is working again, but just barely.
Make it build on non-Android platforms.
BufferQueue::RegisterCallback now checks for STOPPED play state.
Include function name in trace logs.
Enhance test to check buffer queue callbacks, get buffer queue state, get play state.
Fix bug with Stop while Paused not resetting buffer pointer.
Remove obsolete comments and #if 0.
Set enqueue attribute is state is PLAYING and the first buffer is enqueued.
Added slutPrintIIDs.
Update comments.
Fix build warnings.
Fix compile error introduced by the merge.
Fix runtime problems introduced during the merge.
Address code review comments:
- BufferQueue changes apply to AudioRecord also.
- Rename to conform to new naming conventions.
- Add comments.
Fix build warning.
Add interactive buffer queue test application.

Change-Id: I5b00545a599fd9dba96efb834fca2369d149eaaa
/system/media/opensles/libopensles/CAudioPlayer.c
f66a508b11e327670a6bf5a8cf9c106f215e3b39 21-Jul-2010 Jean-Michel Trivi <jmtrivi@google.com> Harmonize naming scheme for Android AudioPlayer related functions
with what is used for AudioRecorder.

Change-Id: I96ed88ff17a5fff12b2e17dd6cb84630cba8fad8
/system/media/opensles/libopensles/CAudioPlayer.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/CAudioPlayer.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/CAudioPlayer.c
9c2a7b1e9f8203bf9de26efca0f1f805038b1f2b 29-Jun-2010 Glenn Kasten <gkasten@google.com> Restore previous version of CAudioPlayer fields.

Addressed code review comments:
Move channel mute, channel solo, and channel count from IMuteSolo to CAudioPlayer.
Deferred support for IMuteSolo to CMIDIPlayer deferred until we hear back from working group.
Move comment marker to correct location.

We discussed the code review comments and agreed to restore the
previous handling of channel mute, channel solo, and channel count.
We will probably have to review this again later, depending on what
the working group says about MIDI Player. To make it easier to
examine the history later, I'm submitting the previous change as
is, followed immediately by this change which addresses the code
review comments.

Change-Id: I4d5594d70c1c2d5fb90980a8a0414177ff29d4a7
/system/media/opensles/libopensles/CAudioPlayer.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/CAudioPlayer.c
da18bcf20d4cceb715904717a5a8b1585f935080 24-Jun-2010 Jean-Michel Trivi <jmtrivi@google.com> Implement the SLMuteSoloItf interface.

Change-Id: I5ed3112046c4317fe752bc2545b3e168f7e8a18a
/system/media/opensles/libopensles/CAudioPlayer.c
9db8335361c67c4ed877f68218835df96ce43a4b 21-Jun-2010 Jean-Michel Trivi <jmtrivi@google.com> For Android code, use ANDROID flag rather then USE_ANDROID.

Change-Id: I4b5877d8b6aee37bb472c817a2a863104271a03b
/system/media/opensles/libopensles/CAudioPlayer.c
3cdc48ac145e12a40b0ff0f90e8c01bec269bc38 16-Jun-2010 Glenn Kasten <gkasten@google.com> Add limited volume support for USE_SNDFILE platform.

Fix build warnings.
Remove obsolete FIXME.
/system/media/opensles/libopensles/CAudioPlayer.c
95364617b16ca2e322a4e0faeda93a2750d29fd6 11-Jun-2010 Glenn Kasten <gkasten@google.com> Make test apps work on host platform.

Change-Id: Ia5ed73b0ff77eb16959b3a539ac33ea9e89a9f4c
/system/media/opensles/libopensles/CAudioPlayer.c
09f49a84b259d8b8c49a4d71b42ea801b2a9e8f2 02-Jun-2010 Glenn Kasten <gkasten@google.com> Improve resource recovery.

Better cleanup in AudioPlayer.Destroy.
Avoid mallocs in LEDArray and Equalizer.
Line length 100.

Change-Id: I2d22880b27ccf7e9038b398cae9287781fd82253

Continued work on threading.

Lay the groundwork for true asynchronous realize.
Call all callbacks with mutex unlocked.
C volatile is meaningless.
Start adding support for suspend/resume on interfaces.
Line length 100.

Change-Id: I631cb4f123143e4ef79c6c491d12b1e559857cab
/system/media/opensles/libopensles/CAudioPlayer.c
f6f90fc5202248e2ae0abde6e655d7186cebc6af 29-May-2010 Glenn Kasten <gkasten@google.com> Move platform-specific code to separate files. Use sles_allinclusive.h to really mean all inclusive. MuteSolo check channel count.

Change-Id: I96caab5be55a1f04342eb67b511309babd5a6916

Make a copy of data source and sink parameter to avoid dangling inputs. Pre-process URI scheme and MIME type using a perfect hash. Line length 100.

Change-Id: Icb1e1a7a9c6370eda1e15e61f0dff35c1d59d7fa

Fix merge problem on Android.

Change-Id: I70b724273147f3981550272990729a4a409e1f72

MIME type needs to be completely initialized.

Change-Id: I3766acfb170abc976506cf305fabd5548107f592

Remove MIME lookup and URI scheme lookup.

Change-Id: I7058dfef01c9db509ad5915d9f8099a720e6736b
/system/media/opensles/libopensles/CAudioPlayer.c
0263d22efc4ad9420b367ec61b5a1d1ec72cebb9 27-May-2010 Jean-Michel Trivi <jmtrivi@google.com> First pass at implementing support of SL_DATALOCATOR_URI in an SL ES
audio player data source.

Change-Id: Ie8dc3b88c667035cbb20d2180eed6f699b6e7c2b
/system/media/opensles/libopensles/CAudioPlayer.c
188a1af5a1d2e2c339cded3dc5bbd99c2fd89fef 29-May-2010 Glenn Kasten <gkasten@google.com> Continue splitting up source code.

Change-Id: Iad6caa5adf111f50ad1a3aa14fc31efc7d5b285e
/system/media/opensles/libopensles/CAudioPlayer.c