summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/JetPlayer.cpp6
-rw-r--r--media/libmedia/SoundPool.cpp14
-rw-r--r--media/libmedia/ToneGenerator.cpp22
3 files changed, 15 insertions, 27 deletions
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index 59e538f..8fe5bb3 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -39,7 +39,6 @@ JetPlayer::JetPlayer(void *javaJetPlayer, int maxTracks, int trackBufferSize) :
mMaxTracks(maxTracks),
mEasData(NULL),
mEasJetFileLoc(NULL),
- mAudioTrack(NULL),
mTrackBufferSize(trackBufferSize)
{
ALOGV("JetPlayer constructor");
@@ -140,11 +139,10 @@ int JetPlayer::release()
free(mEasJetFileLoc);
mEasJetFileLoc = NULL;
}
- if (mAudioTrack) {
+ if (mAudioTrack != 0) {
mAudioTrack->stop();
mAudioTrack->flush();
- delete mAudioTrack;
- mAudioTrack = NULL;
+ mAudioTrack.clear();
}
if (mAudioBuffer) {
delete mAudioBuffer;
diff --git a/media/libmedia/SoundPool.cpp b/media/libmedia/SoundPool.cpp
index ee70ef7..e1e88ec 100644
--- a/media/libmedia/SoundPool.cpp
+++ b/media/libmedia/SoundPool.cpp
@@ -547,8 +547,8 @@ void SoundChannel::init(SoundPool* soundPool)
void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftVolume,
float rightVolume, int priority, int loop, float rate)
{
- AudioTrack* oldTrack;
- AudioTrack* newTrack;
+ sp<AudioTrack> oldTrack;
+ sp<AudioTrack> newTrack;
status_t status;
{ // scope for the lock
@@ -620,7 +620,7 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
ALOGE("Error creating AudioTrack");
goto exit;
}
- ALOGV("setVolume %p", newTrack);
+ ALOGV("setVolume %p", newTrack.get());
newTrack->setVolume(leftVolume, rightVolume);
newTrack->setLoop(0, frameCount, loop);
@@ -643,11 +643,9 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
}
exit:
- ALOGV("delete oldTrack %p", oldTrack);
- delete oldTrack;
+ ALOGV("delete oldTrack %p", oldTrack.get());
if (status != NO_ERROR) {
- delete newTrack;
- mAudioTrack = NULL;
+ mAudioTrack.clear();
}
}
@@ -884,7 +882,7 @@ SoundChannel::~SoundChannel()
}
// do not call AudioTrack destructor with mLock held as it will wait for the AudioTrack
// callback thread to exit which may need to execute process() and acquire the mLock.
- delete mAudioTrack;
+ mAudioTrack.clear();
}
void SoundChannel::dump()
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index f55b697..ebe1ba1 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -803,7 +803,6 @@ ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool
ALOGV("ToneGenerator constructor: streamType=%d, volume=%f", streamType, volume);
mState = TONE_IDLE;
- mpAudioTrack = NULL;
if (AudioSystem::getOutputSamplingRate(&mSamplingRate, streamType) != NO_ERROR) {
ALOGE("Unable to marshal AudioFlinger");
@@ -855,10 +854,10 @@ ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool
ToneGenerator::~ToneGenerator() {
ALOGV("ToneGenerator destructor");
- if (mpAudioTrack != NULL) {
+ if (mpAudioTrack != 0) {
stopTone();
- ALOGV("Delete Track: %p", mpAudioTrack);
- delete mpAudioTrack;
+ ALOGV("Delete Track: %p", mpAudioTrack.get());
+ mpAudioTrack.clear();
}
}
@@ -1047,14 +1046,9 @@ void ToneGenerator::stopTone() {
////////////////////////////////////////////////////////////////////////////////
bool ToneGenerator::initAudioTrack() {
- if (mpAudioTrack) {
- delete mpAudioTrack;
- mpAudioTrack = NULL;
- }
-
// Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
mpAudioTrack = new AudioTrack();
- ALOGV("Create Track: %p", mpAudioTrack);
+ ALOGV("Create Track: %p", mpAudioTrack.get());
mpAudioTrack->set(mStreamType,
0, // sampleRate
@@ -1081,12 +1075,10 @@ bool ToneGenerator::initAudioTrack() {
initAudioTrack_exit:
+ ALOGV("Init failed: %p", mpAudioTrack.get());
+
// Cleanup
- if (mpAudioTrack != NULL) {
- ALOGV("Delete Track I: %p", mpAudioTrack);
- delete mpAudioTrack;
- mpAudioTrack = NULL;
- }
+ mpAudioTrack.clear();
return false;
}