<!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>[166442] trunk/Source/WebCore</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/166442">166442</a></dd>
<dt>Author</dt> <dd>slewis@apple.com</dd>
<dt>Date</dt> <dd>2014-03-28 18:15:47 -0700 (Fri, 28 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Notification handler for telling if audio hardware is active.
https://bugs.webkit.org/show_bug.cgi?id=130743

Reviewed by Jer Noble.

Not web-exposed so no easy way to test.

Listen to CoreAudio to see if audio hardware is active in the current process.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/AudioHardwareListener.cpp: Added.
(WebCore::AudioHardwareListener::create):
(WebCore::AudioHardwareListener::AudioHardwareListener):
* platform/audio/AudioHardwareListener.h: Added.
(WebCore::AudioHardwareListener::Client::~Client):
(WebCore::AudioHardwareListener::~AudioHardwareListener):
(WebCore::AudioHardwareListener::isHardwareActive):
* platform/audio/mac/AudioHardwareListenerMac.cpp: Added.
(WebCore::isAudioHardwareProcessRunning):
(WebCore::AudioHardwareListener::create):
(WebCore::AudioHardwareListenerMac::create):
(WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac):
(WebCore::AudioHardwareListenerMac::~AudioHardwareListenerMac):
(WebCore::AudioHardwareListenerMac::setHardwareActive):
* platform/audio/mac/AudioHardwareListenerMac.h: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<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="#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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166441 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-29 01:15:44 UTC (rev 166441)
+++ trunk/Source/WebCore/ChangeLog        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-03-28  Stephanie Lewis  &lt;slewis@apple.com&gt;
+
+        Notification handler for telling if audio hardware is active.
+        https://bugs.webkit.org/show_bug.cgi?id=130743
+
+        Reviewed by Jer Noble.
+
+        Not web-exposed so no easy way to test.
+
+        Listen to CoreAudio to see if audio hardware is active in the current process.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/AudioHardwareListener.cpp: Added.
+        (WebCore::AudioHardwareListener::create):
+        (WebCore::AudioHardwareListener::AudioHardwareListener):
+        * platform/audio/AudioHardwareListener.h: Added.
+        (WebCore::AudioHardwareListener::Client::~Client):
+        (WebCore::AudioHardwareListener::~AudioHardwareListener):
+        (WebCore::AudioHardwareListener::isHardwareActive):
+        * platform/audio/mac/AudioHardwareListenerMac.cpp: Added.
+        (WebCore::isAudioHardwareProcessRunning):
+        (WebCore::AudioHardwareListener::create):
+        (WebCore::AudioHardwareListenerMac::create):
+        (WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac):
+        (WebCore::AudioHardwareListenerMac::~AudioHardwareListenerMac):
+        (WebCore::AudioHardwareListenerMac::setHardwareActive):
+        * platform/audio/mac/AudioHardwareListenerMac.h: Added.
+
</ins><span class="cx"> 2014-03-28  James Craig  &lt;jcraig@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: AXI: expose what elements get generic &quot;clickable&quot; status
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166441 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-29 01:15:44 UTC (rev 166441)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -849,6 +849,7 @@
</span><span class="cx"> __ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
</span><span class="cx"> __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore20toUInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
</span><ins>+__ZN7WebCore21AudioHardwareListener6createERNS0_6ClientE
</ins><span class="cx"> __ZN7WebCore21BackForwardController11itemAtIndexEi
</span><span class="cx"> __ZN7WebCore21BackForwardController6goBackEv
</span><span class="cx"> __ZN7WebCore21BackForwardController9goForwardEv
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166441 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-29 01:15:44 UTC (rev 166441)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -5505,6 +5505,10 @@
</span><span class="cx">                 CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; };
</span><span class="cx">                 CD27F6E51457685A0078207D /* JSMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E2145767580078207D /* JSMediaController.cpp */; };
</span><span class="cx">                 CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
</span><ins>+                CD2F4A2318D89F700063746D /* AudioHardwareListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2F4A2118D89F700063746D /* AudioHardwareListener.cpp */; };
+                CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2218D89F700063746D /* AudioHardwareListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CD2F4A2718D8A3490063746D /* AudioHardwareListenerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */; };
+                CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; };
</ins><span class="cx">                 CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */; };
</span><span class="cx">                 CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */; };
</span><span class="cx">                 CD336F6417FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6317FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h */; };
</span><span class="lines">@@ -12806,6 +12810,10 @@
</span><span class="cx">                 CD27F6E3145767580078207D /* JSMediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD27F6E4145767870078207D /* MediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD27F6E6145770D30078207D /* MediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CD2F4A2118D89F700063746D /* AudioHardwareListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioHardwareListener.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD2F4A2218D89F700063746D /* AudioHardwareListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHardwareListener.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioHardwareListenerMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHardwareListenerMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CD32A189184EB46A0029B1BB /* mediaControlsiOS.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = mediaControlsiOS.js; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVTrackPrivateAVFObjCImpl.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVTrackPrivateAVFObjCImpl.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22731,6 +22739,8 @@
</span><span class="cx">                                 FD31607912B026F700C1A359 /* VectorMath.h */,
</span><span class="cx">                                 FD537350137B651800008DCE /* ZeroPole.cpp */,
</span><span class="cx">                                 FD537351137B651800008DCE /* ZeroPole.h */,
</span><ins>+                                CD2F4A2118D89F700063746D /* AudioHardwareListener.cpp */,
+                                CD2F4A2218D89F700063746D /* AudioHardwareListener.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = audio;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -22746,6 +22756,8 @@
</span><span class="cx">                                 CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */,
</span><span class="cx">                                 FD3160BA12B0272A00C1A359 /* FFTFrameMac.cpp */,
</span><span class="cx">                                 CD54DE4517468B6F005E5B36 /* MediaSessionManagerMac.cpp */,
</span><ins>+                                CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */,
+                                CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = mac;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -22854,6 +22866,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 FE115FAB167988CD00249134 /* AbstractDatabaseServer.h in Headers */,
</span><ins>+                                CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */,
</ins><span class="cx">                                 FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */,
</span><span class="cx">                                 FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */,
</span><span class="cx">                                 41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
</span><span class="lines">@@ -25922,6 +25935,7 @@
</span><span class="cx">                                 076970871463AD8700F502CF /* TextTrackList.h in Headers */,
</span><span class="cx">                                 B1AD4E7413A12A4600846B27 /* TextTrackLoader.h in Headers */,
</span><span class="cx">                                 CD8B5A49180E138B008B8E65 /* TextTrackMediaSource.h in Headers */,
</span><ins>+                                CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */,
</ins><span class="cx">                                 498770F11242C535002226BA /* Texture.h in Headers */,
</span><span class="cx">                                 BCE658FF0EA9248A007E4533 /* Theme.h in Headers */,
</span><span class="cx">                                 44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */,
</span><span class="lines">@@ -26911,6 +26925,7 @@
</span><span class="cx">                                 4162A450101145AE00DFF3ED /* DedicatedWorkerGlobalScope.cpp in Sources */,
</span><span class="cx">                                 41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */,
</span><span class="cx">                                 FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */,
</span><ins>+                                CD2F4A2718D8A3490063746D /* AudioHardwareListenerMac.cpp in Sources */,
</ins><span class="cx">                                 4167EBF5102962BA003D252A /* DefaultSharedWorkerRepository.cpp in Sources */,
</span><span class="cx">                                 1AF4CEE918BC350100BC2D34 /* DefaultVisitedLinkStore.cpp in Sources */,
</span><span class="cx">                                 FD31602B12B0267600C1A359 /* DelayDSPKernel.cpp in Sources */,
</span><span class="lines">@@ -27634,6 +27649,7 @@
</span><span class="cx">                                 A584FE381864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp in Sources */,
</span><span class="cx">                                 93F9B6E00BA0FB7200854064 /* JSComment.cpp in Sources */,
</span><span class="cx">                                 79AC9218109945C80021266E /* JSCompositionEvent.cpp in Sources */,
</span><ins>+                                CD2F4A2318D89F700063746D /* AudioHardwareListener.cpp in Sources */,
</ins><span class="cx">                                 FDA15EBD12B03F0B003A583A /* JSConvolverNode.cpp in Sources */,
</span><span class="cx">                                 FE6FD48D0F676E9300092873 /* JSCoordinates.cpp in Sources */,
</span><span class="cx">                                 930705D809E0C9B700B17FE4 /* JSCounter.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioHardwareListenercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp (0 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;AudioHardwareListener.h&quot;
+
+namespace WebCore {
+
+#if !PLATFORM(MAC)
+PassRefPtr&lt;AudioHardwareListener&gt; AudioHardwareListener::create(Client&amp; client)
+{
+    return adoptRef(new AudioHardwareListener(client));
+}
+    
+bool AudioHardwareListener::audioHardwareListenerIsSupported()
+{
+    return false;
+};
+
+#endif
+
+AudioHardwareListener::AudioHardwareListener(Client&amp; client)
+    : m_client(client)
+    , m_activity(AudioHardwareActivityType::Unknown)
+{
+    
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioAudioHardwareListenerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/AudioHardwareListener.h (0 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/AudioHardwareListener.h                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/AudioHardwareListener.h        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 AudioHardwareListener_h
+#define AudioHardwareListener_h
+
+#include &lt;wtf/PassRefPtr.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+
+namespace WebCore {
+    
+enum AudioHardwareActivityType {
+    Unknown,
+    IsActive,
+    IsInactive
+};
+
+class AudioHardwareListener : public RefCounted&lt;AudioHardwareListener&gt; {
+public:
+    class Client {
+    public:
+        virtual ~Client() { }
+        virtual void audioHardwareDidBecomeActive() = 0;
+        virtual void audioHardwareDidBecomeInactive() = 0;
+    };
+
+    
+    static PassRefPtr&lt;AudioHardwareListener&gt; create(Client&amp;);
+    virtual ~AudioHardwareListener() { }
+    
+    AudioHardwareActivityType hardwareActivity() const { return m_activity; }
+
+protected:
+    AudioHardwareListener(Client&amp;);
+
+    Client&amp; m_client;
+    AudioHardwareActivityType m_activity;
+};
+
+}
+
+#endif // AudioHardwareListener_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMaccpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp (0 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;AudioHardwareListenerMac.h&quot;
+
+#if PLATFORM(MAC)
+
+#include &lt;algorithm&gt;
+
+enum {
+    kAudioHardwarePropertyProcessIsRunning = 'prun'
+};
+
+namespace WebCore {
+    
+static AudioHardwareActivityType isAudioHardwareProcessRunning()
+{
+    AudioObjectPropertyAddress propertyAddress = {
+        kAudioHardwarePropertyProcessIsRunning,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster
+    };
+    
+    if (!AudioObjectHasProperty(kAudioObjectSystemObject, &amp;propertyAddress))
+        return AudioHardwareActivityType::Unknown;
+    
+    UInt32 result = 0;
+    UInt32 resultSize = sizeof(UInt32);
+
+    if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &amp;propertyAddress, 0, 0, &amp;resultSize, &amp;result))
+        return AudioHardwareActivityType::Unknown;
+
+    if (result)
+        return AudioHardwareActivityType::IsActive;
+    else
+        return AudioHardwareActivityType::IsInactive;
+}
+    
+PassRefPtr&lt;AudioHardwareListener&gt; AudioHardwareListener::create(Client&amp; client)
+{
+    return AudioHardwareListenerMac::create(client);
+}
+
+PassRefPtr&lt;AudioHardwareListenerMac&gt; AudioHardwareListenerMac::create(Client&amp; client)
+{
+    return adoptRef(new AudioHardwareListenerMac(client));
+}
+
+AudioHardwareListenerMac::AudioHardwareListenerMac(Client&amp; client)
+    : AudioHardwareListener(client)
+{
+    m_activity = isAudioHardwareProcessRunning();
+    if (hardwareActivity() == AudioHardwareActivityType::Unknown)
+        return;
+
+    AudioObjectPropertyAddress propertyAddress = {
+        kAudioHardwarePropertyProcessIsRunning,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster
+    };
+
+    m_block = Block_copy(^(UInt32, const AudioObjectPropertyAddress[]) {
+        setHardwareActive(isAudioHardwareProcessRunning());
+    });
+
+    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;propertyAddress, dispatch_get_main_queue(), m_block);
+}
+
+AudioHardwareListenerMac::~AudioHardwareListenerMac()
+{
+    if (hardwareActivity() == AudioHardwareActivityType::Unknown)
+        return;
+    
+    AudioObjectPropertyAddress propertyAddress = {
+        kAudioHardwarePropertyProcessIsRunning,
+        kAudioObjectPropertyScopeGlobal,
+        kAudioObjectPropertyElementMaster
+    };
+
+    AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &amp;propertyAddress, dispatch_get_main_queue(), m_block);
+
+    Block_release(m_block);
+}
+
+void AudioHardwareListenerMac::setHardwareActive(AudioHardwareActivityType activity)
+{
+    if (activity == m_activity)
+        return;
+    m_activity = activity;
+    
+    if (hardwareActivity() == AudioHardwareActivityType::IsActive)
+        m_client.audioHardwareDidBecomeActive();
+    else if (hardwareActivity() == AudioHardwareActivityType::IsInactive)
+        m_client.audioHardwareDidBecomeInactive();
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioHardwareListenerMach"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h (0 => 166442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h        2014-03-29 01:15:47 UTC (rev 166442)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 AudioHardwareListenerMac_h
+#define AudioHardwareListenerMac_h
+
+#include &quot;AudioHardwareListener.h&quot;
+
+#if PLATFORM(MAC)
+
+#include &lt;CoreAudio/AudioHardware.h&gt;
+
+namespace WebCore {
+
+class AudioHardwareListenerMac : public AudioHardwareListener {
+public:
+    static WTF::PassRefPtr&lt;AudioHardwareListenerMac&gt; create(Client&amp;);
+
+protected:
+    AudioHardwareListenerMac(Client&amp;);
+    virtual ~AudioHardwareListenerMac();
+
+    void setHardwareActive(AudioHardwareActivityType);
+    AudioObjectPropertyListenerBlock m_block;
+};
+
+}
+
+#endif // PLATFORM(MAC)
+
+#endif // AudioHardwareListenerMac_h
</ins></span></pre>
</div>
</div>

</body>
</html>