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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // There is id duplication that violates the spec. | 100 // There is id duplication that violates the spec. |
101 outputs.clear(); | 101 outputs.clear(); |
102 } | 102 } |
103 return new MIDIOutputMap(outputs); | 103 return new MIDIOutputMap(outputs); |
104 } | 104 } |
105 | 105 |
106 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version, bool isActive) | 106 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version, bool isActive) |
107 { | 107 { |
108 ASSERT(isMainThread()); | 108 ASSERT(isMainThread()); |
109 m_inputs.append(MIDIInput::create(this, id, manufacturer, name, version, isA
ctive)); | 109 m_inputs.append(MIDIInput::create(this, id, manufacturer, name, version, isA
ctive)); |
| 110 // FIXME: Pass MIDIPort. |
| 111 dispatchEvent(MIDIConnectionEvent::create()); |
110 } | 112 } |
111 | 113 |
112 void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version, bool isActive) | 114 void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version, bool isActive) |
113 { | 115 { |
114 ASSERT(isMainThread()); | 116 ASSERT(isMainThread()); |
115 unsigned portIndex = m_outputs.size(); | 117 unsigned portIndex = m_outputs.size(); |
116 m_outputs.append(MIDIOutput::create(this, portIndex, id, manufacturer, name,
version, isActive)); | 118 m_outputs.append(MIDIOutput::create(this, portIndex, id, manufacturer, name,
version, isActive)); |
| 119 // FIXME: Pass MIDIPort. |
| 120 dispatchEvent(MIDIConnectionEvent::create()); |
117 } | 121 } |
118 | 122 |
119 void MIDIAccess::didSetInputPortState(unsigned portIndex, bool isActive) | 123 void MIDIAccess::didSetInputPortState(unsigned portIndex, bool isActive) |
120 { | 124 { |
121 ASSERT(isMainThread()); | 125 ASSERT(isMainThread()); |
122 if (portIndex < m_inputs.size()) | 126 if (portIndex >= m_inputs.size()) |
123 m_inputs[portIndex]->setActiveState(isActive); | 127 return; |
| 128 |
| 129 m_inputs[portIndex]->setActiveState(isActive); |
| 130 // FIXME: Pass MIDIPort. |
| 131 dispatchEvent(MIDIConnectionEvent::create()); |
124 } | 132 } |
125 | 133 |
126 void MIDIAccess::didSetOutputPortState(unsigned portIndex, bool isActive) | 134 void MIDIAccess::didSetOutputPortState(unsigned portIndex, bool isActive) |
127 { | 135 { |
128 ASSERT(isMainThread()); | 136 ASSERT(isMainThread()); |
129 if (portIndex < m_outputs.size()) | 137 if (portIndex >= m_outputs.size()) |
130 m_outputs[portIndex]->setActiveState(isActive); | 138 return; |
| 139 |
| 140 m_outputs[portIndex]->setActiveState(isActive); |
| 141 // FIXME: Pass MIDIPort. |
| 142 dispatchEvent(MIDIConnectionEvent::create()); |
131 } | 143 } |
132 | 144 |
133 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) | 145 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) |
134 { | 146 { |
135 ASSERT(isMainThread()); | 147 ASSERT(isMainThread()); |
136 if (portIndex >= m_inputs.size()) | 148 if (portIndex >= m_inputs.size()) |
137 return; | 149 return; |
138 | 150 |
139 // Convert from time in seconds which is based on the time coordinate system
of monotonicallyIncreasingTime() | 151 // Convert from time in seconds which is based on the time coordinate system
of monotonicallyIncreasingTime() |
140 // into time in milliseconds (a DOMHighResTimeStamp) according to the same t
ime coordinate system as performance.now(). | 152 // into time in milliseconds (a DOMHighResTimeStamp) according to the same t
ime coordinate system as performance.now(). |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 188 |
177 DEFINE_TRACE(MIDIAccess) | 189 DEFINE_TRACE(MIDIAccess) |
178 { | 190 { |
179 visitor->trace(m_inputs); | 191 visitor->trace(m_inputs); |
180 visitor->trace(m_outputs); | 192 visitor->trace(m_outputs); |
181 RefCountedGarbageCollectedEventTargetWithInlineData<MIDIAccess>::trace(visit
or); | 193 RefCountedGarbageCollectedEventTargetWithInlineData<MIDIAccess>::trace(visit
or); |
182 ActiveDOMObject::trace(visitor); | 194 ActiveDOMObject::trace(visitor); |
183 } | 195 } |
184 | 196 |
185 } // namespace blink | 197 } // namespace blink |
OLD | NEW |