зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1225347 - Apply audio setting to volume parameter of Speak(). r=eeejay
This commit is contained in:
Родитель
d7478b6b1e
Коммит
b194b8e4da
|
@ -697,7 +697,6 @@ nsSpeechTask::CreateAudioChannelAgent()
|
|||
float volume = 0.0f;
|
||||
bool muted = true;
|
||||
mAudioChannelAgent->NotifyStartedPlaying(nsIAudioChannelAgent::AUDIO_AGENT_NOTIFY, &volume, &muted);
|
||||
WindowVolumeChanged(volume, muted);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "SpeechSynthesisVoice.h"
|
||||
#include "nsSynthVoiceRegistry.h"
|
||||
#include "nsSpeechTask.h"
|
||||
#include "AudioChannelService.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
@ -619,6 +620,22 @@ nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
|
|||
aUtterance.mVoice->GetVoiceURI(uri);
|
||||
}
|
||||
|
||||
// Get current audio volume to apply speech call
|
||||
float volume = aUtterance.Volume();
|
||||
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||
if (service) {
|
||||
nsCOMPtr<nsPIDOMWindow> topWindow =
|
||||
do_QueryInterface(aUtterance.GetOwner());
|
||||
if (topWindow) {
|
||||
float audioVolume = 1.0f;
|
||||
bool muted = false;
|
||||
service->GetState(topWindow->GetOuterWindow(),
|
||||
static_cast<uint32_t>(AudioChannelService::GetDefaultAudioChannel()),
|
||||
&audioVolume, &muted);
|
||||
volume = muted ? 0.0f : audioVolume * volume;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<nsSpeechTask> task;
|
||||
if (XRE_IsContentProcess()) {
|
||||
task = new SpeechTaskChild(&aUtterance);
|
||||
|
@ -628,13 +645,13 @@ nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
|
|||
aUtterance.mText,
|
||||
lang,
|
||||
uri,
|
||||
aUtterance.Volume(),
|
||||
volume,
|
||||
aUtterance.Rate(),
|
||||
aUtterance.Pitch());
|
||||
} else {
|
||||
task = new nsSpeechTask(&aUtterance);
|
||||
Speak(aUtterance.mText, lang, uri,
|
||||
aUtterance.Volume(), aUtterance.Rate(), aUtterance.Pitch(), task);
|
||||
volume, aUtterance.Rate(), aUtterance.Pitch(), task);
|
||||
}
|
||||
|
||||
return task.forget();
|
||||
|
|
Загрузка…
Ссылка в новой задаче