summaryrefslogtreecommitdiff
path: root/libs/audioflinger/AudioPolicyService.cpp
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2009-10-24 01:38:58 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2009-10-24 01:38:58 -0700
commit7ed70c9515fe3df6eb1796717d73f23e7286b3e6 (patch)
treeca15e2090451457b722bb524c5f2c75421477c9f /libs/audioflinger/AudioPolicyService.cpp
parentadddd24f31291f733cd5f72898b92f13f37ae37c (diff)
parentbf96aaadd46fb5b0884070177faa16ec4f22e2ba (diff)
am bf96aaad: Merge change Icf10db28 into eclair
Merge commit 'bf96aaadd46fb5b0884070177faa16ec4f22e2ba' into eclair-mr2 * commit 'bf96aaadd46fb5b0884070177faa16ec4f22e2ba': Fix issue 2192181: AudioFlinger must provide separated methods to set VOICE_CALL stream volume and down link audio volume.
Diffstat (limited to 'libs/audioflinger/AudioPolicyService.cpp')
-rw-r--r--libs/audioflinger/AudioPolicyService.cpp48
1 files changed, 44 insertions, 4 deletions
diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp
index 5c3cc8e1e642..f71c99c0c4ae 100644
--- a/libs/audioflinger/AudioPolicyService.cpp
+++ b/libs/audioflinger/AudioPolicyService.cpp
@@ -495,6 +495,10 @@ status_t AudioPolicyService::stopTone()
return NO_ERROR;
}
+status_t AudioPolicyService::setVoiceVolume(float volume, int delayMs)
+{
+ return mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
+}
// ----------- AudioPolicyService::AudioCommandThread implementation ----------
@@ -577,6 +581,16 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
}
delete data;
}break;
+ case SET_VOICE_VOLUME: {
+ VoiceVolumeData *data = (VoiceVolumeData *)command->mParam;
+ LOGV("AudioCommandThread() processing set voice volume volume %f", data->mVolume);
+ command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
+ if (command->mWaitStatus) {
+ command->mCond.signal();
+ mWaitWorkCV.wait(mLock);
+ }
+ delete data;
+ }break;
default:
LOGW("AudioCommandThread() unknown command %d", command->mCommand);
}
@@ -597,7 +611,6 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
void AudioPolicyService::AudioCommandThread::startToneCommand(int type, int stream)
{
- Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
command->mCommand = START_TONE;
ToneData *data = new ToneData();
@@ -605,6 +618,7 @@ void AudioPolicyService::AudioCommandThread::startToneCommand(int type, int stre
data->mStream = stream;
command->mParam = (void *)data;
command->mWaitStatus = false;
+ Mutex::Autolock _l(mLock);
insertCommand_l(command);
LOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
mWaitWorkCV.signal();
@@ -612,11 +626,11 @@ void AudioPolicyService::AudioCommandThread::startToneCommand(int type, int stre
void AudioPolicyService::AudioCommandThread::stopToneCommand()
{
- Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
command->mCommand = STOP_TONE;
command->mParam = NULL;
command->mWaitStatus = false;
+ Mutex::Autolock _l(mLock);
insertCommand_l(command);
LOGV("AudioCommandThread() adding tone stop");
mWaitWorkCV.signal();
@@ -626,7 +640,6 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float
{
status_t status = NO_ERROR;
- Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
command->mCommand = SET_VOLUME;
VolumeData *data = new VolumeData();
@@ -639,6 +652,7 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float
} else {
command->mWaitStatus = false;
}
+ Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d", stream, volume, output);
mWaitWorkCV.signal();
@@ -654,7 +668,6 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle,
{
status_t status = NO_ERROR;
- Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
command->mCommand = SET_PARAMETERS;
ParametersData *data = new ParametersData();
@@ -666,6 +679,7 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle,
} else {
command->mWaitStatus = false;
}
+ Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
LOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d", keyValuePairs.string(), ioHandle, delayMs);
mWaitWorkCV.signal();
@@ -677,6 +691,32 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle,
return status;
}
+status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume, int delayMs)
+{
+ status_t status = NO_ERROR;
+
+ AudioCommand *command = new AudioCommand();
+ command->mCommand = SET_VOICE_VOLUME;
+ VoiceVolumeData *data = new VoiceVolumeData();
+ data->mVolume = volume;
+ command->mParam = data;
+ if (delayMs == 0) {
+ command->mWaitStatus = true;
+ } else {
+ command->mWaitStatus = false;
+ }
+ Mutex::Autolock _l(mLock);
+ insertCommand_l(command, delayMs);
+ LOGV("AudioCommandThread() adding set voice volume volume %f", volume);
+ mWaitWorkCV.signal();
+ if (command->mWaitStatus) {
+ command->mCond.wait(mLock);
+ status = command->mStatus;
+ mWaitWorkCV.signal();
+ }
+ return status;
+}
+
// insertCommand_l() must be called with mLock held
void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *command, int delayMs)
{