OSDN Git Service

Use sp<AudioTrack> instead of raw AudioTrack *
authorGlenn Kasten <gkasten@google.com>
Thu, 30 May 2013 21:33:29 +0000 (14:33 -0700)
committerGlenn Kasten <gkasten@google.com>
Mon, 3 Jun 2013 18:28:36 +0000 (11:28 -0700)
commit2799d743ee2ae5a25fe869a7f9c052acc029559f
tree5cab5ff06f7cae0025b93fdcd549cfb2ec72b755
parent7c684c622110af460025eff85082030947278430
Use sp<AudioTrack> instead of raw AudioTrack *

This change prepares for the new implementation of AudioTrack client, which
will require clients to use only sp<AudioTrack>, not raw AudioTrack *.
A raw delete will cause a race condition during AudioTrack destruction.

AudioTrack was made a RefBase by commit b68a91a70bc8d0d18e7404e14443d4e4020b3635
on 2011/11/15, when it was needed by OpenSL ES (for the callback protector).
At that time, the only other client that was also converted from
AudioTrack * to sp<AudioTrack> was android.media.AudioTrack JNI in
project frameworks/base (file android_media_AudioTrack.cpp).

Details:
 * Use .clear() instead of delete followed by = NULL.
 * ALOG %p need .get().
 * sp<> don't need to be listed in constructor initializer, if initially 0.
 * Use == 0 for sp<> vs == NULL for raw pointers.
 * Use if (sp != 0) instead of if (raw).

Change-Id: Ic7cad25795d6e862e112abdc227b6d33afdfce17
15 files changed:
include/media/AudioTrack.h
include/media/JetPlayer.h
include/media/SoundPool.h
include/media/ToneGenerator.h
include/media/stagefright/AudioPlayer.h
libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
libvideoeditor/lvpp/VideoEditorAudioPlayer.h
libvideoeditor/lvpp/VideoEditorPlayer.cpp
libvideoeditor/lvpp/VideoEditorPlayer.h
media/libmedia/JetPlayer.cpp
media/libmedia/SoundPool.cpp
media/libmedia/ToneGenerator.cpp
media/libmediaplayerservice/MediaPlayerService.cpp
media/libmediaplayerservice/MediaPlayerService.h
media/libstagefright/AudioPlayer.cpp