Merge "Fix races related to volume and mute"
This commit is contained in:
@@ -712,7 +712,7 @@ float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t o
|
||||
}
|
||||
volume = thread->streamVolume(stream);
|
||||
} else {
|
||||
volume = mStreamTypes[stream].volume;
|
||||
volume = streamVolume_l(stream);
|
||||
}
|
||||
|
||||
return volume;
|
||||
@@ -724,7 +724,8 @@ bool AudioFlinger::streamMute(audio_stream_type_t stream) const
|
||||
return true;
|
||||
}
|
||||
|
||||
return mStreamTypes[stream].mute;
|
||||
AutoMutex lock(mLock);
|
||||
return streamMute_l(stream);
|
||||
}
|
||||
|
||||
status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
|
||||
@@ -1377,11 +1378,13 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge
|
||||
// There is no AUDIO_STREAM_MIN, and ++ operator does not compile
|
||||
for (audio_stream_type_t stream = (audio_stream_type_t) 0; stream < AUDIO_STREAM_CNT;
|
||||
stream = (audio_stream_type_t) (stream + 1)) {
|
||||
mStreamTypes[stream].volume = mAudioFlinger->streamVolumeInternal(stream);
|
||||
mStreamTypes[stream].mute = mAudioFlinger->streamMute(stream);
|
||||
mStreamTypes[stream].volume = mAudioFlinger->streamVolume_l(stream);
|
||||
mStreamTypes[stream].mute = mAudioFlinger->streamMute_l(stream);
|
||||
// initialized by stream_type_t default constructor
|
||||
// mStreamTypes[stream].valid = true;
|
||||
}
|
||||
// mStreamTypes[AUDIO_STREAM_CNT] exists but isn't explicitly initialized here,
|
||||
// because mAudioFlinger doesn't have one to copy from
|
||||
}
|
||||
|
||||
AudioFlinger::PlaybackThread::~PlaybackThread()
|
||||
@@ -1575,40 +1578,36 @@ uint32_t AudioFlinger::PlaybackThread::latency() const
|
||||
}
|
||||
}
|
||||
|
||||
status_t AudioFlinger::PlaybackThread::setMasterVolume(float value)
|
||||
void AudioFlinger::PlaybackThread::setMasterVolume(float value)
|
||||
{
|
||||
Mutex::Autolock _l(mLock);
|
||||
mMasterVolume = value;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t AudioFlinger::PlaybackThread::setMasterMute(bool muted)
|
||||
void AudioFlinger::PlaybackThread::setMasterMute(bool muted)
|
||||
{
|
||||
mMasterMute = muted;
|
||||
return NO_ERROR;
|
||||
Mutex::Autolock _l(mLock);
|
||||
setMasterMute_l(muted);
|
||||
}
|
||||
|
||||
status_t AudioFlinger::PlaybackThread::setStreamVolume(audio_stream_type_t stream, float value)
|
||||
void AudioFlinger::PlaybackThread::setStreamVolume(audio_stream_type_t stream, float value)
|
||||
{
|
||||
Mutex::Autolock _l(mLock);
|
||||
mStreamTypes[stream].volume = value;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t AudioFlinger::PlaybackThread::setStreamMute(audio_stream_type_t stream, bool muted)
|
||||
void AudioFlinger::PlaybackThread::setStreamMute(audio_stream_type_t stream, bool muted)
|
||||
{
|
||||
Mutex::Autolock _l(mLock);
|
||||
mStreamTypes[stream].mute = muted;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
float AudioFlinger::PlaybackThread::streamVolume(audio_stream_type_t stream) const
|
||||
{
|
||||
Mutex::Autolock _l(mLock);
|
||||
return mStreamTypes[stream].volume;
|
||||
}
|
||||
|
||||
bool AudioFlinger::PlaybackThread::streamMute(audio_stream_type_t stream) const
|
||||
{
|
||||
return mStreamTypes[stream].mute;
|
||||
}
|
||||
|
||||
// addTrack_l() must be called with ThreadBase::mLock held
|
||||
status_t AudioFlinger::PlaybackThread::addTrack_l(const sp<Track>& track)
|
||||
{
|
||||
@@ -1938,7 +1937,7 @@ bool AudioFlinger::MixerThread::threadLoop()
|
||||
property_get("ro.audio.silent", value, "0");
|
||||
if (atoi(value)) {
|
||||
ALOGD("Silence is golden");
|
||||
setMasterMute(true);
|
||||
setMasterMute_l(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2639,7 +2638,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
|
||||
property_get("ro.audio.silent", value, "0");
|
||||
if (atoi(value)) {
|
||||
ALOGD("Silence is golden");
|
||||
setMasterMute(true);
|
||||
setMasterMute_l(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3035,7 +3034,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
|
||||
property_get("ro.audio.silent", value, "0");
|
||||
if (atoi(value)) {
|
||||
ALOGD("Silence is golden");
|
||||
setMasterMute(true);
|
||||
setMasterMute_l(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -709,17 +709,13 @@ private:
|
||||
|
||||
virtual uint32_t latency() const;
|
||||
|
||||
virtual status_t setMasterVolume(float value);
|
||||
virtual status_t setMasterMute(bool muted);
|
||||
void setMasterVolume(float value);
|
||||
void setMasterMute(bool muted);
|
||||
|
||||
virtual float masterVolume() const { return mMasterVolume; }
|
||||
virtual bool masterMute() const { return mMasterMute; }
|
||||
void setStreamVolume(audio_stream_type_t stream, float value);
|
||||
void setStreamMute(audio_stream_type_t stream, bool muted);
|
||||
|
||||
virtual status_t setStreamVolume(audio_stream_type_t stream, float value);
|
||||
virtual status_t setStreamMute(audio_stream_type_t stream, bool muted);
|
||||
|
||||
virtual float streamVolume(audio_stream_type_t stream) const;
|
||||
virtual bool streamMute(audio_stream_type_t stream) const;
|
||||
float streamVolume(audio_stream_type_t stream) const;
|
||||
|
||||
sp<Track> createTrack_l(
|
||||
const sp<AudioFlinger::Client>& client,
|
||||
@@ -766,6 +762,7 @@ private:
|
||||
// PlaybackThread needs to find out if master-muted, it checks it's local
|
||||
// copy rather than the one in AudioFlinger. This optimization saves a lock.
|
||||
bool mMasterMute;
|
||||
void setMasterMute_l(bool muted) { mMasterMute = muted; }
|
||||
protected:
|
||||
SortedVector< wp<Track> > mActiveTracks;
|
||||
|
||||
@@ -891,7 +888,11 @@ private:
|
||||
PlaybackThread *checkPlaybackThread_l(audio_io_handle_t output) const;
|
||||
MixerThread *checkMixerThread_l(audio_io_handle_t output) const;
|
||||
RecordThread *checkRecordThread_l(audio_io_handle_t input) const;
|
||||
float streamVolumeInternal(audio_stream_type_t stream) const
|
||||
// no range check, AudioFlinger::mLock held
|
||||
bool streamMute_l(audio_stream_type_t stream) const
|
||||
{ return mStreamTypes[stream].mute; }
|
||||
// no range check, doesn't check per-thread stream volume, AudioFlinger::mLock held
|
||||
float streamVolume_l(audio_stream_type_t stream) const
|
||||
{ return mStreamTypes[stream].volume; }
|
||||
void audioConfigChanged_l(int event, audio_io_handle_t ioHandle, void *param2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user