<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[171069] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/171069">171069</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2014-07-14 11:17:34 -0700 (Mon, 14 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] don't enable low power audio mode on external output devices
https://bugs.webkit.org/show_bug.cgi?id=134877

Reviewed by Sam Weinig.


Source/WebCore: 
No new tests, this deals with changes to the audio hardware at runtime.

* WebCore.xcodeproj/project.pbxproj: Remove AudioSessionListener.h.
* WebCore.vcxproj/WebCore.vcxproj: Ditto.

* platform/audio/AudioHardwareListener.cpp:
(WebCore::AudioHardwareListener::AudioHardwareListener): Initialize m_outputDeviceSupportsLowPowerMode
    to true on iOS.
* platform/audio/AudioHardwareListener.h:
(WebCore::AudioHardwareListener::outputDeviceSupportsLowPowerMode): New accessor.
(WebCore::AudioHardwareListener::setHardwareActivity): New setter for derived classes.
(WebCore::AudioHardwareListener::setOutputDeviceSupportsLowPowerMode): Ditto.

Remove AudioSessionListener interface, it wasn't being used.
* platform/audio/AudioSession.cpp:
(WebCore::AudioSession::addListener): Deleted.
(WebCore::AudioSession::removeListener): Deleted.
(WebCore::AudioSession::beganAudioInterruption): Deleted.
(WebCore::AudioSession::endedAudioInterruption): Deleted.
* platform/audio/AudioSession.h:
* platform/audio/AudioSessionListener.h: Removed.

* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::addSession): Allocate the AudioHardwareListener if necessary.
(WebCore::MediaSessionManager::removeSession): Free the AudioHardwareListener if necessary.
(WebCore::MediaSessionManager::audioOutputDeviceChanged): AudioHardwareListener client interface
    called when the output device changes, call updateSessionState to make sure we are using
    the correct buffer size.
* platform/audio/MediaSessionManager.h:

* platform/audio/ios/AudioDestinationIOS.h:
* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::AudioSessionPrivate::AudioSessionPrivate): Drive-by cleanup, remove ObjC helper object
    that was used to listen for OS notifications, it is no longer used.
(SOFT_LINK_POINTER): Deleted.
(-[WebAudioSessionHelper initWithCallback:]): Deleted.
(-[WebAudioSessionHelper dealloc]): Deleted.
(-[WebAudioSessionHelper interruption:]): Deleted.

* platform/audio/mac/AudioHardwareListenerMac.cpp:
(WebCore::currentDeviceSupportsLowPowerBufferSize): New, return true only if using build-in 
    transport device.
(WebCore::processIsRunningPropertyDescriptor): Return reference to static AudioObjectPropertyAddress
    for kAudioHardwarePropertyProcessIsRunning instead of declaring one in every method
    that needs one.
(WebCore::outputDevicePropertyDescriptor): Return reference to static AudioObjectPropertyAddress
    for kAudioHardwarePropertyDefaultOutputDevice.
(WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac): Restructure and add audio object
    listener for default output device.
(WebCore::AudioHardwareListenerMac::~AudioHardwareListenerMac): *Remove* listener audio object
    property listener instead of *Adding* a new one. Remove new listener.
(WebCore::AudioHardwareListenerMac::propertyChanged): Enumerate the properties that changed,
    call appropriate method.
(WebCore::AudioHardwareListenerMac::processIsRunningChanged): Renamed from setHardwareActive, 
    cleanup.
(WebCore::AudioHardwareListenerMac::outputDeviceChanged): New, call client.audioHardwareOutputDeviceChanged.
(WebCore::AudioHardwareListenerMac::setHardwareActive): Deleted, renamed processIsRunningChanged.
* platform/audio/mac/AudioHardwareListenerMac.h:

* platform/audio/mac/MediaSessionManagerMac.cpp:
(MediaSessionManager::updateSessionState): Only set the output buffer size to 4K when hardware
    supports it.

