summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryukawa <yukawa@chromium.org>2015-04-02 22:32:17 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-03 05:33:09 +0000
commit43f9c3f62cb9faef5cd89eee48fd5e58e29a921f (patch)
treed06af667c8542c9f8c38e953f25fe8c7348a06e8
parent75b5fb357ecd8ff6febf1a5942f62651540a5e3d (diff)
downloadchromium_src-43f9c3f62cb9faef5cd89eee48fd5e58e29a921f.zip
chromium_src-43f9c3f62cb9faef5cd89eee48fd5e58e29a921f.tar.gz
chromium_src-43f9c3f62cb9faef5cd89eee48fd5e58e29a921f.tar.bz2
Use UsbIds::GetVendorName to retrieve USB vendor name.
Chromium already has a mechanism to query USB vendor name from the vender ID in device/usb/usb_ids.h. All we need to do is just to call device::UsbIds::GetVendorName() with the USB vendor ID. BUG=472338 TEST=Manually done with KORG nanoKEY2 on Windows 8.1 Review URL: https://codereview.chromium.org/1047383002 Cr-Commit-Position: refs/heads/master@{#323635}
-rw-r--r--media/BUILD.gn2
-rw-r--r--media/DEPS1
-rw-r--r--media/media.gyp3
-rw-r--r--media/midi/midi_manager_win.cc38
4 files changed, 25 insertions, 19 deletions
diff --git a/media/BUILD.gn b/media/BUILD.gn
index dfe9b7d..cf26159 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -412,6 +412,8 @@ component("media") {
}
if (is_win) {
+ deps += [ "//device/usb" ]
+
libs += [
"mf.lib",
"mfplat.lib",
diff --git a/media/DEPS b/media/DEPS
index a8ee49d..6d3642e 100644
--- a/media/DEPS
+++ b/media/DEPS
@@ -2,6 +2,7 @@
include_rules = [
"+crypto",
"+device/udev_linux",
+ "+device/usb",
"+gpu",
"+jni",
"+skia/ext",
diff --git a/media/media.gyp b/media/media.gyp
index 232d3fd..26ba789 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -971,6 +971,9 @@
},
}],
['OS=="win"', {
+ 'dependencies': [
+ '../device/usb/usb.gyp:device_usb',
+ ],
'link_settings': {
'libraries': [
'-lmf.lib',
diff --git a/media/midi/midi_manager_win.cc b/media/midi/midi_manager_win.cc
index 6c08014..bc72ce4 100644
--- a/media/midi/midi_manager_win.cc
+++ b/media/midi/midi_manager_win.cc
@@ -40,6 +40,7 @@
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "base/win/message_window.h"
+#include "device/usb/usb_ids.h"
#include "media/midi/midi_manager.h"
#include "media/midi/midi_message_queue.h"
#include "media/midi/midi_message_util.h"
@@ -289,6 +290,14 @@ struct MidiDeviceInfo final {
}
};
+std::string GetManufacturerName(const MidiDeviceInfo& info) {
+ if (info.is_usb_device)
+ return device::UsbIds::GetVendorName(info.usb_vendor_id);
+
+ // TODO(toyoshim): Support non USB-MIDI devices. crbug.com/472341.
+ return "";
+}
+
using PortNumberCache = base::hash_map<
MidiDeviceInfo,
std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>,
@@ -630,13 +639,12 @@ class MidiServiceWinImpl : public MidiServiceWin {
make_scoped_refptr(new MidiInputDeviceState(MidiDeviceInfo(caps)));
state->midi_handle = midi_in_handle;
state->midi_header = CreateMIDIHDR(kBufferLength);
+ const auto& state_device_info = state->device_info;
bool add_new_port = false;
uint32 port_number = 0;
- base::string16 product_name;
- uint32 driver_version = 0;
{
base::AutoLock auto_lock(input_ports_lock_);
- const auto it = unused_input_ports_.find(state->device_info);
+ const auto it = unused_input_ports_.find(state_device_info);
if (it == unused_input_ports_.end()) {
port_number = input_ports_.size();
add_new_port = true;
@@ -656,8 +664,6 @@ class MidiServiceWinImpl : public MidiServiceWin {
input_ports_[port_number];
input_ports_[port_number]->port_index = port_number;
input_ports_[port_number]->port_age = input_ports_ages_[port_number];
- product_name = input_ports_[port_number]->device_info.product_name;
- driver_version = input_ports_[port_number]->device_info.driver_version;
}
// Several initial startup tasks cannot be done in MIM_OPEN handler.
task_thread_.message_loop()->PostTask(
@@ -667,10 +673,9 @@ class MidiServiceWinImpl : public MidiServiceWin {
const MidiPortInfo port_info(
// TODO(toyoshim): Use a hash ID insted crbug.com/467448
base::IntToString(static_cast<int>(port_number)),
- // TODO(toyoshim): Retrieve the manifacturer name.
- "",
- base::WideToUTF8(product_name),
- MmversionToString(driver_version),
+ GetManufacturerName(state_device_info),
+ base::WideToUTF8(state_device_info.product_name),
+ MmversionToString(state_device_info.driver_version),
MIDI_PORT_OPENED);
task_thread_.message_loop()->PostTask(
FROM_HERE, base::Bind(&MidiServiceWinImpl::AddInputPortOnTaskThread,
@@ -815,14 +820,12 @@ class MidiServiceWinImpl : public MidiServiceWin {
auto state =
make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps)));
state->midi_handle = midi_out_handle;
-
+ const auto& state_device_info = state->device_info;
bool add_new_port = false;
uint32 port_number = 0;
- base::string16 product_name;
- uint32 driver_version = 0;
{
base::AutoLock auto_lock(output_ports_lock_);
- const auto it = unused_output_ports_.find(state->device_info);
+ const auto it = unused_output_ports_.find(state_device_info);
if (it == unused_output_ports_.end()) {
port_number = output_ports_.size();
add_new_port = true;
@@ -840,17 +843,14 @@ class MidiServiceWinImpl : public MidiServiceWin {
output_ports_[port_number];
output_ports_[port_number]->port_index = port_number;
output_ports_[port_number]->port_age = output_ports_ages_[port_number];
- product_name = output_ports_[port_number]->device_info.product_name;
- driver_version = output_ports_[port_number]->device_info.driver_version;
}
if (add_new_port) {
const MidiPortInfo port_info(
// TODO(toyoshim): Use a hash ID insted. crbug.com/467448
base::IntToString(static_cast<int>(port_number)),
- // TODO(toyoshim): Retrieve the manifacturer name.
- "",
- base::WideToUTF8(product_name),
- MmversionToString(driver_version),
+ GetManufacturerName(state_device_info),
+ base::WideToUTF8(state_device_info.product_name),
+ MmversionToString(state_device_info.driver_version),
MIDI_PORT_OPENED);
task_thread_.message_loop()->PostTask(
FROM_HERE, base::Bind(&MidiServiceWinImpl::AddOutputPortOnTaskThread,