diff options
author | toyoshim <toyoshim@chromium.org> | 2015-07-21 00:29:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-21 07:30:28 +0000 |
commit | 7f258c184e269772364d4f21a1c1fbf3b514381d (patch) | |
tree | c2c1c8a10c1ae618a5ae7b86f2431a7f5ffa2845 | |
parent | 3cd5879f2c4f71888e8f7342d6b3b3a6d1dc6501 (diff) | |
download | chromium_src-7f258c184e269772364d4f21a1c1fbf3b514381d.zip chromium_src-7f258c184e269772364d4f21a1c1fbf3b514381d.tar.gz chromium_src-7f258c184e269772364d4f21a1c1fbf3b514381d.tar.bz2 |
Web MIDI: make unsupported device check strict
Some hardware devices seem to report the same MID and PID with the
blacklisted software synth. This patch adds one more check to
disable only software synth.
BUG=512318
Review URL: https://codereview.chromium.org/1241413002
Cr-Commit-Position: refs/heads/master@{#339621}
-rw-r--r-- | media/midi/midi_manager_win.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/media/midi/midi_manager_win.cc b/media/midi/midi_manager_win.cc index 4b7170a..3f23ad9 100644 --- a/media/midi/midi_manager_win.cc +++ b/media/midi/midi_manager_win.cc @@ -189,7 +189,8 @@ struct MidiDeviceInfo final { product_name(AsString16(caps.szPname)), usb_vendor_id(ExtractUsbVendorIdIfExists(caps)), usb_product_id(ExtractUsbProductIdIfExists(caps)), - is_usb_device(IsUsbDevice(caps)) {} + is_usb_device(IsUsbDevice(caps)), + is_software_synth(false) {} explicit MidiDeviceInfo(const MIDIOUTCAPS2W& caps) : manufacturer_id(caps.wMid), product_id(caps.wPid), @@ -197,7 +198,8 @@ struct MidiDeviceInfo final { product_name(AsString16(caps.szPname)), usb_vendor_id(ExtractUsbVendorIdIfExists(caps)), usb_product_id(ExtractUsbProductIdIfExists(caps)), - is_usb_device(IsUsbDevice(caps)) {} + is_usb_device(IsUsbDevice(caps)), + is_software_synth(IsSoftwareSynth(caps)) {} explicit MidiDeviceInfo(const MidiDeviceInfo& info) : manufacturer_id(info.manufacturer_id), product_id(info.product_id), @@ -205,7 +207,8 @@ struct MidiDeviceInfo final { product_name(info.product_name), usb_vendor_id(info.usb_vendor_id), usb_product_id(info.usb_product_id), - is_usb_device(info.is_usb_device) {} + is_usb_device(info.is_usb_device), + is_software_synth(info.is_software_synth) {} // Currently only following entities are considered when testing the equality // of two MIDI devices. // TODO(toyoshim): Consider to calculate MIDIPort.id here and use it as the @@ -217,6 +220,7 @@ struct MidiDeviceInfo final { const uint16 usb_vendor_id; const uint16 usb_product_id; const bool is_usb_device; + const bool is_software_synth; // Required to be used as the key of base::hash_map. bool operator==(const MidiDeviceInfo& that) const { @@ -260,6 +264,9 @@ struct MidiDeviceInfo final { return IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid) && IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid); } + static bool IsSoftwareSynth(const MIDIOUTCAPS2W& caps) { + return caps.wTechnology == MOD_SWSYNTH; + } static uint16 ExtractUsbVendorIdIfExists(const MIDIINCAPS2W& caps) { if (!IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid)) return 0; @@ -298,7 +305,7 @@ std::string GetManufacturerName(const MidiDeviceInfo& info) { } bool IsUnsupportedDevice(const MidiDeviceInfo& info) { - return info.manufacturer_id == MM_MICROSOFT && + return info.is_software_synth && info.manufacturer_id == MM_MICROSOFT && (info.product_id == MM_MSFT_WDMAUDIO_MIDIOUT || info.product_id == MM_MSFT_GENERIC_MIDISYNTH); } |