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

Unified Diff: media/midi/midi_manager_winrt.cc

Issue 2298103002: Disable Microsoft GS Wavetable Synth in Windows 10 Web MIDI backend (Closed)
Patch Set: using FALSE for boolean Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager_winrt.cc
diff --git a/media/midi/midi_manager_winrt.cc b/media/midi/midi_manager_winrt.cc
index 11841cbde431cb09c8c6a70dee481c8fe16a081d..0cc93adc8eb118623b915bf01eb2cb4dc2cc4707 100644
--- a/media/midi/midi_manager_winrt.cc
+++ b/media/midi/midi_manager_winrt.cc
@@ -118,6 +118,18 @@ HRESULT GetPointerToBufferData(IBuffer* buffer, uint8_t** out) {
return S_OK;
}
+// Checks if given DeviceInformation represent a Microsoft GS Wavetable Synth
+// instance.
+bool IsMicrosoftSynthesizer(IDeviceInformation* info) {
+ auto midi_synthesizer_statics =
+ WrlStaticsFactory<IMidiSynthesizerStatics,
+ RuntimeClass_Windows_Devices_Midi_MidiSynthesizer>();
+ boolean result = FALSE;
+ HRESULT hr = midi_synthesizer_statics->IsSynthesizer(info, &result);
+ VLOG_IF(1, FAILED(hr)) << "IsSynthesizer failed: " << PrintHr(hr);
+ return result != FALSE;
+}
+
// Tokens with value = 0 are considered invalid (as in <wrl/event.h>).
const int64_t kInvalidTokenValue = 0;
@@ -189,6 +201,11 @@ class MidiManagerWinrt::MidiPortManager {
WRL::Callback<ITypedEventHandler<DeviceWatcher*, DeviceInformation*>>(
[weak_ptr, task_runner](IDeviceWatcher* watcher,
IDeviceInformation* info) {
+ // Disable Microsoft GS Wavetable Synth due to security reasons.
+ // http://crbug.com/499279
+ if (IsMicrosoftSynthesizer(info))
+ return S_OK;
+
std::string dev_id = GetIdString(info),
dev_name = GetNameString(info);
@@ -356,9 +373,6 @@ class MidiManagerWinrt::MidiPortManager {
DCHECK(thread_checker_.CalledOnValidThread());
CHECK(is_initialized_);
- // TODO(shaochuan): Disable Microsoft GS Wavetable Synth due to security
- // reasons. http://crbug.com/499279
-
port_names_[dev_id] = dev_name;
WRL::Wrappers::HString dev_id_hstring;
@@ -423,6 +437,8 @@ class MidiManagerWinrt::MidiPortManager {
DCHECK(thread_checker_.CalledOnValidThread());
CHECK(is_initialized_);
+ // Note: in case Microsoft GS Wavetable Synth triggers this event for some
+ // reason, it will be ignored here with log emitted.
MidiPort<InterfaceType>* port = GetPortByDeviceId(dev_id);
if (!port) {
VLOG(1) << "Removing non-existent port " << dev_id;
« 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