summaryrefslogtreecommitdiffstats
path: root/include/media/AudioRecord.h
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-07-12 09:05:58 -0700
committerGlenn Kasten <gkasten@google.com>2012-07-13 14:49:12 -0700
commit68337edf595a0c345ba4b8adcd4f1e541a1d7eb7 (patch)
tree121fce48f2765c8d13ecbc84dcf06c44d62096b4 /include/media/AudioRecord.h
parent9cca4c6d976d2d4127286e9eaa54d1b99880c25c (diff)
downloadframeworks_av-68337edf595a0c345ba4b8adcd4f1e541a1d7eb7.zip
frameworks_av-68337edf595a0c345ba4b8adcd4f1e541a1d7eb7.tar.gz
frameworks_av-68337edf595a0c345ba4b8adcd4f1e541a1d7eb7.tar.bz2
AudioRecord client threading cleanup
Rename ClientRecordThread to AudioRecordThread to be more similar to AudioTrack naming. Only create the thread once, and use resume() and pause() for start() and stop(). This will allow us to have a known client callback thread tid that we can pass to AudioFlinger before start(). mActive: Made mActive a bool not int. mActive is protected by mLock; volatile is meaningless. Fixed a few places where mActive was accessed without a lock: - stopped() - processAudioBuffer() These aren't used internally, so no need for _l() versions. Change-Id: I4b8a5c90f3a22d3894b344564cb1c5aef4f1fda2
Diffstat (limited to 'include/media/AudioRecord.h')
-rw-r--r--include/media/AudioRecord.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 01ab8c7..f7ebd39 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -316,18 +316,31 @@ private:
AudioRecord& operator = (const AudioRecord& other);
/* a small internal class to handle the callback */
- class ClientRecordThread : public Thread
+ class AudioRecordThread : public Thread
{
public:
- ClientRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
+ AudioRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
+
+ // Do not call Thread::requestExitAndWait() without first calling requestExit().
+ // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough.
+ virtual void requestExit();
+
+ void pause(); // suspend thread from execution at next loop boundary
+ void resume(); // allow thread to execute, if not requested to exit
+
private:
friend class AudioRecord;
virtual bool threadLoop();
- virtual status_t readyToRun();
AudioRecord& mReceiver;
+ virtual ~AudioRecordThread();
+ Mutex mMyLock; // Thread::mLock is private
+ Condition mMyCond; // Thread::mThreadExitedCondition is private
+ bool mPaused; // whether thread is currently paused
};
- bool processAudioBuffer(const sp<ClientRecordThread>& thread);
+ // body of AudioRecordThread::threadLoop()
+ bool processAudioBuffer(const sp<AudioRecordThread>& thread);
+
status_t openRecord_l(uint32_t sampleRate,
audio_format_t format,
audio_channel_mask_t channelMask,
@@ -336,12 +349,10 @@ private:
audio_io_handle_t getInput_l();
status_t restoreRecord_l(audio_track_cblk_t*& cblk);
- sp<ClientRecordThread> mClientRecordThread;
- status_t mReadyToRun;
+ sp<AudioRecordThread> mAudioRecordThread;
mutable Mutex mLock;
- Condition mCondition;
- volatile int32_t mActive;
+ bool mActive; // protected by mLock
// for client callback handler
callback_t mCbf;