Source/WebKit2: 
* PluginProcess/PluginProcess.h: Add an empty implementation of 
    AudioHardwareListener::audioOutputDeviceChanged.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioAudioHardwareListenercpp">trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioAudioHardwareListenerh">trunk/Source/WebCore/platform/audio/AudioHardwareListener.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioAudioSessioncpp">trunk/Source/WebCore/platform/audio/AudioSession.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioAudioSessionh">trunk/Source/WebCore/platform/audio/AudioSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagercpp">trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagerh">trunk/Source/WebCore/platform/audio/MediaSessionManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioiosAudioDestinationIOSh">trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioiosAudioSessionIOSmm">trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMaccpp">trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMach">trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacMediaSessionManagerMaccpp">trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessPluginProcessh">trunk/Source/WebKit2/PluginProcess/PluginProcess.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformaudioAudioSessionListenerh">trunk/Source/WebCore/platform/audio/AudioSessionListener.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/ChangeLog        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2014-07-14  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        [Mac] don't enable low power audio mode on external output devices
+        https://bugs.webkit.org/show_bug.cgi?id=134877
+
+        Reviewed by Sam Weinig.
+
+        No new tests, this deals with changes to the audio hardware at runtime.
+
+        * WebCore.xcodeproj/project.pbxproj: Remove AudioSessionListener.h.
+        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+
+        * platform/audio/AudioHardwareListener.cpp:
+        (WebCore::AudioHardwareListener::AudioHardwareListener): Initialize m_outputDeviceSupportsLowPowerMode
+            to true on iOS.
+        * platform/audio/AudioHardwareListener.h:
+        (WebCore::AudioHardwareListener::outputDeviceSupportsLowPowerMode): New accessor.
+        (WebCore::AudioHardwareListener::setHardwareActivity): New setter for derived classes.
+        (WebCore::AudioHardwareListener::setOutputDeviceSupportsLowPowerMode): Ditto.
+
+        Remove AudioSessionListener interface, it wasn't being used.
+        * platform/audio/AudioSession.cpp:
+        (WebCore::AudioSession::addListener): Deleted.
+        (WebCore::AudioSession::removeListener): Deleted.
+        (WebCore::AudioSession::beganAudioInterruption): Deleted.
+        (WebCore::AudioSession::endedAudioInterruption): Deleted.
+        * platform/audio/AudioSession.h:
+        * platform/audio/AudioSessionListener.h: Removed.
+
+        * platform/audio/MediaSessionManager.cpp:
+        (WebCore::MediaSessionManager::addSession): Allocate the AudioHardwareListener if necessary.
+        (WebCore::MediaSessionManager::removeSession): Free the AudioHardwareListener if necessary.
+        (WebCore::MediaSessionManager::audioOutputDeviceChanged): AudioHardwareListener client interface
+            called when the output device changes, call updateSessionState to make sure we are using
+            the correct buffer size.
+        * platform/audio/MediaSessionManager.h:
+
+        * platform/audio/ios/AudioDestinationIOS.h:
+        * platform/audio/ios/AudioSessionIOS.mm:
+        (WebCore::AudioSessionPrivate::AudioSessionPrivate): Drive-by cleanup, remove ObjC helper object
+            that was used to listen for OS notifications, it is no longer used.
+        (SOFT_LINK_POINTER): Deleted.
+        (-[WebAudioSessionHelper initWithCallback:]): Deleted.
+        (-[WebAudioSessionHelper dealloc]): Deleted.
+        (-[WebAudioSessionHelper interruption:]): Deleted.
+
+        * platform/audio/mac/AudioHardwareListenerMac.cpp:
+        (WebCore::currentDeviceSupportsLowPowerBufferSize): New, return true only if using build-in 
+            transport device.
+        (WebCore::processIsRunningPropertyDescriptor): Return reference to static AudioObjectPropertyAddress
+            for kAudioHardwarePropertyProcessIsRunning instead of declaring one in every method
+            that needs one.
+        (WebCore::outputDevicePropertyDescriptor): Return reference to static AudioObjectPropertyAddress
+            for kAudioHardwarePropertyDefaultOutputDevice.
+        (WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac): Restructure and add audio object
+            listener for default output device.
+        (WebCore::AudioHardwareListenerMac::~AudioHardwareListenerMac): *Remove* listener audio object
+            property listener instead of *Adding* a new one. Remove new listener.
+        (WebCore::AudioHardwareListenerMac::propertyChanged): Enumerate the properties that changed,
+            call appropriate method.
+        (WebCore::AudioHardwareListenerMac::processIsRunningChanged): Renamed from setHardwareActive, 
+            cleanup.
+        (WebCore::AudioHardwareListenerMac::outputDeviceChanged): New, call client.audioHardwareOutputDeviceChanged.
+        (WebCore::AudioHardwareListenerMac::setHardwareActive): Deleted, renamed processIsRunningChanged.
+        * platform/audio/mac/AudioHardwareListenerMac.h:
+
+        * platform/audio/mac/MediaSessionManagerMac.cpp:
+        (MediaSessionManager::updateSessionState): Only set the output buffer size to 4K when hardware
+            supports it.
+
</ins><span class="cx"> 2014-07-13  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove SelectorCheckerFastPath from the style resolution algorithm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -19309,7 +19309,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\FileSystem.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\FloatConversion.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\audio\AudioSession.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\platform\audio\AudioSessionListener.h&quot; /&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\platform\audio\MediaSession.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\audio\MediaSessionManager.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\ANGLEWebKitBridge.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -13114,7 +13114,6 @@
</span><span class="cx">                 CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemSleepListenerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSleepListenerMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79821170A22DC00D45C55 /* AudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                CDA79822170A24F400D45C55 /* AudioSessionListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSessionListener.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 CDA79823170A258300D45C55 /* AudioSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79825170A279000D45C55 /* AudioSessionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AudioSessionIOS.mm; path = ios/AudioSessionIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA98D9B160128A500FEA3B1 /* JSMediaKeyError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaKeyError.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -23083,7 +23082,6 @@
</span><span class="cx">                                 FD31605212B026F700C1A359 /* AudioResamplerKernel.h */,
</span><span class="cx">                                 CDA79823170A258300D45C55 /* AudioSession.cpp */,
</span><span class="cx">                                 CDA79821170A22DC00D45C55 /* AudioSession.h */,
</span><del>-                                CDA79822170A24F400D45C55 /* AudioSessionListener.h */,
</del><span class="cx">                                 FD31605312B026F700C1A359 /* AudioSourceProvider.h */,
</span><span class="cx">                                 FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */,
</span><span class="cx">                                 FD31605412B026F700C1A359 /* AudioUtilities.cpp */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioHardwareListenercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -38,8 +38,11 @@
</span><span class="cx"> AudioHardwareListener::AudioHardwareListener(Client&amp; client)
</span><span class="cx">     : m_client(client)
</span><span class="cx">     , m_activity(AudioHardwareActivityType::Unknown)
</span><ins>+    , m_outputDeviceSupportsLowPowerMode(false)
</ins><span class="cx"> {
</span><del>-    
</del><ins>+#if PLATFORM(IOS)
+    m_outputDeviceSupportsLowPowerMode = true;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioHardwareListenerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/AudioHardwareListener.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioHardwareListener.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/AudioHardwareListener.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -44,18 +44,24 @@
</span><span class="cx">         virtual ~Client() { }
</span><span class="cx">         virtual void audioHardwareDidBecomeActive() = 0;
</span><span class="cx">         virtual void audioHardwareDidBecomeInactive() = 0;
</span><ins>+        virtual void audioOutputDeviceChanged() = 0;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     static PassRefPtr&lt;AudioHardwareListener&gt; create(Client&amp;);
</span><span class="cx">     virtual ~AudioHardwareListener() { }
</span><span class="cx">     
</span><span class="cx">     AudioHardwareActivityType hardwareActivity() const { return m_activity; }
</span><ins>+    bool outputDeviceSupportsLowPowerMode() const { return m_outputDeviceSupportsLowPowerMode; }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     AudioHardwareListener(Client&amp;);
</span><span class="cx"> 
</span><ins>+    void setHardwareActivity(AudioHardwareActivityType activity) { m_activity = activity; }
+    void setOutputDeviceSupportsLowPowerMode(bool support) { m_outputDeviceSupportsLowPowerMode = support; }
+
</ins><span class="cx">     Client&amp; m_client;
</span><span class="cx">     AudioHardwareActivityType m_activity;
</span><ins>+    bool m_outputDeviceSupportsLowPowerMode;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/AudioSession.cpp (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioSession.cpp        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/AudioSession.cpp        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(AUDIO_SESSION)
</span><span class="cx"> 
</span><del>-#include &quot;AudioSessionListener.h&quot;
</del><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -39,28 +38,6 @@
</span><span class="cx">     return session;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AudioSession::addListener(AudioSessionListener* listener)
-{
-    m_listeners.add(listener);
-}
-
-void AudioSession::removeListener(AudioSessionListener* listener)
-{
-    m_listeners.remove(listener);
-}
-
-void AudioSession::beganAudioInterruption()
-{
-    for (HashSet&lt;AudioSessionListener*&gt;::iterator i = m_listeners.begin(); i != m_listeners.end(); ++i)
-        (*i)-&gt;beganAudioInterruption();
-}
-
-void AudioSession::endedAudioInterruption()
-{
-    for (HashSet&lt;AudioSessionListener*&gt;::iterator i = m_listeners.begin(); i != m_listeners.end(); ++i)
-        (*i)-&gt;endedAudioInterruption();
-}
-
</del><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx"> class AudioSessionPrivate {
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioSession.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -34,7 +34,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class AudioSessionListener;
</del><span class="cx"> class AudioSessionPrivate;
</span><span class="cx"> 
</span><span class="cx"> class AudioSession {
</span><span class="lines">@@ -57,9 +56,6 @@
</span><span class="cx">     void setCategoryOverride(CategoryType);
</span><span class="cx">     CategoryType categoryOverride() const;
</span><span class="cx"> 
</span><del>-    void addListener(AudioSessionListener*);
-    void removeListener(AudioSessionListener*);
-
</del><span class="cx">     float sampleRate() const;
</span><span class="cx">     size_t numberOfOutputChannels() const;
</span><span class="cx"> 
</span><span class="lines">@@ -68,15 +64,11 @@
</span><span class="cx">     size_t preferredBufferSize() const;
</span><span class="cx">     void setPreferredBufferSize(size_t);
</span><span class="cx"> 
</span><del>-    void beganAudioInterruption();
-    void endedAudioInterruption();
-
</del><span class="cx"> private:
</span><span class="cx">     AudioSession();
</span><span class="cx">     ~AudioSession();
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;AudioSessionPrivate&gt; m_private;
</span><del>-    HashSet&lt;AudioSessionListener*&gt; m_listeners;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioSessionListenerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/audio/AudioSessionListener.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioSessionListener.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/AudioSessionListener.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -1,49 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AudioSessionListener_h
-#define AudioSessionListener_h
-
-#if USE(AUDIO_SESSION)
-
-#include &lt;wtf/Noncopyable.h&gt;
-
-namespace WebCore {
-
-class AudioSessionListener {
-    WTF_MAKE_NONCOPYABLE(AudioSessionListener);
-public:
-    virtual void beganAudioInterruption() = 0;
-    virtual void endedAudioInterruption() = 0;
-protected:
-    AudioSessionListener() { }
-    virtual ~AudioSessionListener() { }
-};
-
-}
-
-#endif // USE(AUDIO_SESSION)
-
-#endif // AudioSessionListener_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -119,11 +119,15 @@
</span><span class="cx">     m_sessions.append(&amp;session);
</span><span class="cx">     if (m_interrupted)
</span><span class="cx">         session.setState(MediaSession::Interrupted);
</span><del>-    updateSessionState();
</del><span class="cx"> 
</span><span class="cx">     if (!m_remoteCommandListener)
</span><span class="cx">         m_remoteCommandListener = RemoteCommandListener::create(*this);
</span><span class="cx"> 
</span><ins>+    if (!m_audioHardwareListener)
+        m_audioHardwareListener = AudioHardwareListener::create(*this);
+
+    updateSessionState();
+
</ins><span class="cx">     if (m_clients.isEmpty() || !(session.mediaType() == MediaSession::Video || session.mediaType() == MediaSession::Audio))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -141,11 +145,14 @@
</span><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     m_sessions.remove(index);
</span><del>-    updateSessionState();
</del><span class="cx"> 
</span><del>-    if (m_sessions.isEmpty())
</del><ins>+    if (m_sessions.isEmpty()) {
</ins><span class="cx">         m_remoteCommandListener = nullptr;
</span><ins>+        m_audioHardwareListener = nullptr;
+    }
</ins><span class="cx"> 
</span><ins>+    updateSessionState();
+
</ins><span class="cx">     if (m_clients.isEmpty() || !(session.mediaType() == MediaSession::Video || session.mediaType() == MediaSession::Audio))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -339,6 +346,11 @@
</span><span class="cx">         session-&gt;endInterruption(MediaSession::MayResumePlaying);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaSessionManager::audioOutputDeviceChanged()
+{
+    updateSessionState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef MediaSessionManager_h
</span><span class="cx"> #define MediaSessionManager_h
</span><span class="cx"> 
</span><ins>+#include &lt;AudioHardwareListener.h&gt;
</ins><span class="cx"> #include &quot;MediaSession.h&quot;
</span><span class="cx"> #include &quot;RemoteCommandListener.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="lines">@@ -52,7 +53,7 @@
</span><span class="cx">     MediaSessionManagerClient() { }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class MediaSessionManager : RemoteCommandListenerClient, SystemSleepListener::Client {
</del><ins>+class MediaSessionManager : private RemoteCommandListenerClient, private SystemSleepListener::Client, private AudioHardwareListener::Client {
</ins><span class="cx"> public:
</span><span class="cx">     static MediaSessionManager&amp; sharedManager();
</span><span class="cx">     virtual ~MediaSessionManager() { }
</span><span class="lines">@@ -94,8 +95,6 @@
</span><span class="cx">     virtual void stopMonitoringAirPlayRoutes() { }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override;
-
</del><span class="cx">     void addClient(MediaSessionManagerClient*);
</span><span class="cx">     void removeClient(MediaSessionManagerClient*);
</span><span class="cx"> 
</span><span class="lines">@@ -114,15 +113,26 @@
</span><span class="cx"> 
</span><span class="cx">     void updateSessionState();
</span><span class="cx"> 
</span><del>-    virtual void systemWillSleep();
-    virtual void systemDidWake();
</del><span class="cx"> 
</span><ins>+    // RemoteCommandListenerClient
+    virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override;
+
+    // AudioHardwareListenerClient
+    virtual void audioHardwareDidBecomeActive() override { }
+    virtual void audioHardwareDidBecomeInactive() override { }
+    virtual void audioOutputDeviceChanged() override;
+
+    // SystemSleepListener
+    virtual void systemWillSleep() override;
+    virtual void systemDidWake() override;
+
</ins><span class="cx">     SessionRestrictions m_restrictions[MediaSession::WebAudio + 1];
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;MediaSession*&gt; m_sessions;
</span><span class="cx">     Vector&lt;MediaSessionManagerClient*&gt; m_clients;
</span><span class="cx">     std::unique_ptr&lt;RemoteCommandListener&gt; m_remoteCommandListener;
</span><span class="cx">     std::unique_ptr&lt;SystemSleepListener&gt; m_systemSleepListener;
</span><ins>+    RefPtr&lt;AudioHardwareListener&gt; m_audioHardwareListener;
</ins><span class="cx">     bool m_interrupted;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioiosAudioDestinationIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AudioBus.h&quot;
</span><span class="cx"> #include &quot;AudioDestination.h&quot;
</span><del>-#include &quot;AudioSessionListener.h&quot;
</del><span class="cx"> #include &quot;MediaSession.h&quot;
</span><span class="cx"> #include &lt;AudioUnit/AudioUnit.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioiosAudioSessionIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -54,58 +54,8 @@
</span><span class="cx"> #define AVAudioSessionCategoryAudioProcessing getAVAudioSessionCategoryAudioProcessing()
</span><span class="cx"> #define AVAudioSessionInterruptionTypeKey getAVAudioSessionInterruptionTypeKey()
</span><span class="cx"> 
</span><del>-static NSString * const WCAVAudioSessionInterruptionNotification = @&quot;AVAudioSessionInterruptionNotification&quot;;
-
-#if !ASSERT_DISABLED
-SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionNotification, NSString *)
-#endif
-
-@interface WebAudioSessionHelper : NSObject {
-    WebCore::AudioSession* _callback;
-}
-- (id)initWithCallback:(WebCore::AudioSession*)callback;
-- (void)interruption:(NSNotification*)notification;
-@end
-
-@implementation WebAudioSessionHelper
-- (id)initWithCallback:(WebCore::AudioSession*)callback
-{
-    self = [super init];
-    if (!self)
-        return nil;
-
-    _callback = callback;
-
-    ASSERT([WCAVAudioSessionInterruptionNotification isEqualToString:getAVAudioSessionInterruptionNotification()]);
-
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruption:) name:WCAVAudioSessionInterruptionNotification object:nil];
-
-    return self;
-}
-
-- (void)dealloc
-{
-    [[NSNotificationCenter defaultCenter] removeObserver:self name:WCAVAudioSessionInterruptionNotification object:nil];
-    [super dealloc];
-}
-
-- (void)interruption:(NSNotification *)notification
-{
-    ASSERT([AVAudioSession sharedInstance] == [notification object]);
-    if ([AVAudioSession sharedInstance] != [notification object])
-        return;
-
-    NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
-    if (type == AVAudioSessionInterruptionTypeBegan)
-        _callback-&gt;beganAudioInterruption();
-    else
-        _callback-&gt;endedAudioInterruption();
-}
-@end
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> #if !LOG_DISABLED
</span><span class="cx"> static const char* categoryName(AudioSession::CategoryType category)
</span><span class="cx"> {
</span><span class="lines">@@ -128,13 +78,11 @@
</span><span class="cx"> class AudioSessionPrivate {
</span><span class="cx"> public:
</span><span class="cx">     AudioSessionPrivate(AudioSession*);
</span><del>-    RetainPtr&lt;WebAudioSessionHelper&gt; m_helper;
</del><span class="cx">     AudioSession::CategoryType m_categoryOverride;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-AudioSessionPrivate::AudioSessionPrivate(AudioSession* session)
-    : m_helper(adoptNS([[WebAudioSessionHelper alloc] initWithCallback:session]))
-    , m_categoryOverride(AudioSession::None)
</del><ins>+AudioSessionPrivate::AudioSessionPrivate(AudioSession*)
+    : m_categoryOverride(AudioSession::None)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -58,7 +58,57 @@
</span><span class="cx">     else
</span><span class="cx">         return AudioHardwareActivityType::IsInactive;
</span><span class="cx"> }
</span><del>-    
</del><ins>+
+static bool currentDeviceSupportsLowPowerBufferSize()
+{
+    AudioDeviceID deviceID = kAudioDeviceUnknown;
+    UInt32 descriptorSize = sizeof(deviceID);
+    AudioObjectPropertyAddress defaultOutputDeviceDescriptor = {
+        kAudioHardwarePropertyDefaultOutputDevice,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster };
+
+    if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &amp;defaultOutputDeviceDescriptor, 0, 0, &amp;descriptorSize, (void*)&amp;deviceID))
+        return false;
+
+    UInt32 transportType = kAudioDeviceTransportTypeUnknown;
+    descriptorSize = sizeof(transportType);
+    AudioObjectPropertyAddress tranportTypeDescriptor = {
+        kAudioDevicePropertyTransportType,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster,
+    };
+
+    if (AudioObjectGetPropertyData(deviceID, &amp;tranportTypeDescriptor, 0, 0, &amp;descriptorSize, &amp;transportType))
+        return false;
+
+    // Only allow low-power buffer size when using built-in output device, many external devices perform
+    // poorly with a large output buffer.
+    return kAudioDeviceTransportTypeBuiltIn == transportType;
+}
+
+static const AudioObjectPropertyAddress&amp; processIsRunningPropertyDescriptor()
+{
+    static AudioObjectPropertyAddress processIsRunningProperty = {
+        kAudioHardwarePropertyProcessIsRunning,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster
+    };
+
+    return processIsRunningProperty;
+};
+
+static const AudioObjectPropertyAddress&amp; outputDevicePropertyDescriptor()
+{
+    static AudioObjectPropertyAddress outputDeviceProperty = {
+        kAudioHardwarePropertyDefaultOutputDevice,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster
+    };
+
+    return outputDeviceProperty;
+};
+
</ins><span class="cx"> PassRefPtr&lt;AudioHardwareListener&gt; AudioHardwareListener::create(Client&amp; client)
</span><span class="cx"> {
</span><span class="cx">     return AudioHardwareListenerMac::create(client);
</span><span class="lines">@@ -72,44 +122,45 @@
</span><span class="cx"> AudioHardwareListenerMac::AudioHardwareListenerMac(Client&amp; client)
</span><span class="cx">     : AudioHardwareListener(client)
</span><span class="cx"> {
</span><del>-    m_activity = isAudioHardwareProcessRunning();
-    if (hardwareActivity() == AudioHardwareActivityType::Unknown)
-        return;
</del><ins>+    setHardwareActivity(isAudioHardwareProcessRunning());
+    setOutputDeviceSupportsLowPowerMode(currentDeviceSupportsLowPowerBufferSize());
</ins><span class="cx"> 
</span><del>-    AudioObjectPropertyAddress propertyAddress = {
-        kAudioHardwarePropertyProcessIsRunning,
-        kAudioObjectPropertyScopeGlobal,
-        kAudioObjectPropertyElementMaster
-    };
-
-    m_block = Block_copy(^(UInt32, const AudioObjectPropertyAddress[]) {
-        setHardwareActive(isAudioHardwareProcessRunning());
</del><ins>+    m_block = Block_copy(^(UInt32 count, const AudioObjectPropertyAddress properties[]) {
+        propertyChanged(count, properties);
</ins><span class="cx">     });
</span><span class="cx"> 
</span><del>-    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;propertyAddress, dispatch_get_main_queue(), m_block);
</del><ins>+    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;processIsRunningPropertyDescriptor(), dispatch_get_main_queue(), m_block);
+    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;outputDevicePropertyDescriptor(), dispatch_get_main_queue(), m_block);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> AudioHardwareListenerMac::~AudioHardwareListenerMac()
</span><span class="cx"> {
</span><del>-    if (hardwareActivity() == AudioHardwareActivityType::Unknown)
-        return;
-    
-    AudioObjectPropertyAddress propertyAddress = {
-        kAudioHardwarePropertyProcessIsRunning,
-        kAudioObjectPropertyScopeGlobal,
-        kAudioObjectPropertyElementMaster
-    };
</del><ins>+    AudioObjectRemovePropertyListenerBlock(kAudioObjectSystemObject, &amp;processIsRunningPropertyDescriptor(), dispatch_get_main_queue(), m_block);
+    AudioObjectRemovePropertyListenerBlock(kAudioObjectSystemObject, &amp;outputDevicePropertyDescriptor(), dispatch_get_main_queue(), m_block);
+    Block_release(m_block);
+}
</ins><span class="cx"> 
</span><del>-    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;propertyAddress, dispatch_get_main_queue(), m_block);
</del><ins>+void AudioHardwareListenerMac::propertyChanged(UInt32 propertyCount, const AudioObjectPropertyAddress properties[])
+{
+    const AudioObjectPropertyAddress&amp; deviceRunning = processIsRunningPropertyDescriptor();
+    const AudioObjectPropertyAddress&amp; outputDevice = outputDevicePropertyDescriptor();
</ins><span class="cx"> 
</span><del>-    Block_release(m_block);
</del><ins>+    for (UInt32 i = 0; i &lt; propertyCount; ++i) {
+        const AudioObjectPropertyAddress&amp; property = properties[i];
+
+        if (!memcmp(&amp;property, &amp;deviceRunning, sizeof(AudioObjectPropertyAddress)))
+            processIsRunningChanged();
+        else if (!memcmp(&amp;property, &amp;outputDevice, sizeof(AudioObjectPropertyAddress)))
+            outputDeviceChanged();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AudioHardwareListenerMac::setHardwareActive(AudioHardwareActivityType activity)
</del><ins>+void AudioHardwareListenerMac::processIsRunningChanged()
</ins><span class="cx"> {
</span><del>-    if (activity == m_activity)
</del><ins>+    AudioHardwareActivityType activity = isAudioHardwareProcessRunning();
+    if (activity == hardwareActivity())
</ins><span class="cx">         return;
</span><del>-    m_activity = activity;
</del><ins>+    setHardwareActivity(activity);
</ins><span class="cx">     
</span><span class="cx">     if (hardwareActivity() == AudioHardwareActivityType::IsActive)
</span><span class="cx">         m_client.audioHardwareDidBecomeActive();
</span><span class="lines">@@ -117,6 +168,12 @@
</span><span class="cx">         m_client.audioHardwareDidBecomeInactive();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void AudioHardwareListenerMac::outputDeviceChanged()
+{
+    setOutputDeviceSupportsLowPowerMode(currentDeviceSupportsLowPowerBufferSize());
+    m_client.audioOutputDeviceChanged();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -38,11 +38,15 @@
</span><span class="cx"> public:
</span><span class="cx">     static WTF::PassRefPtr&lt;AudioHardwareListenerMac&gt; create(Client&amp;);
</span><span class="cx"> 
</span><del>-protected:
</del><ins>+private:
</ins><span class="cx">     AudioHardwareListenerMac(Client&amp;);
</span><span class="cx">     virtual ~AudioHardwareListenerMac();
</span><span class="cx"> 
</span><del>-    void setHardwareActive(AudioHardwareActivityType);
</del><ins>+    void processIsRunningChanged();
+    void outputDeviceChanged();
+
+    void propertyChanged(UInt32, const AudioObjectPropertyAddress[]);
+
</ins><span class="cx">     AudioObjectPropertyListenerBlock m_block;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacMediaSessionManagerMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -50,7 +50,14 @@
</span><span class="cx">     else if ((has(MediaSession::Video) || has(MediaSession::Audio)) &amp;&amp; Settings::lowPowerVideoAudioBufferSizeEnabled()) {
</span><span class="cx">         // FIXME: &lt;http://webkit.org/b/116725&gt; Figure out why enabling the code below
</span><span class="cx">         // causes media LayoutTests to fail on 10.8.
</span><del>-        AudioSession::sharedSession().setPreferredBufferSize(kLowPowerVideoBufferSize);
</del><ins>+
+        size_t bufferSize;
+        if (m_audioHardwareListener &amp;&amp; m_audioHardwareListener-&gt;outputDeviceSupportsLowPowerMode())
+            bufferSize = kLowPowerVideoBufferSize;
+        else
+            bufferSize = kWebAudioBufferSize;
+
+        AudioSession::sharedSession().setPreferredBufferSize(bufferSize);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-07-14  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        [Mac] don't enable low power audio mode on external output devices
+        https://bugs.webkit.org/show_bug.cgi?id=134877
+
+        Reviewed by Sam Weinig.
+
+        * PluginProcess/PluginProcess.h: Add an empty implementation of 
+            AudioHardwareListener::audioOutputDeviceChanged.
+
</ins><span class="cx"> 2014-07-14  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Throttle painting using a UI-process-side CADisplayLink
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessPluginProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.h (171068 => 171069)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/PluginProcess.h        2014-07-14 18:11:46 UTC (rev 171068)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.h        2014-07-14 18:17:34 UTC (rev 171069)
</span><span class="lines">@@ -101,6 +101,7 @@
</span><span class="cx">     // AudioHardwareListenerClient
</span><span class="cx">     virtual void audioHardwareDidBecomeActive() override;
</span><span class="cx">     virtual void audioHardwareDidBecomeInactive() override;
</span><ins>+    virtual void audioOutputDeviceChanged() override { }
</ins><span class="cx"> 
</span><span class="cx">     void platformInitializePluginProcess(const PluginProcessCreationParameters&amp;);
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>