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

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

Issue 1182913007: Merge M43: Web MIDI: disable unsupported devices on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
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 <dbt.h> 8 #include <dbt.h>
9 #include <ks.h> 9 #include <ks.h>
10 #include <ksmedia.h> 10 #include <ksmedia.h>
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 switch (info.manufacturer_id) { 299 switch (info.manufacturer_id) {
300 case MM_MICROSOFT: 300 case MM_MICROSOFT:
301 return "Microsoft Corporation"; 301 return "Microsoft Corporation";
302 default: 302 default:
303 // TODO(toyoshim): Support other manufacture IDs. crbug.com/472341. 303 // TODO(toyoshim): Support other manufacture IDs. crbug.com/472341.
304 return ""; 304 return "";
305 } 305 }
306 } 306 }
307 307
308 bool IsUnsupportedDevice(const MidiDeviceInfo& info) {
309 return info.manufacturer_id == MM_MICROSOFT &&
310 (info.product_id == MM_MSFT_WDMAUDIO_MIDIOUT ||
311 info.product_id == MM_MSFT_GENERIC_MIDISYNTH);
312 }
313
308 using PortNumberCache = base::hash_map< 314 using PortNumberCache = base::hash_map<
309 MidiDeviceInfo, 315 MidiDeviceInfo,
310 std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>, 316 std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>,
311 MidiDeviceInfo::Hasher>; 317 MidiDeviceInfo::Hasher>;
312 318
313 class DeviceMonitorWindow final { 319 class DeviceMonitorWindow final {
314 public: 320 public:
315 explicit DeviceMonitorWindow(base::Closure on_device_arrival) 321 explicit DeviceMonitorWindow(base::Closure on_device_arrival)
316 : on_device_arrival_(on_device_arrival), 322 : on_device_arrival_(on_device_arrival),
317 dev_notify_handle_(kInvalidDeviceNotifyHandle) { 323 dev_notify_handle_(kInvalidDeviceNotifyHandle) {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 result = midiOutGetDevCaps( 827 result = midiOutGetDevCaps(
822 device_id, reinterpret_cast<LPMIDIOUTCAPSW>(&caps), sizeof(caps)); 828 device_id, reinterpret_cast<LPMIDIOUTCAPSW>(&caps), sizeof(caps));
823 if (result != MMSYSERR_NOERROR) { 829 if (result != MMSYSERR_NOERROR) {
824 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result); 830 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result);
825 return; 831 return;
826 } 832 }
827 auto state = 833 auto state =
828 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps))); 834 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps)));
829 state->midi_handle = midi_out_handle; 835 state->midi_handle = midi_out_handle;
830 const auto& state_device_info = state->device_info; 836 const auto& state_device_info = state->device_info;
837 if (IsUnsupportedDevice(state_device_info))
838 return;
831 bool add_new_port = false; 839 bool add_new_port = false;
832 uint32 port_number = 0; 840 uint32 port_number = 0;
833 { 841 {
834 base::AutoLock auto_lock(output_ports_lock_); 842 base::AutoLock auto_lock(output_ports_lock_);
835 const auto it = unused_output_ports_.find(state_device_info); 843 const auto it = unused_output_ports_.find(state_device_info);
836 if (it == unused_output_ports_.end()) { 844 if (it == unused_output_ports_.end()) {
837 port_number = output_ports_.size(); 845 port_number = output_ports_.size();
838 add_new_port = true; 846 add_new_port = true;
839 output_ports_.push_back(nullptr); 847 output_ports_.push_back(nullptr);
840 output_ports_ages_.push_back(0); 848 output_ports_ages_.push_back(0);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 // TOOD(toyoshim): This calculation should be done when the date is actually 1196 // TOOD(toyoshim): This calculation should be done when the date is actually
1189 // sent. 1197 // sent.
1190 client->AccumulateMidiBytesSent(data.size()); 1198 client->AccumulateMidiBytesSent(data.size());
1191 } 1199 }
1192 1200
1193 MidiManager* MidiManager::Create() { 1201 MidiManager* MidiManager::Create() {
1194 return new MidiManagerWin(); 1202 return new MidiManagerWin();
1195 } 1203 }
1196 1204
1197 } // namespace media 1205 } // 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