audioflinger: remove null checks

This code has null checks with intervening unconditional dereferences of
the potentially-null variable.

It's not clear that `mOutput` can ever be null to begin with. If it can
be, we have a few dereferences to guard. :)

Caught by the static analyzer:

frameworks/av/services/audioflinger/Threads.cpp:2671:19: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]
frameworks/av/services/audioflinger/Threads.cpp:2852:9: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]

Bug: None
Test: TreeHugger

Change-Id: I456581204718390088998a1fe2514dff63f6578f
gugelfrei
George Burgess IV 4 years ago committed by George Burgess
parent 697aec8505
commit 5e4d86f837

@ -1872,7 +1872,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge
// and the mute set to false).
mMasterVolume = audioFlinger->masterVolume_l();
mMasterMute = audioFlinger->masterMute_l();
if (mOutput && mOutput->audioHwDev) {
if (mOutput->audioHwDev) {
if (mOutput->audioHwDev->canSetMasterVolume()) {
mMasterVolume = 1.0;
}
@ -2830,7 +2830,7 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()
this/* srcThread */, this/* dstThread */);
}
audio_output_flags_t flags = mOutput != nullptr ? mOutput->flags : AUDIO_OUTPUT_FLAG_NONE;
audio_output_flags_t flags = mOutput->flags;
mediametrics::LogItem item(mMetricsId);
item.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS)
.set(AMEDIAMETRICS_PROP_ENCODING, formatToString(mFormat).c_str())

Loading…
Cancel
Save