mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Backed out changeset df13b449ffcc (bug 1242874)
This commit is contained in:
parent
5ee6035efc
commit
0a62793b79
@ -201,11 +201,17 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig)
|
||||
NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(float *aVolume,
|
||||
bool* aMuted)
|
||||
{
|
||||
if (NS_WARN_IF(!aConfig)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
MOZ_ASSERT(aVolume);
|
||||
MOZ_ASSERT(aMuted);
|
||||
|
||||
// Window-less AudioChannelAgents are muted by default.
|
||||
if (!mWindow) {
|
||||
*aVolume = 0;
|
||||
*aMuted = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||
@ -225,13 +231,14 @@ AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig)
|
||||
"mute = %d, volume = %f, suspend = %d\n", this,
|
||||
config.mMuted, config.mVolume, config.mSuspend));
|
||||
|
||||
aConfig->SetConfig(config.mVolume, config.mMuted, config.mSuspend);
|
||||
*aVolume = config.mVolume;
|
||||
*aMuted = config.mMuted;
|
||||
|
||||
mIsRegToService = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioChannelAgent::NotifyStoppedPlaying()
|
||||
NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying()
|
||||
{
|
||||
if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
|
||||
!mIsRegToService) {
|
||||
|
@ -55,16 +55,6 @@ interface nsISuspendedTypes : nsISupports
|
||||
const uint32_t SUSPENDED_STOP_DISPOSABLE = 4;
|
||||
};
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
// It's defined in dom/audiochannel/AudioChannelService.h.
|
||||
class AudioPlaybackConfig;
|
||||
}
|
||||
}
|
||||
%}
|
||||
[ptr] native AudioPlaybackConfig(mozilla::dom::AudioPlaybackConfig);
|
||||
|
||||
[uuid(15c05894-408e-4798-b527-a8c32d9c5f8c)]
|
||||
interface nsIAudioChannelAgentCallback : nsISupports
|
||||
{
|
||||
@ -162,10 +152,15 @@ interface nsIAudioChannelAgent : nsISupports
|
||||
* Note: Gecko component SHOULD call this function first then start to
|
||||
* play audio stream only when return value is true.
|
||||
*
|
||||
* @param config
|
||||
* It contains the playback related states (volume/mute/suspend)
|
||||
* @return
|
||||
* normal state: the agent has registered with audio channel service and
|
||||
* the component should start playback.
|
||||
* muted state: the agent has registered with audio channel service but
|
||||
* the component should not start playback.
|
||||
* faded state: the agent has registered with audio channel service the
|
||||
* component should start playback as well as reducing the volume.
|
||||
*/
|
||||
void notifyStartedPlaying(in AudioPlaybackConfig config);
|
||||
void notifyStartedPlaying(out float volume, out bool muted);
|
||||
|
||||
/**
|
||||
* Notify the agent we no longer want to play.
|
||||
|
@ -452,14 +452,10 @@ FMRadio::EnableAudioChannelAgent()
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(mAudioChannelAgent);
|
||||
|
||||
AudioPlaybackConfig config;
|
||||
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
float volume = 0.0;
|
||||
bool muted = true;
|
||||
mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
|
||||
WindowVolumeChanged(volume, muted);
|
||||
|
||||
mAudioChannelAgentEnabled = true;
|
||||
}
|
||||
|
@ -5061,14 +5061,10 @@ HTMLMediaElement::NotifyAudioChannelAgent(bool aPlaying)
|
||||
AutoNoJSAPI nojsapi;
|
||||
|
||||
if (aPlaying) {
|
||||
AudioPlaybackConfig config;
|
||||
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
float volume = 0.0;
|
||||
bool muted = true;
|
||||
mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
|
||||
WindowVolumeChanged(volume, muted);
|
||||
} else {
|
||||
mAudioChannelAgent->NotifyStoppedPlaying();
|
||||
mAudioChannelAgent = nullptr;
|
||||
|
@ -734,14 +734,14 @@ AudioDestinationNode::InputMuted(bool aMuted)
|
||||
return;
|
||||
}
|
||||
|
||||
AudioPlaybackConfig config;
|
||||
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config);
|
||||
float volume = 0.0;
|
||||
bool muted = true;
|
||||
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
WindowVolumeChanged(volume, muted);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -712,15 +712,9 @@ nsSpeechTask::CreateAudioChannelAgent()
|
||||
mAudioChannelAgent->InitWithWeakCallback(mUtterance->GetOwner(),
|
||||
static_cast<int32_t>(AudioChannelService::GetDefaultAudioChannel()),
|
||||
this);
|
||||
|
||||
AudioPlaybackConfig config;
|
||||
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
float volume = 0.0f;
|
||||
bool muted = true;
|
||||
mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
|
||||
}
|
||||
|
||||
void
|
||||
@ -742,11 +736,9 @@ nsSpeechTask::WindowVolumeChanged(float aVolume, bool aMuted)
|
||||
NS_IMETHODIMP
|
||||
nsSpeechTask::WindowSuspendChanged(nsSuspendedTypes aSuspend)
|
||||
{
|
||||
if (aSuspend == nsISuspendedTypes::NONE_SUSPENDED &&
|
||||
mUtterance->mPaused) {
|
||||
if (aSuspend == nsISuspendedTypes::NONE_SUSPENDED) {
|
||||
Resume();
|
||||
} else if (aSuspend != nsISuspendedTypes::NONE_SUSPENDED &&
|
||||
!mUtterance->mPaused) {
|
||||
} else {
|
||||
Pause();
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -107,7 +107,6 @@ using mozilla::plugins::PluginModuleContentParent;
|
||||
#endif
|
||||
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
#include "AudioChannelService.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins::parent;
|
||||
@ -2290,19 +2289,14 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
} else {
|
||||
|
||||
dom::AudioPlaybackConfig config;
|
||||
rv = agent->NotifyStartedPlaying(&config);
|
||||
float volume = 0.0;
|
||||
bool muted = true;
|
||||
rv = agent->NotifyStartedPlaying(&volume, &muted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
rv = inst->WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
rv = inst->WindowSuspendChanged(config.mSuspend);
|
||||
rv = inst->WindowVolumeChanged(volume, muted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
@ -561,8 +561,9 @@ Telephony::HandleAudioAgentState()
|
||||
}
|
||||
} else if (!activeCall.IsNull() && !mIsAudioStartPlaying) {
|
||||
mIsAudioStartPlaying = true;
|
||||
AudioPlaybackConfig config;
|
||||
rv = mAudioAgent->NotifyStartedPlaying(&config);
|
||||
float volume;
|
||||
bool muted;
|
||||
rv = mAudioAgent->NotifyStartedPlaying(&volume, &muted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -576,12 +577,9 @@ Telephony::HandleAudioAgentState()
|
||||
// because the modem have not changed the call state yet. It causes that
|
||||
// the telephony can't be resumed. Therefore, we don't mute the telephony
|
||||
// at the beginning.
|
||||
rv = WindowVolumeChanged(1.0, false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = WindowSuspendChanged(config.mSuspend);
|
||||
volume = 1.0;
|
||||
muted = false;
|
||||
rv = WindowVolumeChanged(volume, muted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user