| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(getExecutionContext()); | 214 timestamp = now(getExecutionContext()); |
| 215 | 215 |
| 216 RefPtr<DOMUint8Array> array = DOMUint8Array::create(unsignedData.size()); | 216 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 } |
| 225 if (i < arrayLength) | 225 if (i < arrayLength) |
| 226 arrayData[i] = unsignedData[i] & 0xff; | 226 arrayData[i] = unsignedData[i] & 0xff; |
| 227 } | 227 } |
| 228 | 228 |
| 229 send(array.get(), timestamp, exceptionState); | 229 send(array, timestamp, exceptionState); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exceptionState) | 232 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exceptionState) |
| 233 { | 233 { |
| 234 ASSERT(data); | 234 ASSERT(data); |
| 235 send(data, 0.0, exceptionState); | 235 send(data, 0.0, exceptionState); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& exceptionSt
ate) | 238 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& exceptionSt
ate) |
| 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 |