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

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

Issue 1189113003: Merge M44: Web MIDI: disable unsupported devices on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2403
Patch Set: Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_win.h" 5 #include "media/midi/midi_manager_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <ks.h> 8 #include <ks.h>
9 #include <ksmedia.h> 9 #include <ksmedia.h>
10 #include <mmreg.h> 10 #include <mmreg.h>
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 switch (info.manufacturer_id) { 291 switch (info.manufacturer_id) {
292 case MM_MICROSOFT: 292 case MM_MICROSOFT:
293 return "Microsoft Corporation"; 293 return "Microsoft Corporation";
294 default: 294 default:
295 // TODO(toyoshim): Support other manufacture IDs. crbug.com/472341. 295 // TODO(toyoshim): Support other manufacture IDs. crbug.com/472341.
296 return ""; 296 return "";
297 } 297 }
298 } 298 }
299 299
300 bool IsUnsupportedDevice(const MidiDeviceInfo& info) {
301 return info.manufacturer_id == MM_MICROSOFT &&
302 (info.product_id == MM_MSFT_WDMAUDIO_MIDIOUT ||
303 info.product_id == MM_MSFT_GENERIC_MIDISYNTH);
304 }
305
300 using PortNumberCache = base::hash_map< 306 using PortNumberCache = base::hash_map<
301 MidiDeviceInfo, 307 MidiDeviceInfo,
302 std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>, 308 std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>,
303 MidiDeviceInfo::Hasher>; 309 MidiDeviceInfo::Hasher>;
304 310
305 struct MidiInputDeviceState final : base::RefCounted<MidiInputDeviceState> { 311 struct MidiInputDeviceState final : base::RefCounted<MidiInputDeviceState> {
306 explicit MidiInputDeviceState(const MidiDeviceInfo& device_info) 312 explicit MidiInputDeviceState(const MidiDeviceInfo& device_info)
307 : device_info(device_info), 313 : device_info(device_info),
308 midi_handle(kInvalidMidiInHandle), 314 midi_handle(kInvalidMidiInHandle),
309 port_index(0), 315 port_index(0),
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 result = midiOutGetDevCaps( 798 result = midiOutGetDevCaps(
793 device_id, reinterpret_cast<LPMIDIOUTCAPSW>(&caps), sizeof(caps)); 799 device_id, reinterpret_cast<LPMIDIOUTCAPSW>(&caps), sizeof(caps));
794 if (result != MMSYSERR_NOERROR) { 800 if (result != MMSYSERR_NOERROR) {
795 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result); 801 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result);
796 return; 802 return;
797 } 803 }
798 auto state = 804 auto state =
799 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps))); 805 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps)));
800 state->midi_handle = midi_out_handle; 806 state->midi_handle = midi_out_handle;
801 const auto& state_device_info = state->device_info; 807 const auto& state_device_info = state->device_info;
808 if (IsUnsupportedDevice(state_device_info))
809 return;
802 bool add_new_port = false; 810 bool add_new_port = false;
803 uint32 port_number = 0; 811 uint32 port_number = 0;
804 { 812 {
805 base::AutoLock auto_lock(output_ports_lock_); 813 base::AutoLock auto_lock(output_ports_lock_);
806 const auto it = unused_output_ports_.find(state_device_info); 814 const auto it = unused_output_ports_.find(state_device_info);
807 if (it == unused_output_ports_.end()) { 815 if (it == unused_output_ports_.end()) {
808 port_number = static_cast<uint32>(output_ports_.size()); 816 port_number = static_cast<uint32>(output_ports_.size());
809 add_new_port = true; 817 add_new_port = true;
810 output_ports_.push_back(nullptr); 818 output_ports_.push_back(nullptr);
811 output_ports_ages_.push_back(0); 819 output_ports_ages_.push_back(0);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 base::TimeTicks time) { 1166 base::TimeTicks time) {
1159 ReceiveMidiData(port_index, &data[0], data.size(), time); 1167 ReceiveMidiData(port_index, &data[0], data.size(), time);
1160 } 1168 }
1161 1169
1162 MidiManager* MidiManager::Create() { 1170 MidiManager* MidiManager::Create() {
1163 return new MidiManagerWin(); 1171 return new MidiManagerWin();
1164 } 1172 }
1165 1173
1166 } // namespace midi 1174 } // namespace midi
1167 } // namespace media 1175 } // 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