Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: Source/WebCore/platform/mac/PlatformClockCA.cpp

Issue 13713003: Remove all of WebCore/platform/mac which is not mentioned in WebCore.gypi. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added back a couple needed headers Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27
28 #if USE(COREAUDIO)
29
30 #include "PlatformClockCA.h"
31
32 #include "FloatConversion.h"
33 #include <AudioToolbox/CoreAudioClock.h>
34 #include <CoreAudio/AudioHardware.h>
35
36 using namespace WebCore;
37
38 PlatformClockCA::PlatformClockCA()
39 : m_clock(0)
40 , m_running(false)
41 {
42 CAClockNew(0, &m_clock);
43 UInt32 timebase = kCAClockTimebase_AudioDevice;
44 UInt32 timebaseSize = sizeof(timebase);
45 CAClockSetProperty(m_clock, kCAClockProperty_InternalTimebase, timebaseSize, &timebase);
46
47 AudioObjectID defaultAudioOutput = 0;
48 UInt32 defaultAudioOutputSize = sizeof(defaultAudioOutput);
49
50 AudioObjectPropertyAddress address;
51 address.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
52 address.mScope = kAudioObjectPropertyScopeGlobal;
53 address.mElement = kAudioObjectPropertyElementMaster;
54
55 AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, 0, &defaul tAudioOutputSize, &defaultAudioOutput);
56 CAClockSetProperty(m_clock, kCAClockProperty_TimebaseSource, defaultAudioOut putSize, &defaultAudioOutput);
57 }
58
59 PlatformClockCA::~PlatformClockCA()
60 {
61 CAClockDispose(m_clock);
62 }
63
64 void PlatformClockCA::setCurrentTime(float time)
65 {
66 if (m_running)
67 CAClockStop(m_clock);
68 CAClockTime caTime;
69 caTime.format = kCAClockTimeFormat_Seconds;
70 caTime.time.seconds = time;
71 CAClockSetCurrentTime(m_clock, &caTime);
72 if (m_running)
73 CAClockStart(m_clock);
74 }
75
76 float PlatformClockCA::currentTime() const
77 {
78 CAClockTime caTime;
79
80 // CAClock does not return the correct current time when stopped. Instead, q uery for
81 // what is the start time, i.e. what the current time will be when started.
82 if (m_running) {
83 if (CAClockGetCurrentTime(m_clock, kCAClockTimeFormat_Seconds, &caTime) == noErr)
84 return narrowPrecisionToFloat(caTime.time.seconds);
85 } else {
86 if (CAClockGetStartTime(m_clock, kCAClockTimeFormat_Seconds, &caTime) == noErr)
87 return narrowPrecisionToFloat(caTime.time.seconds);
88 }
89 return 0;
90 }
91
92 void PlatformClockCA::setPlayRate(float rate)
93 {
94 CAClockSetPlayRate(m_clock, rate);
95 }
96
97 float PlatformClockCA::PlatformClockCA::playRate() const
98 {
99 double rate = 0;
100 if (CAClockGetPlayRate(m_clock, &rate) == noErr)
101 return narrowPrecisionToFloat(rate);
102 return 0;
103 }
104
105 void PlatformClockCA::start()
106 {
107 if (m_running)
108 return;
109 m_running = true;
110 CAClockStart(m_clock);
111 }
112
113 void PlatformClockCA::stop()
114 {
115 if (!m_running)
116 return;
117 m_running = false;
118 CAClockStop(m_clock);
119 }
120
121
122 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/platform/mac/PlatformClockCA.h ('k') | Source/WebCore/platform/mac/PlatformClockCM.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698