Commit 19a973bb authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Revert of Enable the volume slider in Ash for windows. (https://codereview.chromium.org/178883004/)

Reason for revert:
Experimentally reverting this CL because it may have broken AshTestHelperTest.AshTestHelper on Windows Vista . Will revert the revert if this CL is innocent

See http://build.chromium.org/p/chromium.win/builders/Vista%20Tests%20%282%29/builds/41640/steps/ash_unittests/logs/AshTestHelper

Original issue's description:
> Enable the volume slider in Ash for windows.
> 
> BUG=227247
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=255215

TBR=henrika@chromium.org,tommi@chromium.org,jennyz@chromium.org,dewittj@chromium.org,zturner@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=227247

Review URL: https://codereview.chromium.org/188693004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255363 0039d316-1c4b-4281-b951-d872f2087c98
parent aad4d0d3
......@@ -458,10 +458,6 @@
'system/user/user_observer.h',
'system/web_notification/web_notification_tray.cc',
'system/web_notification/web_notification_tray.h',
'system/win/audio/tray_audio_delegate_win.cc',
'system/win/audio/tray_audio_delegate_win.h',
'system/win/audio/tray_audio_win.cc',
'system/win/audio/tray_audio_win.h',
'touch/touch_hud_debug.cc',
'touch/touch_hud_debug.h',
'touch/touch_hud_projection.cc',
......
......@@ -8,7 +8,7 @@
namespace ash {
namespace system {
class ASH_EXPORT TrayAudioDelegate {
class TrayAudioDelegate {
public:
enum { kNoAudioDeviceIcon = -1 };
......
......@@ -61,9 +61,6 @@
#include "ash/system/chromeos/tray_display.h"
#include "ash/system/chromeos/tray_tracing.h"
#include "ui/message_center/message_center.h"
#elif defined(OS_WIN)
#include "ash/system/win/audio/tray_audio_win.h"
#include "media/audio/win/core_audio_util_win.h"
#endif
using views::TrayBubbleView;
......@@ -204,8 +201,6 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
AddTrayItem(tray_date_);
#elif defined(OS_WIN)
AddTrayItem(tray_accessibility_);
if (media::CoreAudioUtil::IsSupported())
AddTrayItem(new internal::TrayAudioWin(this));
AddTrayItem(new internal::TrayUpdate(this));
AddTrayItem(tray_date_);
#elif defined(OS_LINUX)
......
zturner@chromium.org
\ No newline at end of file
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/win/audio/tray_audio_delegate_win.h"
#include <audiopolicy.h>
#include <cmath>
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "media/audio/win/core_audio_util_win.h"
using base::win::ScopedComPtr;
namespace {
// Volume value which should be considered as muted in range [0, 100].
const int kMuteThresholdPercent = 1;
// Lowest volume which is considered to be audible in the range [0, 100].
const int kDefaultUnmuteVolumePercent = 4;
} // namespace
namespace ash {
namespace system {
void TrayAudioDelegateWin::AdjustOutputVolumeToAudibleLevel() {
if (GetOutputVolumeLevel() <= kMuteThresholdPercent)
SetOutputVolumeLevel(kDefaultUnmuteVolumePercent);
}
int TrayAudioDelegateWin::GetOutputDefaultVolumeMuteLevel() {
return kMuteThresholdPercent;
}
int TrayAudioDelegateWin::GetOutputVolumeLevel() {
ScopedComPtr<ISimpleAudioVolume> volume_control =
CreateDefaultVolumeControl();
if (!volume_control)
return 0;
float level = 0.0f;
if (FAILED(volume_control->GetMasterVolume(&level)))
return 0;
// MSVC prior to 2013 doesn't have a round function. The below code is not
// conformant to C99 round(), but since we know that 0 <= level <= 100, it
// should be ok.
return static_cast<int>(level + 0.5);
}
int TrayAudioDelegateWin::GetActiveOutputDeviceIconId() {
return kNoAudioDeviceIcon;
}
bool TrayAudioDelegateWin::HasAlternativeSources() {
return false;
}
bool TrayAudioDelegateWin::IsOutputAudioMuted() {
ScopedComPtr<ISimpleAudioVolume> volume_control =
CreateDefaultVolumeControl();
if (!volume_control)
return false;
BOOL mute = FALSE;
if (FAILED(volume_control->GetMute(&mute)))
return false;
return !!mute;
}
void TrayAudioDelegateWin::SetOutputAudioIsMuted(bool is_muted) {
ScopedComPtr<ISimpleAudioVolume> volume_control =
CreateDefaultVolumeControl();
if (!volume_control)
return;
volume_control->SetMute(is_muted, NULL);
}
void TrayAudioDelegateWin::SetOutputVolumeLevel(int level) {
ScopedComPtr<ISimpleAudioVolume> volume_control =
CreateDefaultVolumeControl();
if (!volume_control)
return;
float volume_level = static_cast<float>(level) / 100.0f;
volume_control->SetMasterVolume(volume_level, NULL);
}
ScopedComPtr<ISimpleAudioVolume>
TrayAudioDelegateWin::CreateDefaultVolumeControl() {
ScopedComPtr<ISimpleAudioVolume> volume_control;
ScopedComPtr<IAudioSessionManager> session_manager;
ScopedComPtr<IMMDevice> device =
media::CoreAudioUtil::CreateDefaultDevice(eRender, eConsole);
if (!device ||
FAILED(device->Activate(__uuidof(IAudioSessionManager), CLSCTX_ALL, NULL,
session_manager.ReceiveVoid()))) {
return volume_control;
}
session_manager->GetSimpleAudioVolume(NULL, FALSE,
volume_control.Receive());
return volume_control;
}
} // namespace system
} // namespace ash
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_DELEGATE_WIN_H_
#define ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_DELEGATE_WIN_H_
#include <audioclient.h>
#include <mmdeviceapi.h>
#include "ash/ash_export.h"
#include "ash/system/audio/tray_audio_delegate.h"
#include "base/compiler_specific.h"
#include "base/win/scoped_comptr.h"
namespace ash {
namespace system {
class ASH_EXPORT TrayAudioDelegateWin : public TrayAudioDelegate {
public:
virtual ~TrayAudioDelegateWin() {}
// Overridden from TrayAudioDelegate.
virtual void AdjustOutputVolumeToAudibleLevel() OVERRIDE;
virtual int GetOutputDefaultVolumeMuteLevel() OVERRIDE;
virtual int GetOutputVolumeLevel() OVERRIDE;
virtual int GetActiveOutputDeviceIconId() OVERRIDE;
virtual bool HasAlternativeSources() OVERRIDE;
virtual bool IsOutputAudioMuted() OVERRIDE;
virtual void SetOutputAudioIsMuted(bool is_muted) OVERRIDE;
virtual void SetOutputVolumeLevel(int level) OVERRIDE;
private:
base::win::ScopedComPtr<ISimpleAudioVolume> CreateDefaultVolumeControl();
};
} // namespace system
} // namespace ash
#endif // ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_DELEGATE_WIN_H_
\ No newline at end of file
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/win/audio/tray_audio_win.h"
#include "ash/system/win/audio/tray_audio_delegate_win.h"
namespace ash {
using system::TrayAudioDelegate;
using system::TrayAudioDelegateWin;
namespace internal {
TrayAudioWin::TrayAudioWin(SystemTray* system_tray)
: TrayAudio(system_tray,
scoped_ptr<TrayAudioDelegate>(new TrayAudioDelegateWin())) {
}
TrayAudioWin::~TrayAudioWin() {
}
} // namespace internal
} // namespace ash
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_WIN_H_
#define ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_WIN_H_
#include "ash/ash_export.h"
#include "ash/system/audio/tray_audio.h"
#include "base/memory/scoped_ptr.h"
namespace ash {
namespace internal {
class TrayAudioWin : public TrayAudio {
public:
explicit TrayAudioWin(SystemTray* system_tray);
virtual ~TrayAudioWin();
private:
DISALLOW_COPY_AND_ASSIGN(TrayAudioWin);
};
} // namespace internal
} // namespace ash
#endif // ASH_SYSTEM_WIN_AUDIO_TRAY_AUDIO_WIN_H_
\ No newline at end of file
......@@ -107,11 +107,6 @@ DesktopNotificationsTest::~DesktopNotificationsTest() {
void DesktopNotificationsTest::SetUp() {
ui::InitializeInputMethodForTesting();
#if defined(OS_WIN) && defined(USE_ASH)
// The system tray under Windows ash contains a volume slider which needs
// to talk to the audio hardware using COM.
com_initializer_.reset(new base::win::ScopedCOMInitializer());
#endif
#if defined(USE_AURA)
wm_state_.reset(new views::corewm::WMState);
#endif
......@@ -151,9 +146,6 @@ void DesktopNotificationsTest::TearDown() {
#endif
#if defined(USE_AURA)
wm_state_.reset();
#endif
#if defined(OS_WIN) && defined(USE_ASH)
com_initializer_.reset();
#endif
ui::ShutdownInputMethodForTesting();
}
......
......@@ -21,10 +21,6 @@
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN) && defined(USE_ASH)
#include "base/win/scoped_com_initializer.h"
#endif
#if defined(USE_AURA)
namespace views {
namespace corewm {
......@@ -138,9 +134,6 @@ class DesktopNotificationsTest : public testing::Test {
#if defined(USE_AURA)
scoped_ptr<views::corewm::WMState> wm_state_;
#endif
#if defined(OS_WIN) && defined(USE_ASH)
scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
#endif
DISALLOW_COPY_AND_ASSIGN(DesktopNotificationsTest);
};
......
......@@ -4,7 +4,7 @@
// Utility methods for the Core Audio API on Windows.
// Always ensure that Core Audio is supported before using these methods.
// Use media::CoreAudioUtil::IsSupported() for this purpose.
// Use media::CoreAudioIsSupported() for this purpose.
// Also, all methods must be called on a valid COM thread. This can be done
// by using the base::win::ScopedCOMInitializer helper class.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment