diff options
author | Glenn Kasten <gkasten@google.com> | 2014-01-13 10:21:48 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2014-01-24 13:19:59 -0800 |
commit | 38e905b3cbba4da443d799b16999989781afc6d8 (patch) | |
tree | 47b872b97f1af95c3e0ceefb1f8d56c9ae7a67fc /include/media/AudioTrack.h | |
parent | f0002d142e6d24c5438600b2c259679de710f8ac (diff) | |
download | frameworks_av-38e905b3cbba4da443d799b16999989781afc6d8.zip frameworks_av-38e905b3cbba4da443d799b16999989781afc6d8.tar.gz frameworks_av-38e905b3cbba4da443d799b16999989781afc6d8.tar.bz2 |
Refactor code related to I/O handles to reduce chance for leaks
The AudioRecord input handle code was refactored earlier
to fix a potential handle leak, and to simplify the code:
> Change-Id: I124dce344b1d11c2dd66ca5e2c9aec0c52c230e2
This changelist refactors AudioTrack similarly,
and adds further cleanup of both AudioTrack and AudioRecord.
We attempt to implement the rules for referencing counting I/O handles,
but there is still the possibility of a handle leak if the client process
dies after allocating the handle reference but before releasing it.
That issue is being tracked separately.
Details:
- AudioSystem::getOutput() is now called within createTrack_l
- restoreTrack_l was missing offload info
now it has the info available,
but is not yet being called for offloaded tracks
- AudioTrack::getOutput() is now const
- Remove getOutput_l()
Change-Id: I44a0a623d24fc5847bcac0939c276400568adbca
Diffstat (limited to 'include/media/AudioTrack.h')
-rw-r--r-- | include/media/AudioTrack.h | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index 644e55c..cb67321 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -454,7 +454,7 @@ public: * Returned value: * handle on audio hardware output */ - audio_io_handle_t getOutput(); + audio_io_handle_t getOutput() const; /* Returns the unique session ID associated with this track. * @@ -640,14 +640,12 @@ protected: size_t frameCount, audio_output_flags_t flags, const sp<IMemory>& sharedBuffer, - audio_io_handle_t output, size_t epoch); // can only be called when mState != STATE_ACTIVE void flush_l(); void setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount); - audio_io_handle_t getOutput_l(); // FIXME enum is faster than strcmp() for parameter 'from' status_t restoreTrack_l(const char *from); @@ -655,10 +653,11 @@ protected: bool isOffloaded_l() const { return (mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0; } - // Next 3 fields may be changed if IAudioTrack is re-created, but always != 0 + // Next 4 fields may be changed if IAudioTrack is re-created, but always != 0 sp<IAudioTrack> mAudioTrack; sp<IMemory> mCblkMemory; audio_track_cblk_t* mCblk; // re-load after mLock.unlock() + audio_io_handle_t mOutput; // returned by AudioSystem::getOutput() sp<AudioTrackThread> mAudioTrackThread; @@ -763,7 +762,6 @@ private: sp<DeathNotifier> mDeathNotifier; uint32_t mSequence; // incremented for each new IAudioTrack attempt - audio_io_handle_t mOutput; // cached output io handle int mClientUid; }; |