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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna
bled())) | 209 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna
bled())) |
210 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(),
timestamp); | 210 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(),
timestamp); |
211 } | 211 } |
212 | 212 |
213 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& exceptionState) | 213 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& exceptionState) |
214 { | 214 { |
215 if (timestamp == 0.0) | 215 if (timestamp == 0.0) |
216 timestamp = now(executionContext()); | 216 timestamp = now(executionContext()); |
217 | 217 |
218 RefPtr<DOMUint8Array> array = DOMUint8Array::create(unsignedData.size()); | 218 RefPtr<DOMUint8Array> array = DOMUint8Array::createOrNull(unsignedData.size(
)); |
| 219 if (!array) { |
| 220 exceptionState.throwRangeError("Out of memory."); |
| 221 return; |
| 222 } |
219 DOMUint8Array::ValueType* const arrayData = array->data(); | 223 DOMUint8Array::ValueType* const arrayData = array->data(); |
220 const uint32_t arrayLength = array->length(); | 224 const uint32_t arrayLength = array->length(); |
221 | 225 |
222 for (size_t i = 0; i < unsignedData.size(); ++i) { | 226 for (size_t i = 0; i < unsignedData.size(); ++i) { |
223 if (unsignedData[i] > 0xff) { | 227 if (unsignedData[i] > 0xff) { |
224 exceptionState.throwTypeError("The value at index " + String::number
(i) + " (" + String::number(unsignedData[i]) + ") is greater than 0xFF."); | 228 exceptionState.throwTypeError("The value at index " + String::number
(i) + " (" + String::number(unsignedData[i]) + ") is greater than 0xFF."); |
225 return; | 229 return; |
226 } | 230 } |
227 if (i < arrayLength) | 231 if (i < arrayLength) |
228 arrayData[i] = unsignedData[i] & 0xff; | 232 arrayData[i] = unsignedData[i] & 0xff; |
(...skipping 11 matching lines...) Expand all Loading... |
240 { | 244 { |
241 send(unsignedData, 0.0, exceptionState); | 245 send(unsignedData, 0.0, exceptionState); |
242 } | 246 } |
243 | 247 |
244 DEFINE_TRACE(MIDIOutput) | 248 DEFINE_TRACE(MIDIOutput) |
245 { | 249 { |
246 MIDIPort::trace(visitor); | 250 MIDIPort::trace(visitor); |
247 } | 251 } |
248 | 252 |
249 } // namespace blink | 253 } // namespace blink |
OLD | NEW |