Diff
Modified: trunk/Source/WebCore/ChangeLog (160999 => 161000)
--- trunk/Source/WebCore/ChangeLog 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/ChangeLog 2013-12-23 18:24:06 UTC (rev 161000)
@@ -1,3 +1,47 @@
+2013-12-23 Eric Carlson <[email protected]>
+
+ AudioSessionManager should be MediaSessionManager
+ https://bugs.webkit.org/show_bug.cgi?id=126087
+
+ Reviewed by Jer Noble.
+
+ No new tests, no change in functionality.
+
+ * WebCore.xcodeproj/project.pbxproj: Change file names.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement): MediaSessionManagerToken::create() takes a client
+ interface instead of the media type.
+ * html/HTMLMediaElement.h:
+
+ * platform/audio/AudioSessionListener.h: Include <wtf/Noncopyable.h>.
+
+ AudioSessionManager.* -> MediaSessionManager.*
+ * platform/audio/AudioSessionManager.cpp: Removed.
+ * platform/audio/AudioSessionManager.h: Removed.
+ * platform/audio/MediaSessionManager.cpp: Copied from Source/WebCore/platform/audio/AudioSessionManager.cpp.
+ (MediaSessionManagerToken::create):
+ (MediaSessionManagerToken::MediaSessionManagerToken):
+ (MediaSessionManagerToken::~MediaSessionManagerToken):
+ (MediaSessionManager::sharedManager):
+ (MediaSessionManager::MediaSessionManager):
+ (MediaSessionManager::has):
+ (MediaSessionManager::count):
+ (MediaSessionManager::addToken):
+ (MediaSessionManager::removeToken):
+ (MediaSessionManager::updateSessionState):
+ * platform/audio/MediaSessionManager.h: Copied from Source/WebCore/platform/audio/AudioSessionManager.h.
+
+ * platform/audio/mac/AudioDestinationMac.cpp:
+ (WebCore::AudioDestinationMac::AudioDestinationMac): MediaSessionManagerToken::create() takes a
+ client interface instead of the media type.
+ * platform/audio/mac/AudioDestinationMac.h:
+
+ * platform/audio/mac/AudioSessionMac.cpp:
+ * platform/audio/mac/AudioSessionManagerMac.cpp: Removed.
+ * platform/audio/mac/MediaSessionManagerMac.cpp: Copied from Source/WebCore/platform/audio/mac/AudioSessionManagerMac.cpp.
+ (MediaSessionManager::updateSessionState):
+
2013-12-23 Zan Dobersek <[email protected]>
webkit gtk 2.2.3 stable tarball compilation error
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (160999 => 161000)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-12-23 18:24:06 UTC (rev 161000)
@@ -331,6 +331,7 @@
07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */; };
07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */; };
07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */; };
+ 07F944161864D046005D31CB /* MediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* MediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */; };
07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */; };
0806E57A12893045007CED32 /* SVGMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0806E57912893045007CED32 /* SVGMatrix.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5364,7 +5365,7 @@
CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5393D2175E018600C07123 /* JSMemoryInfo.h */; };
CD54A762180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */; };
CD54A763180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */; };
- CD54DE4717468B6F005E5B36 /* AudioSessionManagerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54DE4517468B6F005E5B36 /* AudioSessionManagerMac.cpp */; };
+ CD54DE4717468B6F005E5B36 /* MediaSessionManagerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54DE4517468B6F005E5B36 /* MediaSessionManagerMac.cpp */; };
CD54DE4B17469C6D005E5B36 /* AudioSessionMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */; };
CD61FE671794AADB004101EB /* MediaSourceRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1A942E115B5CE2200D525D1 /* MediaSourceRegistry.cpp */; };
CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = B1A942E215B5CE2200D525D1 /* MediaSourceRegistry.h */; };
@@ -5413,7 +5414,7 @@
CDAB6D2E17C814EE00C60B34 /* JSMediaControlsHost.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2C17C814EE00C60B34 /* JSMediaControlsHost.h */; };
CDAB6D3117C9259500C60B34 /* UserAgentScripts.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2F17C9259500C60B34 /* UserAgentScripts.h */; };
CDAB6D3217C9259500C60B34 /* UserAgentScriptsData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAB6D3017C9259500C60B34 /* UserAgentScriptsData.cpp */; };
- CDAE8C091746B95700532D78 /* AudioSessionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAE8C071746B95700532D78 /* AudioSessionManager.cpp */; };
+ CDAE8C091746B95700532D78 /* MediaSessionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAE8C071746B95700532D78 /* MediaSessionManager.cpp */; };
CDB859F7160D48A400E5B07F /* MediaKeyEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB859F4160D489900E5B07F /* MediaKeyEvent.cpp */; };
CDB859FA160D494900E5B07F /* JSMediaKeyEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB859F8160D493E00E5B07F /* JSMediaKeyEvent.cpp */; };
CDC26B40160A8CC60026757B /* MockCDM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDC26B3C160A62B00026757B /* MockCDM.cpp */; };
@@ -12481,7 +12482,7 @@
CD54A75E180F535000B076C9 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AudioTrackPrivateMediaSourceAVFObjC.cpp; path = objc/AudioTrackPrivateMediaSourceAVFObjC.cpp; sourceTree = "<group>"; };
CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateMediaSourceAVFObjC.h; path = objc/AudioTrackPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
- CD54DE4517468B6F005E5B36 /* AudioSessionManagerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSessionManagerMac.cpp; sourceTree = "<group>"; };
+ CD54DE4517468B6F005E5B36 /* MediaSessionManagerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionManagerMac.cpp; sourceTree = "<group>"; };
CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSessionMac.cpp; sourceTree = "<group>"; };
CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
@@ -12553,8 +12554,8 @@
CDAB6D2C17C814EE00C60B34 /* JSMediaControlsHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaControlsHost.h; sourceTree = "<group>"; };
CDAB6D2F17C9259500C60B34 /* UserAgentScripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserAgentScripts.h; sourceTree = "<group>"; };
CDAB6D3017C9259500C60B34 /* UserAgentScriptsData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserAgentScriptsData.cpp; sourceTree = "<group>"; };
- CDAE8C071746B95700532D78 /* AudioSessionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSessionManager.cpp; sourceTree = "<group>"; };
- CDAE8C081746B95700532D78 /* AudioSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSessionManager.h; sourceTree = "<group>"; };
+ CDAE8C071746B95700532D78 /* MediaSessionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionManager.cpp; sourceTree = "<group>"; };
+ CDAE8C081746B95700532D78 /* MediaSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManager.h; sourceTree = "<group>"; };
CDB859F2160D489900E5B07F /* MediaKeyError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaKeyError.h; sourceTree = "<group>"; };
CDB859F3160D489900E5B07F /* MediaKeyError.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaKeyError.idl; sourceTree = "<group>"; };
CDB859F4160D489900E5B07F /* MediaKeyEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaKeyEvent.cpp; sourceTree = "<group>"; };
@@ -21983,8 +21984,8 @@
CDA79823170A258300D45C55 /* AudioSession.cpp */,
CDA79821170A22DC00D45C55 /* AudioSession.h */,
CDA79822170A24F400D45C55 /* AudioSessionListener.h */,
- CDAE8C071746B95700532D78 /* AudioSessionManager.cpp */,
- CDAE8C081746B95700532D78 /* AudioSessionManager.h */,
+ CDAE8C071746B95700532D78 /* MediaSessionManager.cpp */,
+ CDAE8C081746B95700532D78 /* MediaSessionManager.h */,
FD31605312B026F700C1A359 /* AudioSourceProvider.h */,
FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */,
FD31605412B026F700C1A359 /* AudioUtilities.cpp */,
@@ -22055,7 +22056,7 @@
FD3160B812B0272A00C1A359 /* AudioFileReaderMac.cpp */,
FD3160B912B0272A00C1A359 /* AudioFileReaderMac.h */,
CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */,
- CD54DE4517468B6F005E5B36 /* AudioSessionManagerMac.cpp */,
+ CD54DE4517468B6F005E5B36 /* MediaSessionManagerMac.cpp */,
FD3160BA12B0272A00C1A359 /* FFTFrameMac.cpp */,
);
path = mac;
@@ -23871,6 +23872,7 @@
B2FA3D4F0AB75A6F000E5AC4 /* JSSVGAnimatedString.h in Headers */,
B2FA3D510AB75A6F000E5AC4 /* JSSVGAnimatedTransformList.h in Headers */,
076306E117E16089005A7C4E /* JSSourceInfo.h in Headers */,
+ 07F944161864D046005D31CB /* MediaSessionManager.h in Headers */,
B2FA3D530AB75A6F000E5AC4 /* JSSVGAnimateElement.h in Headers */,
4496E39E1398136C003EE32A /* JSSVGAnimateMotionElement.h in Headers */,
B2FA3D550AB75A6F000E5AC4 /* JSSVGAnimateTransformElement.h in Headers */,
@@ -25850,8 +25852,8 @@
CDA79824170A258300D45C55 /* AudioSession.cpp in Sources */,
CDA79827170A279100D45C55 /* AudioSessionIOS.mm in Sources */,
CD54DE4B17469C6D005E5B36 /* AudioSessionMac.cpp in Sources */,
- CDAE8C091746B95700532D78 /* AudioSessionManager.cpp in Sources */,
- CD54DE4717468B6F005E5B36 /* AudioSessionManagerMac.cpp in Sources */,
+ CDAE8C091746B95700532D78 /* MediaSessionManager.cpp in Sources */,
+ CD54DE4717468B6F005E5B36 /* MediaSessionManagerMac.cpp in Sources */,
FDB052DF1561A42C00B500D6 /* AudioSummingJunction.cpp in Sources */,
BE88E0D81715D2A200658D98 /* AudioTrack.cpp in Sources */,
BE88E0DB1715D2A200658D98 /* AudioTrackList.cpp in Sources */,
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (160999 => 161000)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -138,7 +138,7 @@
#endif
#if USE(AUDIO_SESSION)
-#include "AudioSessionManager.h"
+#include "MediaSessionManager.h"
#endif
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
@@ -342,7 +342,7 @@
, m_audioSourceNode(0)
#endif
#if USE(AUDIO_SESSION)
- , m_audioSessionManagerToken(AudioSessionManagerToken::create(tagName == videoTag ? AudioSessionManager::Video : AudioSessionManager::Audio))
+ , m_mediaSessionManagerToken(MediaSessionManagerToken::create(*this))
#endif
, m_reportedExtraMemoryCost(0)
#if ENABLE(MEDIA_STREAM)
@@ -5703,6 +5703,16 @@
return 0;
}
+#if USE(AUDIO_SESSION)
+MediaSessionManager::MediaType HTMLMediaElement::mediaType() const
+{
+ if (hasTagName(HTMLNames::videoTag))
+ return MediaSessionManager::Video;
+
+ return MediaSessionManager::Audio;
}
+#endif
+}
+
#endif
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (160999 => 161000)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2013-12-23 18:24:06 UTC (rev 161000)
@@ -53,11 +53,12 @@
#include "MediaStream.h"
#endif
+#if USE(AUDIO_SESSION)
+#include "MediaSessionManager.h"
+#endif
+
namespace WebCore {
-#if USE(AUDIO_SESSION)
-class AudioSessionManagerToken;
-#endif
#if ENABLE(WEB_AUDIO)
class AudioSourceProvider;
class MediaElementAudioSourceNode;
@@ -113,6 +114,9 @@
#if USE(PLATFORM_TEXT_TRACK_MENU)
, public PlatformTextTrackMenuClient
#endif
+#if USE(AUDIO_SESSION)
+ , public MediaSessionManagerClient
+#endif
{
public:
MediaPlayer* player() const { return m_player.get(); }
@@ -691,6 +695,10 @@
bool ensureMediaControlsInjectedScript();
#endif
+#if USE(AUDIO_SESSION)
+ virtual MediaSessionManager::MediaType mediaType() const OVERRIDE;
+#endif
+
Timer<HTMLMediaElement> m_loadTimer;
Timer<HTMLMediaElement> m_progressEventTimer;
Timer<HTMLMediaElement> m_playbackProgressTimer;
@@ -846,7 +854,7 @@
#endif
#if USE(AUDIO_SESSION)
- OwnPtr<AudioSessionManagerToken> m_audioSessionManagerToken;
+ std::unique_ptr<MediaSessionManagerToken> m_mediaSessionManagerToken;
#endif
std::unique_ptr<PageActivityAssertionToken> m_activityToken;
Modified: trunk/Source/WebCore/platform/audio/AudioSessionListener.h (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/AudioSessionListener.h 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/AudioSessionListener.h 2013-12-23 18:24:06 UTC (rev 161000)
@@ -28,6 +28,8 @@
#if USE(AUDIO_SESSION)
+#include <wtf/Noncopyable.h>
+
namespace WebCore {
class AudioSessionListener {
Deleted: trunk/Source/WebCore/platform/audio/AudioSessionManager.cpp (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/AudioSessionManager.cpp 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/AudioSessionManager.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -1,85 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "AudioSessionManager.h"
-
-#if USE(AUDIO_SESSION)
-
-using namespace WebCore;
-
-PassOwnPtr<AudioSessionManagerToken> AudioSessionManagerToken::create(AudioSessionManager::AudioType type)
-{
- return adoptPtr(new AudioSessionManagerToken(type));
-}
-
-AudioSessionManagerToken::AudioSessionManagerToken(AudioSessionManager::AudioType type)
- : m_type(type)
-{
- AudioSessionManager::sharedManager().incrementCount(type);
-}
-
-AudioSessionManagerToken::~AudioSessionManagerToken()
-{
- AudioSessionManager::sharedManager().decrementCount(m_type);
-}
-
-AudioSessionManager& AudioSessionManager::sharedManager()
-{
- DEFINE_STATIC_LOCAL(AudioSessionManager, manager, ());
- return manager;
-}
-
-AudioSessionManager::AudioSessionManager()
-{
-}
-
-bool AudioSessionManager::has(AudioSessionManager::AudioType type)
-{
- ASSERT(type >= 0);
- return m_typeCount.contains(type);
-}
-
-void AudioSessionManager::incrementCount(AudioSessionManager::AudioType type)
-{
- ASSERT(type >= 0);
- m_typeCount.add(type);
- updateSessionState();
-}
-
-void AudioSessionManager::decrementCount(AudioSessionManager::AudioType type)
-{
- ASSERT(type >= 0);
- m_typeCount.remove(type);
- updateSessionState();
-}
-
-#if !PLATFORM(MAC)
-void AudioSessionManager::updateSessionState()
-{
-}
-#endif
-
-#endif // USE(AUDIO_SESSION)
Deleted: trunk/Source/WebCore/platform/audio/AudioSessionManager.h (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/AudioSessionManager.h 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/AudioSessionManager.h 2013-12-23 18:24:06 UTC (rev 161000)
@@ -1,77 +0,0 @@
-/*
- * 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 AudioSessionManager_h
-#define AudioSessionManager_h
-
-#if USE(AUDIO_SESSION)
-
-#include "AudioSession.h"
-#include <wtf/HashCountedSet.h>
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-class AudioSessionManager {
-public:
- static AudioSessionManager& sharedManager();
-
- enum AudioType {
- None,
- Video,
- Audio,
- WebAudio,
- };
-
- bool has(AudioType);
-
-protected:
- friend class AudioSessionManagerToken;
- void incrementCount(AudioType);
- void decrementCount(AudioType);
-
-private:
- AudioSessionManager();
-
- void updateSessionState();
-
- HashCountedSet<size_t> m_typeCount;
-};
-
-class AudioSessionManagerToken {
-public:
- static PassOwnPtr<AudioSessionManagerToken> create(AudioSessionManager::AudioType);
- ~AudioSessionManagerToken();
-
-private:
- AudioSessionManagerToken(AudioSessionManager::AudioType);
-
- AudioSessionManager::AudioType m_type;
-};
-}
-
-#endif // USE(AUDIO_SESSION)
-
-#endif // AudioSessionManager_h
Added: trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (0 => 161000)
--- trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (rev 0)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "MediaSessionManager.h"
+
+using namespace WebCore;
+
+
+std::unique_ptr<MediaSessionManagerToken> MediaSessionManagerToken::create(MediaSessionManagerClient& client)
+{
+ return std::make_unique<MediaSessionManagerToken>(client);
+}
+
+MediaSessionManagerToken::MediaSessionManagerToken(MediaSessionManagerClient& client)
+ : m_client(client)
+{
+ m_type = m_client.mediaType();
+ MediaSessionManager::sharedManager().addToken(*this);
+}
+
+MediaSessionManagerToken::~MediaSessionManagerToken()
+{
+ MediaSessionManager::sharedManager().removeToken(*this);
+}
+
+MediaSessionManager& MediaSessionManager::sharedManager()
+{
+ DEFINE_STATIC_LOCAL(MediaSessionManager, manager, ());
+ return manager;
+}
+
+MediaSessionManager::MediaSessionManager()
+{
+}
+
+bool MediaSessionManager::has(MediaSessionManager::MediaType type) const
+{
+ ASSERT(type >= MediaSessionManager::None && type <= MediaSessionManager::WebAudio);
+
+ for (auto it = m_tokens.begin(), end = m_tokens.end(); it != end; ++it) {
+ if ((*it)->mediaType() == type)
+ return true;
+ }
+
+ return false;
+}
+
+int MediaSessionManager::count(MediaSessionManager::MediaType type) const
+{
+ ASSERT(type >= MediaSessionManager::None && type <= MediaSessionManager::WebAudio);
+
+ int count = 0;
+ for (auto it = m_tokens.begin(), end = m_tokens.end(); it != end; ++it) {
+ if ((*it)->mediaType() == type)
+ ++count;
+ }
+
+ return count;
+}
+
+void MediaSessionManager::addToken(MediaSessionManagerToken& token)
+{
+ m_tokens.append(&token);
+ updateSessionState();
+}
+
+void MediaSessionManager::removeToken(MediaSessionManagerToken& token)
+{
+ size_t index = m_tokens.find(&token);
+ ASSERT(index != notFound);
+ if (index == notFound)
+ return;
+
+ m_tokens.remove(index);
+ updateSessionState();
+}
+
+#if !PLATFORM(MAC)
+void MediaSessionManager::updateSessionState()
+{
+}
+#endif
Copied: trunk/Source/WebCore/platform/audio/MediaSessionManager.h (from rev 160999, trunk/Source/WebCore/platform/audio/AudioSessionManager.h) (0 => 161000)
--- trunk/Source/WebCore/platform/audio/MediaSessionManager.h (rev 0)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.h 2013-12-23 18:24:06 UTC (rev 161000)
@@ -0,0 +1,91 @@
+/*
+ * 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 MediaSessionManager_h
+#define MediaSessionManager_h
+
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class MediaSessionManagerToken;
+
+class MediaSessionManager {
+public:
+ static MediaSessionManager& sharedManager();
+
+ enum MediaType {
+ None,
+ Video,
+ Audio,
+ WebAudio,
+ };
+
+ bool has(MediaType) const;
+ int count(MediaType) const;
+
+protected:
+ friend class MediaSessionManagerToken;
+ void addToken(MediaSessionManagerToken&);
+ void removeToken(MediaSessionManagerToken&);
+
+private:
+ MediaSessionManager();
+
+ void updateSessionState();
+
+ Vector<MediaSessionManagerToken*> m_tokens;
+};
+
+class MediaSessionManagerClient {
+ WTF_MAKE_NONCOPYABLE(MediaSessionManagerClient);
+public:
+ MediaSessionManagerClient() { }
+
+ virtual MediaSessionManager::MediaType mediaType() const = 0;
+
+protected:
+ virtual ~MediaSessionManagerClient() { }
+};
+
+class MediaSessionManagerToken {
+public:
+ static std::unique_ptr<MediaSessionManagerToken> create(MediaSessionManagerClient&);
+
+ MediaSessionManagerToken(MediaSessionManagerClient&);
+ ~MediaSessionManagerToken();
+
+ MediaSessionManager::MediaType mediaType() const { return m_type; }
+
+private:
+
+ MediaSessionManagerClient& m_client;
+ MediaSessionManager::MediaType m_type;
+};
+
+}
+
+#endif // MediaSessionManager_h
Modified: trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -33,9 +33,10 @@
#include "AudioDestinationMac.h"
#include "AudioIOCallback.h"
-#include "AudioSessionManager.h"
+#include "AudioSession.h"
#include "FloatConversion.h"
#include "Logging.h"
+#include "MediaSessionManager.h"
#include "VectorMath.h"
#include <CoreAudio/AudioHardware.h>
@@ -82,7 +83,7 @@
, m_renderBus(AudioBus::create(2, kBufferSize, false))
, m_sampleRate(sampleRate)
, m_isPlaying(false)
- , m_audioSessionManagerToken(AudioSessionManagerToken::create(AudioSessionManager::WebAudio))
+ , m_mediaSessionManagerToken(MediaSessionManagerToken::create(*this))
{
// Open and initialize DefaultOutputUnit
AudioComponent comp;
Modified: trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h 2013-12-23 18:24:06 UTC (rev 161000)
@@ -31,17 +31,16 @@
#include "AudioBus.h"
#include "AudioDestination.h"
+#include "MediaSessionManager.h"
#include <AudioUnit/AudioUnit.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
-class AudioSessionManagerToken;
-
// An AudioDestination using CoreAudio's default output AudioUnit
-class AudioDestinationMac : public AudioDestination {
+class AudioDestinationMac : public AudioDestination, public MediaSessionManagerClient {
public:
AudioDestinationMac(AudioIOCallback&, float sampleRate);
virtual ~AudioDestinationMac();
@@ -60,6 +59,8 @@
OSStatus render(UInt32 numberOfFrames, AudioBufferList* ioData);
+ virtual MediaSessionManager::MediaType mediaType() const { return MediaSessionManager::WebAudio; }
+
AudioUnit m_outputUnit;
AudioIOCallback& m_callback;
RefPtr<AudioBus> m_renderBus;
@@ -68,7 +69,7 @@
bool m_isPlaying;
#if USE(AUDIO_SESSION)
- OwnPtr<AudioSessionManagerToken> m_audioSessionManagerToken;
+ std::unique_ptr<MediaSessionManagerToken> m_mediaSessionManagerToken;
#endif
};
Deleted: trunk/Source/WebCore/platform/audio/mac/AudioSessionManagerMac.cpp (160999 => 161000)
--- trunk/Source/WebCore/platform/audio/mac/AudioSessionManagerMac.cpp 2013-12-23 18:09:02 UTC (rev 160999)
+++ trunk/Source/WebCore/platform/audio/mac/AudioSessionManagerMac.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -1,56 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "AudioSessionManager.h"
-
-#if USE(AUDIO_SESSION) && PLATFORM(MAC)
-
-#include "Logging.h"
-#include "Settings.h"
-
-using namespace WebCore;
-
-static const size_t kWebAudioBufferSize = 128;
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-static const size_t kLowPowerVideoBufferSize = 4096;
-#endif
-
-void AudioSessionManager::updateSessionState()
-{
- LOG(Media, "AudioSessionManager::updateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", m_typeCount.count(Video), m_typeCount.count(Audio), m_typeCount.count(WebAudio));
-
- if (has(WebAudio))
- AudioSession::sharedSession().setPreferredBufferSize(kWebAudioBufferSize);
- // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below
- // causes media LayoutTests to fail on 10.8.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- else if ((has(Video) || has(Audio)) && Settings::lowPowerVideoAudioBufferSizeEnabled())
- AudioSession::sharedSession().setPreferredBufferSize(kLowPowerVideoBufferSize);
-#endif
-}
-
-#endif // USE(AUDIO_SESSION) && PLATFORM(MAC)
Copied: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp (from rev 160999, trunk/Source/WebCore/platform/audio/mac/AudioSessionManagerMac.cpp) (0 => 161000)
--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp (rev 0)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.cpp 2013-12-23 18:24:06 UTC (rev 161000)
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "MediaSessionManager.h"
+
+#if USE(AUDIO_SESSION) && PLATFORM(MAC)
+
+#include "AudioSession.h"
+#include "Logging.h"
+#include "Settings.h"
+
+using namespace WebCore;
+
+static const size_t kWebAudioBufferSize = 128;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+static const size_t kLowPowerVideoBufferSize = 4096;
+#endif
+
+void MediaSessionManager::updateSessionState()
+{
+ LOG(Media, "MediaSessionManager::updateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(Video), count(Audio), count(WebAudio));
+
+ if (has(WebAudio))
+ AudioSession::sharedSession().setPreferredBufferSize(kWebAudioBufferSize);
+ // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below
+ // causes media LayoutTests to fail on 10.8.
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ else if ((has(Video) || has(Audio)) && Settings::lowPowerVideoAudioBufferSizeEnabled())
+ AudioSession::sharedSession().setPreferredBufferSize(kLowPowerVideoBufferSize);
+#endif
+}
+
+#endif // USE(AUDIO_SESSION) && PLATFORM(MAC)