OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 MIDIOutput::~MIDIOutput() | 192 MIDIOutput::~MIDIOutput() |
193 { | 193 { |
194 } | 194 } |
195 | 195 |
196 void MIDIOutput::send(DOMUint8Array* array, double timestamp, ExceptionState& ex
ceptionState) | 196 void MIDIOutput::send(DOMUint8Array* array, double timestamp, ExceptionState& ex
ceptionState) |
197 { | 197 { |
198 ASSERT(array); | 198 ASSERT(array); |
199 | 199 |
200 if (timestamp == 0.0) | 200 if (timestamp == 0.0) |
201 timestamp = now(executionContext()); | 201 timestamp = now(getExecutionContext()); |
202 | 202 |
203 // Implicit open. It does nothing if the port is already opened. | 203 // Implicit open. It does nothing if the port is already opened. |
204 // This should be performed even if |array| is invalid. | 204 // This should be performed even if |array| is invalid. |
205 open(); | 205 open(); |
206 | 206 |
207 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna
bled())) | 207 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna
bled())) |
208 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(),
timestamp); | 208 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(),
timestamp); |
209 } | 209 } |
210 | 210 |
211 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& exceptionState) | 211 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& exceptionState) |
212 { | 212 { |
213 if (timestamp == 0.0) | 213 if (timestamp == 0.0) |
214 timestamp = now(executionContext()); | 214 timestamp = now(getExecutionContext()); |
215 | 215 |
216 RefPtr<DOMUint8Array> array = DOMUint8Array::create(unsignedData.size()); | 216 RefPtr<DOMUint8Array> array = DOMUint8Array::create(unsignedData.size()); |
217 DOMUint8Array::ValueType* const arrayData = array->data(); | 217 DOMUint8Array::ValueType* const arrayData = array->data(); |
218 const uint32_t arrayLength = array->length(); | 218 const uint32_t arrayLength = array->length(); |
219 | 219 |
220 for (size_t i = 0; i < unsignedData.size(); ++i) { | 220 for (size_t i = 0; i < unsignedData.size(); ++i) { |
221 if (unsignedData[i] > 0xff) { | 221 if (unsignedData[i] > 0xff) { |
222 exceptionState.throwTypeError("The value at index " + String::number
(i) + " (" + String::number(unsignedData[i]) + ") is greater than 0xFF."); | 222 exceptionState.throwTypeError("The value at index " + String::number
(i) + " (" + String::number(unsignedData[i]) + ") is greater than 0xFF."); |
223 return; | 223 return; |
224 } | 224 } |
(...skipping 14 matching lines...) Expand all Loading... |
239 { | 239 { |
240 send(unsignedData, 0.0, exceptionState); | 240 send(unsignedData, 0.0, exceptionState); |
241 } | 241 } |
242 | 242 |
243 DEFINE_TRACE(MIDIOutput) | 243 DEFINE_TRACE(MIDIOutput) |
244 { | 244 { |
245 MIDIPort::trace(visitor); | 245 MIDIPort::trace(visitor); |
246 } | 246 } |
247 | 247 |
248 } // namespace blink | 248 } // namespace blink |
OLD | NEW |