summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-01-20 13:44:40 -0800
committerGlenn Kasten <gkasten@google.com>2012-02-03 11:20:35 -0800
commit7378ca506e4e20c2b2d4e94a131cf1b95831adb5 (patch)
tree60a526b206858f294a66194ae3c1bcda08b2e65b /services
parent787bae0578fbaab6219ebf23494866b224d01438 (diff)
downloadframeworks_av-7378ca506e4e20c2b2d4e94a131cf1b95831adb5.zip
frameworks_av-7378ca506e4e20c2b2d4e94a131cf1b95831adb5.tar.gz
frameworks_av-7378ca506e4e20c2b2d4e94a131cf1b95831adb5.tar.bz2
Use 0 not NULL for sp<> and wp<>
Change-Id: Id1f0c89acefaceed6cb9ca7c165fce895e46d85b
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp20
-rw-r--r--services/audioflinger/AudioPolicyService.cpp18
2 files changed, 20 insertions, 18 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index f71ba0a..1c19057 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -809,9 +809,8 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
}
}
}
- if (thread != NULL) {
- result = thread->setParameters(keyValuePairs);
- return result;
+ if (thread != 0) {
+ return thread->setParameters(keyValuePairs);
}
return BAD_VALUE;
}
@@ -3206,7 +3205,7 @@ void AudioFlinger::DuplicatingThread::updateWaitTime()
mWaitTimeMs = UINT_MAX;
for (size_t i = 0; i < mOutputTracks.size(); i++) {
sp<ThreadBase> strong = mOutputTracks[i]->thread().promote();
- if (strong != NULL) {
+ if (strong != 0) {
uint32_t waitTimeMs = (strong->frameCount() * 2 * 1000) / strong->sampleRate();
if (waitTimeMs < mWaitTimeMs) {
mWaitTimeMs = waitTimeMs;
@@ -3330,9 +3329,12 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase()
}
}
mCblkMemory.clear(); // and free the shared memory
- if (mClient != NULL) {
+ if (mClient != 0) {
// Client destructor must run with AudioFlinger mutex locked
Mutex::Autolock _l(mClient->audioFlinger()->mLock);
+ // If the client's reference count drops to zero, the associated destructor
+ // must run with AudioFlinger lock held. Thus the explicit clear() rather than
+ // relying on the automatic clear() at end of scope.
mClient.clear();
}
}
@@ -3486,7 +3488,7 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size)
uint32_t vlr = mCblk->getVolumeLR();
snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n",
mName - AudioMixer::TRACK0,
- (mClient == NULL) ? getpid() : mClient->pid(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mStreamType,
mFormat,
mChannelMask,
@@ -3813,7 +3815,7 @@ void AudioFlinger::RecordThread::RecordTrack::stop()
void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size)
{
snprintf(buffer, size, " %05d %03u 0x%08x %05d %04u %01d %05u %08x %08x\n",
- (mClient == NULL) ? getpid() : mClient->pid(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mFormat,
mChannelMask,
mSessionId,
@@ -4528,7 +4530,7 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR
track = new RecordTrack(this, client, sampleRate,
format, channelMask, frameCount, flags, sessionId);
- if (track->getCblk() == NULL) {
+ if (track->getCblk() == 0) {
lStatus = NO_MEMORY;
goto Exit;
}
@@ -7102,7 +7104,7 @@ void AudioFlinger::EffectHandle::dump(char* buffer, size_t size)
bool locked = mCblk != NULL && tryLock(mCblk->lock);
snprintf(buffer, size, "\t\t\t%05d %05d %01u %01u %05u %05u\n",
- (mClient == NULL) ? getpid() : mClient->pid(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mPriority,
mHasControl,
!locked,
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 1dddbb3..755f51f 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -1362,7 +1362,7 @@ static audio_io_handle_t aps_open_output(void *service,
audio_policy_output_flags_t flags)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1376,7 +1376,7 @@ static audio_io_handle_t aps_open_dup_output(void *service,
audio_io_handle_t output2)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1386,7 +1386,7 @@ static audio_io_handle_t aps_open_dup_output(void *service,
static int aps_close_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->closeOutput(output);
@@ -1395,7 +1395,7 @@ static int aps_close_output(void *service, audio_io_handle_t output)
static int aps_suspend_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return PERMISSION_DENIED;
}
@@ -1406,7 +1406,7 @@ static int aps_suspend_output(void *service, audio_io_handle_t output)
static int aps_restore_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return PERMISSION_DENIED;
}
@@ -1422,7 +1422,7 @@ static audio_io_handle_t aps_open_input(void *service,
audio_in_acoustics_t acoustics)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1434,7 +1434,7 @@ static audio_io_handle_t aps_open_input(void *service,
static int aps_close_input(void *service, audio_io_handle_t input)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->closeInput(input);
@@ -1444,7 +1444,7 @@ static int aps_set_stream_output(void *service, audio_stream_type_t stream,
audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->setStreamOutput(stream, output);
@@ -1455,7 +1455,7 @@ static int aps_move_effects(void *service, int session,
audio_io_handle_t dst_output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->moveEffects(session, (int)src_output, (int)dst_output);