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

Side by Side Diff: media/midi/midi_manager_usb.cc

Issue 516893002: [MIDI] Make android MIDI port id unique (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/midi/midi_manager_usb.h" 5 #include "media/midi/midi_manager_usb.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/stringprintf.h"
11 #include "media/midi/usb_midi_descriptor_parser.h" 12 #include "media/midi/usb_midi_descriptor_parser.h"
12 #include "media/midi/usb_midi_device.h" 13 #include "media/midi/usb_midi_device.h"
13 #include "media/midi/usb_midi_input_stream.h" 14 #include "media/midi/usb_midi_input_stream.h"
14 #include "media/midi/usb_midi_jack.h" 15 #include "media/midi/usb_midi_jack.h"
15 #include "media/midi/usb_midi_output_stream.h" 16 #include "media/midi/usb_midi_output_stream.h"
16 17
17 namespace media { 18 namespace media {
18 19
19 MidiManagerUsb::MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> factory) 20 MidiManagerUsb::MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> factory)
20 : device_factory_(factory.Pass()) { 21 : device_factory_(factory.Pass()) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 &jacks); 88 &jacks);
88 if (!parse_result) { 89 if (!parse_result) {
89 initialize_callback_.Run(MIDI_INITIALIZATION_ERROR); 90 initialize_callback_.Run(MIDI_INITIALIZATION_ERROR);
90 return; 91 return;
91 } 92 }
92 std::vector<UsbMidiJack> input_jacks; 93 std::vector<UsbMidiJack> input_jacks;
93 for (size_t j = 0; j < jacks.size(); ++j) { 94 for (size_t j = 0; j < jacks.size(); ++j) {
94 if (jacks[j].direction() == UsbMidiJack::DIRECTION_OUT) { 95 if (jacks[j].direction() == UsbMidiJack::DIRECTION_OUT) {
95 output_streams_.push_back(new UsbMidiOutputStream(jacks[j])); 96 output_streams_.push_back(new UsbMidiOutputStream(jacks[j]));
96 // TODO(yhirano): Set appropriate properties. 97 // TODO(yhirano): Set appropriate properties.
97 AddOutputPort(MidiPortInfo()); 98 // TODO(yhiran): Port ID should contain product ID / vendor ID.
99 // Port ID must be unique in a MIDI manager. This (and the below) ID
100 // setting is sufficiently unique although there is no user-friendly
101 // meaning.
102 MidiPortInfo port;
103 port.id = base::StringPrintf("port-%ld-%ld",
104 static_cast<long>(i),
105 static_cast<long>(j));
106 AddOutputPort(port);
98 } else { 107 } else {
99 DCHECK_EQ(jacks[j].direction(), UsbMidiJack::DIRECTION_IN); 108 DCHECK_EQ(jacks[j].direction(), UsbMidiJack::DIRECTION_IN);
100 input_jacks.push_back(jacks[j]); 109 input_jacks.push_back(jacks[j]);
101 // TODO(yhirano): Set appropriate properties. 110 // TODO(yhirano): Set appropriate properties.
102 AddInputPort(MidiPortInfo()); 111 MidiPortInfo port;
112 port.id = base::StringPrintf("port-%ld-%ld",
113 static_cast<long>(i),
114 static_cast<long>(j));
115 AddInputPort(port);
103 } 116 }
104 } 117 }
105 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); 118 input_stream_.reset(new UsbMidiInputStream(input_jacks, this));
106 } 119 }
107 initialize_callback_.Run(MIDI_OK); 120 initialize_callback_.Run(MIDI_OK);
108 } 121 }
109 122
110 } // namespace media 123 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698