OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 29 matching lines...) Expand all Loading... |
40 setInternalChannelInterpretation(AudioBus::Speakers); | 40 setInternalChannelInterpretation(AudioBus::Speakers); |
41 } | 41 } |
42 | 42 |
43 PassRefPtr<DefaultAudioDestinationHandler> DefaultAudioDestinationHandler::creat
e(AudioNode& node) | 43 PassRefPtr<DefaultAudioDestinationHandler> DefaultAudioDestinationHandler::creat
e(AudioNode& node) |
44 { | 44 { |
45 return adoptRef(new DefaultAudioDestinationHandler(node)); | 45 return adoptRef(new DefaultAudioDestinationHandler(node)); |
46 } | 46 } |
47 | 47 |
48 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler() | 48 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler() |
49 { | 49 { |
50 ASSERT(!isInitialized()); | 50 DCHECK(!isInitialized()); |
51 } | 51 } |
52 | 52 |
53 void DefaultAudioDestinationHandler::dispose() | 53 void DefaultAudioDestinationHandler::dispose() |
54 { | 54 { |
55 uninitialize(); | 55 uninitialize(); |
56 AudioDestinationHandler::dispose(); | 56 AudioDestinationHandler::dispose(); |
57 } | 57 } |
58 | 58 |
59 void DefaultAudioDestinationHandler::initialize() | 59 void DefaultAudioDestinationHandler::initialize() |
60 { | 60 { |
61 ASSERT(isMainThread()); | 61 DCHECK(isMainThread()); |
62 if (isInitialized()) | 62 if (isInitialized()) |
63 return; | 63 return; |
64 | 64 |
65 createDestination(); | 65 createDestination(); |
66 AudioHandler::initialize(); | 66 AudioHandler::initialize(); |
67 } | 67 } |
68 | 68 |
69 void DefaultAudioDestinationHandler::uninitialize() | 69 void DefaultAudioDestinationHandler::uninitialize() |
70 { | 70 { |
71 ASSERT(isMainThread()); | 71 DCHECK(isMainThread()); |
72 if (!isInitialized()) | 72 if (!isInitialized()) |
73 return; | 73 return; |
74 | 74 |
75 m_destination->stop(); | 75 m_destination->stop(); |
76 m_numberOfInputChannels = 0; | 76 m_numberOfInputChannels = 0; |
77 | 77 |
78 AudioHandler::uninitialize(); | 78 AudioHandler::uninitialize(); |
79 } | 79 } |
80 | 80 |
81 void DefaultAudioDestinationHandler::createDestination() | 81 void DefaultAudioDestinationHandler::createDestination() |
82 { | 82 { |
83 float hardwareSampleRate = AudioDestination::hardwareSampleRate(); | 83 float hardwareSampleRate = AudioDestination::hardwareSampleRate(); |
84 VLOG(1) << ">>>> hardwareSampleRate = " << hardwareSampleRate; | 84 VLOG(1) << ">>>> hardwareSampleRate = " << hardwareSampleRate; |
85 | 85 |
86 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI
nputChannels, channelCount(), hardwareSampleRate, context()->getSecurityOrigin()
); | 86 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI
nputChannels, channelCount(), hardwareSampleRate, context()->getSecurityOrigin()
); |
87 } | 87 } |
88 | 88 |
89 void DefaultAudioDestinationHandler::startRendering() | 89 void DefaultAudioDestinationHandler::startRendering() |
90 { | 90 { |
91 ASSERT(isInitialized()); | 91 DCHECK(isInitialized()); |
92 if (isInitialized()) { | 92 if (isInitialized()) { |
93 ASSERT(!m_destination->isPlaying()); | 93 DCHECK(!m_destination->isPlaying()); |
94 m_destination->start(); | 94 m_destination->start(); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void DefaultAudioDestinationHandler::stopRendering() | 98 void DefaultAudioDestinationHandler::stopRendering() |
99 { | 99 { |
100 ASSERT(isInitialized()); | 100 DCHECK(isInitialized()); |
101 if (isInitialized()) { | 101 if (isInitialized()) { |
102 ASSERT(m_destination->isPlaying()); | 102 DCHECK(m_destination->isPlaying()); |
103 m_destination->stop(); | 103 m_destination->stop(); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 unsigned long DefaultAudioDestinationHandler::maxChannelCount() const | 107 unsigned long DefaultAudioDestinationHandler::maxChannelCount() const |
108 { | 108 { |
109 return AudioDestination::maxChannelCount(); | 109 return AudioDestination::maxChannelCount(); |
110 } | 110 } |
111 | 111 |
112 void DefaultAudioDestinationHandler::setChannelCount(unsigned long channelCount,
ExceptionState& exceptionState) | 112 void DefaultAudioDestinationHandler::setChannelCount(unsigned long channelCount,
ExceptionState& exceptionState) |
113 { | 113 { |
114 // The channelCount for the input to this node controls the actual number of
channels we | 114 // The channelCount for the input to this node controls the actual number of
channels we |
115 // send to the audio hardware. It can only be set depending on the maximum n
umber of | 115 // send to the audio hardware. It can only be set depending on the maximum n
umber of |
116 // channels supported by the hardware. | 116 // channels supported by the hardware. |
117 | 117 |
118 ASSERT(isMainThread()); | 118 DCHECK(isMainThread()); |
119 | 119 |
120 if (!maxChannelCount() || channelCount > maxChannelCount()) { | 120 if (!maxChannelCount() || channelCount > maxChannelCount()) { |
121 exceptionState.throwDOMException( | 121 exceptionState.throwDOMException( |
122 IndexSizeError, | 122 IndexSizeError, |
123 ExceptionMessages::indexOutsideRange<unsigned>("channel count", chan
nelCount, 1, ExceptionMessages::InclusiveBound, maxChannelCount(), ExceptionMess
ages::InclusiveBound)); | 123 ExceptionMessages::indexOutsideRange<unsigned>("channel count", chan
nelCount, 1, ExceptionMessages::InclusiveBound, maxChannelCount(), ExceptionMess
ages::InclusiveBound)); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 unsigned long oldChannelCount = this->channelCount(); | 127 unsigned long oldChannelCount = this->channelCount(); |
128 AudioHandler::setChannelCount(channelCount, exceptionState); | 128 AudioHandler::setChannelCount(channelCount, exceptionState); |
(...skipping 14 matching lines...) Expand all Loading... |
143 setHandler(DefaultAudioDestinationHandler::create(*this)); | 143 setHandler(DefaultAudioDestinationHandler::create(*this)); |
144 } | 144 } |
145 | 145 |
146 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create(BaseAudioContex
t* context) | 146 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create(BaseAudioContex
t* context) |
147 { | 147 { |
148 return new DefaultAudioDestinationNode(*context); | 148 return new DefaultAudioDestinationNode(*context); |
149 } | 149 } |
150 | 150 |
151 } // namespace blink | 151 } // namespace blink |
152 | 152 |
OLD | NEW |