summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-06-13 13:47:02 -0700
committerGlenn Kasten <gkasten@google.com>2013-06-13 14:02:18 -0700
commite2ffd5b583da9d30d96710b0e8879e90b2b51d30 (patch)
tree9e03c688b0f8d3c807de2ca4233552eeb756a8cd
parent04411d3ed343added179703837c6c24444acce3b (diff)
downloadframeworks_av-e2ffd5b583da9d30d96710b0e8879e90b2b51d30.zip
frameworks_av-e2ffd5b583da9d30d96710b0e8879e90b2b51d30.tar.gz
frameworks_av-e2ffd5b583da9d30d96710b0e8879e90b2b51d30.tar.bz2
AudioRecord must be used as sp<> only
Bug: 9423855 Change-Id: I78ba8228c60dff11fb466156bb632c5dda45cdaf
-rw-r--r--include/media/AudioRecord.h4
-rw-r--r--include/media/stagefright/AudioSource.h2
-rw-r--r--media/libstagefright/AudioSource.cpp9
3 files changed, 6 insertions, 9 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 81be803..7aa3c24 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -161,7 +161,9 @@ public:
/* Terminates the AudioRecord and unregisters it from AudioFlinger.
* Also destroys all resources associated with the AudioRecord.
*/
- ~AudioRecord();
+protected:
+ virtual ~AudioRecord();
+public:
/* Initialize an AudioRecord that was created using the AudioRecord() constructor.
* Don't call set() more than once, or after an AudioRecord() constructor that takes parameters.
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index 99f3c3b..4c9aaad 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -73,7 +73,7 @@ private:
Condition mFrameAvailableCondition;
Condition mFrameEncodingCompletionCondition;
- AudioRecord *mRecord;
+ sp<AudioRecord> mRecord;
status_t mInitCheck;
bool mStarted;
int32_t mSampleRate;
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 3cf4d5c..bdd842f 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -49,8 +49,7 @@ static void AudioRecordCallbackFunction(int event, void *user, void *info) {
AudioSource::AudioSource(
audio_source_t inputSource, uint32_t sampleRate, uint32_t channelCount)
- : mRecord(NULL),
- mStarted(false),
+ : mStarted(false),
mSampleRate(sampleRate),
mPrevSampleTimeUs(0),
mNumFramesReceived(0),
@@ -91,9 +90,6 @@ AudioSource::~AudioSource() {
if (mStarted) {
reset();
}
-
- delete mRecord;
- mRecord = NULL;
}
status_t AudioSource::initCheck() const {
@@ -122,8 +118,7 @@ status_t AudioSource::start(MetaData *params) {
if (err == OK) {
mStarted = true;
} else {
- delete mRecord;
- mRecord = NULL;
+ mRecord.clear();
}