From b6cfa6a1c84229eab303875c9ea64f817338ff8e Mon Sep 17 00:00:00 2001 From: yhirano Date: Thu, 28 Aug 2014 19:37:23 -0700 Subject: [PATCH] [MIDI] Make android MIDI port id unique MIDI port id must be unique, as specified in the spec. BUG=341423 Review URL: https://codereview.chromium.org/516893002 Cr-Commit-Position: refs/heads/master@{#292553} --- media/midi/midi_manager_usb.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/media/midi/midi_manager_usb.cc b/media/midi/midi_manager_usb.cc index f2cf866aa0c6..fcefdf5a5222 100644 --- a/media/midi/midi_manager_usb.cc +++ b/media/midi/midi_manager_usb.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/strings/stringprintf.h" #include "media/midi/usb_midi_descriptor_parser.h" #include "media/midi/usb_midi_device.h" #include "media/midi/usb_midi_input_stream.h" @@ -94,12 +95,24 @@ void MidiManagerUsb::OnEnumerateDevicesDone(bool result, if (jacks[j].direction() == UsbMidiJack::DIRECTION_OUT) { output_streams_.push_back(new UsbMidiOutputStream(jacks[j])); // TODO(yhirano): Set appropriate properties. - AddOutputPort(MidiPortInfo()); + // TODO(yhiran): Port ID should contain product ID / vendor ID. + // Port ID must be unique in a MIDI manager. This (and the below) ID + // setting is sufficiently unique although there is no user-friendly + // meaning. + MidiPortInfo port; + port.id = base::StringPrintf("port-%ld-%ld", + static_cast(i), + static_cast(j)); + AddOutputPort(port); } else { DCHECK_EQ(jacks[j].direction(), UsbMidiJack::DIRECTION_IN); input_jacks.push_back(jacks[j]); // TODO(yhirano): Set appropriate properties. - AddInputPort(MidiPortInfo()); + MidiPortInfo port; + port.id = base::StringPrintf("port-%ld-%ld", + static_cast(i), + static_cast(j)); + AddInputPort(port); } } input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); -- 2.11.4.GIT