OSDN Git Service

Object an interface initialization/destroy cleanup
authorGlenn Kasten <gkasten@google.com>
Tue, 5 Oct 2010 14:46:26 +0000 (07:46 -0700)
committerGlenn Kasten <gkasten@google.com>
Tue, 5 Oct 2010 23:45:20 +0000 (16:45 -0700)
commit2a25d97e40dbd5dd9195195a3a269095a4932097
treeb4e779a7e3d4e3ccf93d574b5442e955a80f104d
parent182f822e7110bac4947ba8bded1c90ce8050c0fd
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
25 files changed:
opensles/libopensles/CAudioPlayer.c
opensles/libopensles/CAudioRecorder.c
opensles/libopensles/CEngine.c
opensles/libopensles/IAndroidEffect.c
opensles/libopensles/IAndroidEffectCapabilities.c
opensles/libopensles/IBassBoost.c
opensles/libopensles/IBufferQueue.c
opensles/libopensles/IDeviceVolume.c
opensles/libopensles/IDynamicInterfaceManagement.c
opensles/libopensles/IDynamicSource.c
opensles/libopensles/IEngine.c
opensles/libopensles/IEnvironmentalReverb.c
opensles/libopensles/IEqualizer.c
opensles/libopensles/IMetadataExtraction.c
opensles/libopensles/IObject.c
opensles/libopensles/IPlaybackRate.c
opensles/libopensles/IPresetReverb.c
opensles/libopensles/IRecord.c
opensles/libopensles/IThreadSync.c
opensles/libopensles/IVirtualizer.c
opensles/libopensles/android_AudioPlayer.cpp
opensles/libopensles/android_AudioRecorder.cpp
opensles/libopensles/android_OutputMix.cpp
opensles/libopensles/sles.c
opensles/libopensles/sles_allinclusive.h