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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return; | 83 return; |
84 | 84 |
85 if (getConnection() != ConnectionStateOpen) | 85 if (getConnection() != ConnectionStateOpen) |
86 return; | 86 return; |
87 | 87 |
88 // Drop sysex message here when the client does not request it. Note that th
is is not a security check but an | 88 // Drop sysex message here when the client does not request it. Note that th
is is not a security check but an |
89 // automatic filtering for clients that do not want sysex message. Also note
that sysex message will never be sent | 89 // automatic filtering for clients that do not want sysex message. Also note
that sysex message will never be sent |
90 // unless the current process has an explicit permission to handle sysex mes
sage. | 90 // unless the current process has an explicit permission to handle sysex mes
sage. |
91 if (data[0] == 0xf0 && !midiAccess()->sysexEnabled()) | 91 if (data[0] == 0xf0 && !midiAccess()->sysexEnabled()) |
92 return; | 92 return; |
93 RefPtr<DOMUint8Array> array = DOMUint8Array::create(data, length); | 93 RefPtr<DOMUint8Array> array = DOMUint8Array::createOrNull(data, length); |
94 dispatchEvent(MIDIMessageEvent::create(timeStamp, array)); | 94 // Silently fail if array allocation failed (out of memory). |
| 95 if (array) |
| 96 dispatchEvent(MIDIMessageEvent::create(timeStamp, array.release())); |
95 } | 97 } |
96 | 98 |
97 DEFINE_TRACE(MIDIInput) | 99 DEFINE_TRACE(MIDIInput) |
98 { | 100 { |
99 MIDIPort::trace(visitor); | 101 MIDIPort::trace(visitor); |
100 } | 102 } |
101 | 103 |
102 } // namespace blink | 104 } // namespace blink |
OLD | NEW |