Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Unified Diff: Source/modules/webmidi/MIDIAccess.cpp

Issue 962523005: Web MIDI: add open() and close() to MIDIPort (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review #14 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccessInitializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIAccess.cpp
diff --git a/Source/modules/webmidi/MIDIAccess.cpp b/Source/modules/webmidi/MIDIAccess.cpp
index ab75a15ea3ea41ccabaf5109e31d2d6b49a9bdac..af81061f51c741b3e2edfe0bc653fd5277f7004a 100644
--- a/Source/modules/webmidi/MIDIAccess.cpp
+++ b/Source/modules/webmidi/MIDIAccess.cpp
@@ -46,6 +46,8 @@
namespace blink {
+using PortState = MIDIAccessor::MIDIPortState;
+
MIDIAccess::MIDIAccess(PassOwnPtr<MIDIAccessor> accessor, bool sysexEnabled, const Vector<MIDIAccessInitializer::PortDescriptor>& ports, ExecutionContext* executionContext)
: ActiveDOMObject(executionContext)
, m_accessor(accessor)
@@ -55,9 +57,9 @@ MIDIAccess::MIDIAccess(PassOwnPtr<MIDIAccessor> accessor, bool sysexEnabled, con
for (size_t i = 0; i < ports.size(); ++i) {
const MIDIAccessInitializer::PortDescriptor& port = ports[i];
if (port.type == MIDIPort::MIDIPortTypeInput) {
- m_inputs.append(MIDIInput::create(this, port.id, port.manufacturer, port.name, port.version, port.isActive));
+ m_inputs.append(MIDIInput::create(this, port.id, port.manufacturer, port.name, port.version, port.state));
} else {
- m_outputs.append(MIDIOutput::create(this, m_outputs.size(), port.id, port.manufacturer, port.name, port.version, port.isActive));
+ m_outputs.append(MIDIOutput::create(this, m_outputs.size(), port.id, port.manufacturer, port.name, port.version, port.state));
}
}
}
@@ -72,7 +74,7 @@ MIDIInputMap* MIDIAccess::inputs() const
size_t inactiveCount = 0;
for (size_t i = 0; i < m_inputs.size(); ++i) {
MIDIInput* input = m_inputs[i];
- if (input->isActive())
+ if (input->getState() != PortState::MIDIPortStateDisconnected)
inputs.add(input->id(), input);
else
inactiveCount++;
@@ -90,7 +92,7 @@ MIDIOutputMap* MIDIAccess::outputs() const
size_t inactiveCount = 0;
for (size_t i = 0; i < m_outputs.size(); ++i) {
MIDIOutput* output = m_outputs[i];
- if (output->isActive())
+ if (output->getState() != PortState::MIDIPortStateDisconnected)
outputs.add(output->id(), output);
else
inactiveCount++;
@@ -102,40 +104,40 @@ MIDIOutputMap* MIDIAccess::outputs() const
return new MIDIOutputMap(outputs);
}
-void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, const String& name, const String& version, bool isActive)
+void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, const String& name, const String& version, PortState state)
{
ASSERT(isMainThread());
- MIDIInput* port = MIDIInput::create(this, id, manufacturer, name, version, isActive);
+ MIDIInput* port = MIDIInput::create(this, id, manufacturer, name, version, state);
m_inputs.append(port);
dispatchEvent(MIDIConnectionEvent::create(port));
}
-void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer, const String& name, const String& version, bool isActive)
+void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer, const String& name, const String& version, PortState state)
{
ASSERT(isMainThread());
unsigned portIndex = m_outputs.size();
- MIDIOutput* port = MIDIOutput::create(this, portIndex, id, manufacturer, name, version, isActive);
+ MIDIOutput* port = MIDIOutput::create(this, portIndex, id, manufacturer, name, version, state);
m_outputs.append(port);
dispatchEvent(MIDIConnectionEvent::create(port));
}
-void MIDIAccess::didSetInputPortState(unsigned portIndex, bool isActive)
+void MIDIAccess::didSetInputPortState(unsigned portIndex, PortState state)
{
ASSERT(isMainThread());
if (portIndex >= m_inputs.size())
return;
- m_inputs[portIndex]->setActiveState(isActive);
+ m_inputs[portIndex]->setState(state);
dispatchEvent(MIDIConnectionEvent::create(m_inputs[portIndex]));
}
-void MIDIAccess::didSetOutputPortState(unsigned portIndex, bool isActive)
+void MIDIAccess::didSetOutputPortState(unsigned portIndex, PortState state)
{
ASSERT(isMainThread());
if (portIndex >= m_outputs.size())
return;
- m_outputs[portIndex]->setActiveState(isActive);
+ m_outputs[portIndex]->setState(state);
dispatchEvent(MIDIConnectionEvent::create(m_outputs[portIndex]));
}
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccessInitializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698