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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 ScopedMIDIHDR CreateMIDIHDR(size_t size) { 98 ScopedMIDIHDR CreateMIDIHDR(size_t size) {
99 ScopedMIDIHDR header(new MIDIHDR); 99 ScopedMIDIHDR header(new MIDIHDR);
100 ZeroMemory(header.get(), sizeof(*header)); 100 ZeroMemory(header.get(), sizeof(*header));
101 header->lpData = new char[size]; 101 header->lpData = new char[size];
102 header->dwBufferLength = static_cast<DWORD>(size); 102 header->dwBufferLength = static_cast<DWORD>(size);
103 return header.Pass(); 103 return header.Pass();
104 } 104 }
105 105
106 void SendShortMidiMessageInternal(HMIDIOUT midi_out_handle, 106 void SendShortMidiMessageInternal(HMIDIOUT midi_out_handle,
107 const std::vector<uint8>& message) { 107 const std::vector<uint8_t>& message) {
108 DCHECK_LE(message.size(), static_cast<size_t>(3)) 108 DCHECK_LE(message.size(), static_cast<size_t>(3))
109 << "A short MIDI message should be up to 3 bytes."; 109 << "A short MIDI message should be up to 3 bytes.";
110 110
111 DWORD packed_message = 0; 111 DWORD packed_message = 0;
112 for (size_t i = 0; i < message.size(); ++i) 112 for (size_t i = 0; i < message.size(); ++i)
113 packed_message |= (static_cast<uint32>(message[i]) << (i * 8)); 113 packed_message |= (static_cast<uint32_t>(message[i]) << (i * 8));
114 MMRESULT result = midiOutShortMsg(midi_out_handle, packed_message); 114 MMRESULT result = midiOutShortMsg(midi_out_handle, packed_message);
115 DLOG_IF(ERROR, result != MMSYSERR_NOERROR) 115 DLOG_IF(ERROR, result != MMSYSERR_NOERROR)
116 << "Failed to output short message: " << GetOutErrorMessage(result); 116 << "Failed to output short message: " << GetOutErrorMessage(result);
117 } 117 }
118 118
119 void SendLongMidiMessageInternal(HMIDIOUT midi_out_handle, 119 void SendLongMidiMessageInternal(HMIDIOUT midi_out_handle,
120 const std::vector<uint8>& message) { 120 const std::vector<uint8_t>& message) {
121 // Implementation note: 121 // Implementation note:
122 // Sending a long MIDI message can be performed synchronously or 122 // Sending a long MIDI message can be performed synchronously or
123 // asynchronously depending on the driver. There are 2 options to support both 123 // asynchronously depending on the driver. There are 2 options to support both
124 // cases: 124 // cases:
125 // 1) Call midiOutLongMsg() API and wait for its completion within this 125 // 1) Call midiOutLongMsg() API and wait for its completion within this
126 // function. In this approach, we can avoid memory copy by directly pointing 126 // function. In this approach, we can avoid memory copy by directly pointing
127 // |message| as the data buffer to be sent. 127 // |message| as the data buffer to be sent.
128 // 2) Allocate a buffer and copy |message| to it, then call midiOutLongMsg() 128 // 2) Allocate a buffer and copy |message| to it, then call midiOutLongMsg()
129 // API. The buffer will be freed in the MOM_DONE event hander, which tells 129 // API. The buffer will be freed in the MOM_DONE event hander, which tells
130 // us that the task of midiOutLongMsg() API is completed. 130 // us that the task of midiOutLongMsg() API is completed.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 driver_version(info.driver_version), 207 driver_version(info.driver_version),
208 product_name(info.product_name), 208 product_name(info.product_name),
209 usb_vendor_id(info.usb_vendor_id), 209 usb_vendor_id(info.usb_vendor_id),
210 usb_product_id(info.usb_product_id), 210 usb_product_id(info.usb_product_id),
211 is_usb_device(info.is_usb_device), 211 is_usb_device(info.is_usb_device),
212 is_software_synth(info.is_software_synth) {} 212 is_software_synth(info.is_software_synth) {}
213 // Currently only following entities are considered when testing the equality 213 // Currently only following entities are considered when testing the equality
214 // of two MIDI devices. 214 // of two MIDI devices.
215 // TODO(toyoshim): Consider to calculate MIDIPort.id here and use it as the 215 // TODO(toyoshim): Consider to calculate MIDIPort.id here and use it as the
216 // key. See crbug.com/467448. Then optimize the data for |MidiPortInfo|. 216 // key. See crbug.com/467448. Then optimize the data for |MidiPortInfo|.
217 const uint16 manufacturer_id; 217 const uint16_t manufacturer_id;
218 const uint16 product_id; 218 const uint16_t product_id;
219 const uint32 driver_version; 219 const uint32_t driver_version;
220 const base::string16 product_name; 220 const base::string16 product_name;
221 const uint16 usb_vendor_id; 221 const uint16_t usb_vendor_id;
222 const uint16 usb_product_id; 222 const uint16_t usb_product_id;
223 const bool is_usb_device; 223 const bool is_usb_device;
224 const bool is_software_synth; 224 const bool is_software_synth;
225 225
226 // Required to be used as the key of base::hash_map. 226 // Required to be used as the key of base::hash_map.
227 bool operator==(const MidiDeviceInfo& that) const { 227 bool operator==(const MidiDeviceInfo& that) const {
228 return manufacturer_id == that.manufacturer_id && 228 return manufacturer_id == that.manufacturer_id &&
229 product_id == that.product_id && 229 product_id == that.product_id &&
230 driver_version == that.driver_version && 230 driver_version == that.driver_version &&
231 product_name == that.product_name && 231 product_name == that.product_name &&
232 is_usb_device == that.is_usb_device && 232 is_usb_device == that.is_usb_device &&
(...skipping 28 matching lines...) Expand all
261 return IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid) && 261 return IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid) &&
262 IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid); 262 IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid);
263 } 263 }
264 static bool IsUsbDevice(const MIDIOUTCAPS2W& caps) { 264 static bool IsUsbDevice(const MIDIOUTCAPS2W& caps) {
265 return IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid) && 265 return IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid) &&
266 IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid); 266 IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid);
267 } 267 }
268 static bool IsSoftwareSynth(const MIDIOUTCAPS2W& caps) { 268 static bool IsSoftwareSynth(const MIDIOUTCAPS2W& caps) {
269 return caps.wTechnology == MOD_SWSYNTH; 269 return caps.wTechnology == MOD_SWSYNTH;
270 } 270 }
271 static uint16 ExtractUsbVendorIdIfExists(const MIDIINCAPS2W& caps) { 271 static uint16_t ExtractUsbVendorIdIfExists(const MIDIINCAPS2W& caps) {
272 if (!IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid)) 272 if (!IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid))
273 return 0; 273 return 0;
274 return EXTRACT_USBAUDIO_MID(&caps.ManufacturerGuid); 274 return EXTRACT_USBAUDIO_MID(&caps.ManufacturerGuid);
275 } 275 }
276 static uint16 ExtractUsbVendorIdIfExists(const MIDIOUTCAPS2W& caps) { 276 static uint16_t ExtractUsbVendorIdIfExists(const MIDIOUTCAPS2W& caps) {
277 if (!IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid)) 277 if (!IS_COMPATIBLE_USBAUDIO_MID(&caps.ManufacturerGuid))
278 return 0; 278 return 0;
279 return EXTRACT_USBAUDIO_MID(&caps.ManufacturerGuid); 279 return EXTRACT_USBAUDIO_MID(&caps.ManufacturerGuid);
280 } 280 }
281 static uint16 ExtractUsbProductIdIfExists(const MIDIINCAPS2W& caps) { 281 static uint16_t ExtractUsbProductIdIfExists(const MIDIINCAPS2W& caps) {
282 if (!IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid)) 282 if (!IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid))
283 return 0; 283 return 0;
284 return EXTRACT_USBAUDIO_PID(&caps.ProductGuid); 284 return EXTRACT_USBAUDIO_PID(&caps.ProductGuid);
285 } 285 }
286 static uint16 ExtractUsbProductIdIfExists(const MIDIOUTCAPS2W& caps) { 286 static uint16_t ExtractUsbProductIdIfExists(const MIDIOUTCAPS2W& caps) {
287 if (!IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid)) 287 if (!IS_COMPATIBLE_USBAUDIO_PID(&caps.ProductGuid))
288 return 0; 288 return 0;
289 return EXTRACT_USBAUDIO_PID(&caps.ProductGuid); 289 return EXTRACT_USBAUDIO_PID(&caps.ProductGuid);
290 } 290 }
291 }; 291 };
292 292
293 std::string GetManufacturerName(const MidiDeviceInfo& info) { 293 std::string GetManufacturerName(const MidiDeviceInfo& info) {
294 if (info.is_usb_device) { 294 if (info.is_usb_device) {
295 const char* name = device::UsbIds::GetVendorName(info.usb_vendor_id); 295 const char* name = device::UsbIds::GetVendorName(info.usb_vendor_id);
296 return std::string(name ? name : ""); 296 return std::string(name ? name : "");
297 } 297 }
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) { 308 bool IsUnsupportedDevice(const MidiDeviceInfo& info) {
309 return info.is_software_synth && info.manufacturer_id == MM_MICROSOFT && 309 return info.is_software_synth && info.manufacturer_id == MM_MICROSOFT &&
310 (info.product_id == MM_MSFT_WDMAUDIO_MIDIOUT || 310 (info.product_id == MM_MSFT_WDMAUDIO_MIDIOUT ||
311 info.product_id == MM_MSFT_GENERIC_MIDISYNTH); 311 info.product_id == MM_MSFT_GENERIC_MIDISYNTH);
312 } 312 }
313 313
314 using PortNumberCache = base::hash_map< 314 using PortNumberCache =
315 MidiDeviceInfo, 315 base::hash_map<MidiDeviceInfo,
316 std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>>, 316 std::priority_queue<uint32_t,
317 MidiDeviceInfo::Hasher>; 317 std::vector<uint32_t>,
318 std::greater<uint32_t>>,
319 MidiDeviceInfo::Hasher>;
318 320
319 struct MidiInputDeviceState final 321 struct MidiInputDeviceState final
320 : base::RefCountedThreadSafe<MidiInputDeviceState> { 322 : base::RefCountedThreadSafe<MidiInputDeviceState> {
321 explicit MidiInputDeviceState(const MidiDeviceInfo& device_info) 323 explicit MidiInputDeviceState(const MidiDeviceInfo& device_info)
322 : device_info(device_info), 324 : device_info(device_info),
323 midi_handle(kInvalidMidiInHandle), 325 midi_handle(kInvalidMidiInHandle),
324 port_index(0), 326 port_index(0),
325 port_age(0), 327 port_age(0),
326 start_time_initialized(false) {} 328 start_time_initialized(false) {}
327 329
328 const MidiDeviceInfo device_info; 330 const MidiDeviceInfo device_info;
329 HMIDIIN midi_handle; 331 HMIDIIN midi_handle;
330 ScopedMIDIHDR midi_header; 332 ScopedMIDIHDR midi_header;
331 // Since Win32 multimedia system uses a relative time offset from when 333 // Since Win32 multimedia system uses a relative time offset from when
332 // |midiInStart| API is called, we need to record when it is called. 334 // |midiInStart| API is called, we need to record when it is called.
333 base::TimeTicks start_time; 335 base::TimeTicks start_time;
334 // 0-based port index. We will try to reuse the previous port index when the 336 // 0-based port index. We will try to reuse the previous port index when the
335 // MIDI device is closed then reopened. 337 // MIDI device is closed then reopened.
336 uint32 port_index; 338 uint32_t port_index;
337 // A sequence number which represents how many times |port_index| is reused. 339 // A sequence number which represents how many times |port_index| is reused.
338 // We can remove this field if we decide not to clear unsent events 340 // We can remove this field if we decide not to clear unsent events
339 // when the device is disconnected. 341 // when the device is disconnected.
340 // See https://github.com/WebAudio/web-midi-api/issues/133 342 // See https://github.com/WebAudio/web-midi-api/issues/133
341 uint64 port_age; 343 uint64_t port_age;
342 // True if |start_time| is initialized. This field is not used so far, but 344 // True if |start_time| is initialized. This field is not used so far, but
343 // kept for the debugging purpose. 345 // kept for the debugging purpose.
344 bool start_time_initialized; 346 bool start_time_initialized;
345 347
346 private: 348 private:
347 friend class base::RefCountedThreadSafe<MidiInputDeviceState>; 349 friend class base::RefCountedThreadSafe<MidiInputDeviceState>;
348 ~MidiInputDeviceState() {} 350 ~MidiInputDeviceState() {}
349 }; 351 };
350 352
351 struct MidiOutputDeviceState final 353 struct MidiOutputDeviceState final
352 : base::RefCountedThreadSafe<MidiOutputDeviceState> { 354 : base::RefCountedThreadSafe<MidiOutputDeviceState> {
353 explicit MidiOutputDeviceState(const MidiDeviceInfo& device_info) 355 explicit MidiOutputDeviceState(const MidiDeviceInfo& device_info)
354 : device_info(device_info), 356 : device_info(device_info),
355 midi_handle(kInvalidMidiOutHandle), 357 midi_handle(kInvalidMidiOutHandle),
356 port_index(0), 358 port_index(0),
357 port_age(0), 359 port_age(0),
358 closed(false) {} 360 closed(false) {}
359 361
360 const MidiDeviceInfo device_info; 362 const MidiDeviceInfo device_info;
361 HMIDIOUT midi_handle; 363 HMIDIOUT midi_handle;
362 // 0-based port index. We will try to reuse the previous port index when the 364 // 0-based port index. We will try to reuse the previous port index when the
363 // MIDI device is closed then reopened. 365 // MIDI device is closed then reopened.
364 uint32 port_index; 366 uint32_t port_index;
365 // A sequence number which represents how many times |port_index| is reused. 367 // A sequence number which represents how many times |port_index| is reused.
366 // We can remove this field if we decide not to clear unsent events 368 // We can remove this field if we decide not to clear unsent events
367 // when the device is disconnected. 369 // when the device is disconnected.
368 // See https://github.com/WebAudio/web-midi-api/issues/133 370 // See https://github.com/WebAudio/web-midi-api/issues/133
369 uint64 port_age; 371 uint64_t port_age;
370 // True if the device is already closed and |midi_handle| is considered to be 372 // True if the device is already closed and |midi_handle| is considered to be
371 // invalid. 373 // invalid.
372 // TODO(toyoshim): Use std::atomic<bool> when it is allowed in Chromium 374 // TODO(toyoshim): Use std::atomic<bool> when it is allowed in Chromium
373 // project. 375 // project.
374 volatile bool closed; 376 volatile bool closed;
375 377
376 private: 378 private:
377 friend class base::RefCountedThreadSafe<MidiOutputDeviceState>; 379 friend class base::RefCountedThreadSafe<MidiOutputDeviceState>;
378 ~MidiOutputDeviceState() {} 380 ~MidiOutputDeviceState() {}
379 }; 381 };
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); 497 base::SystemMonitor::Get()->AddDevicesChangedObserver(this);
496 498
497 UpdateDeviceList(); 499 UpdateDeviceList();
498 500
499 task_thread_.message_loop()->PostTask( 501 task_thread_.message_loop()->PostTask(
500 FROM_HERE, 502 FROM_HERE,
501 base::Bind(&MidiServiceWinImpl::CompleteInitializationOnTaskThread, 503 base::Bind(&MidiServiceWinImpl::CompleteInitializationOnTaskThread,
502 base::Unretained(this), Result::OK)); 504 base::Unretained(this), Result::OK));
503 } 505 }
504 506
505 void SendMidiDataAsync(uint32 port_number, 507 void SendMidiDataAsync(uint32_t port_number,
506 const std::vector<uint8>& data, 508 const std::vector<uint8_t>& data,
507 base::TimeTicks time) final { 509 base::TimeTicks time) final {
508 if (destructor_started) { 510 if (destructor_started) {
509 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is " 511 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is "
510 "being destructed. port: " << port_number; 512 "being destructed. port: " << port_number;
511 return; 513 return;
512 } 514 }
513 auto state = GetOutputDeviceFromPort(port_number); 515 auto state = GetOutputDeviceFromPort(port_number);
514 if (!state) { 516 if (!state) {
515 LOG(ERROR) << "ThreadSafeSendData failed due to an invalid port number. " 517 LOG(ERROR) << "ThreadSafeSendData failed due to an invalid port number. "
516 << "port: " << port_number; 518 << "port: " << port_number;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 567 }
566 568
567 scoped_refptr<MidiOutputDeviceState> GetOutputDeviceFromHandle( 569 scoped_refptr<MidiOutputDeviceState> GetOutputDeviceFromHandle(
568 HMIDIOUT midi_handle) { 570 HMIDIOUT midi_handle) {
569 base::AutoLock auto_lock(output_ports_lock_); 571 base::AutoLock auto_lock(output_ports_lock_);
570 const auto it = output_device_map_.find(midi_handle); 572 const auto it = output_device_map_.find(midi_handle);
571 return (it != output_device_map_.end() ? it->second : nullptr); 573 return (it != output_device_map_.end() ? it->second : nullptr);
572 } 574 }
573 575
574 scoped_refptr<MidiOutputDeviceState> GetOutputDeviceFromPort( 576 scoped_refptr<MidiOutputDeviceState> GetOutputDeviceFromPort(
575 uint32 port_number) { 577 uint32_t port_number) {
576 base::AutoLock auto_lock(output_ports_lock_); 578 base::AutoLock auto_lock(output_ports_lock_);
577 if (output_ports_.size() <= port_number) 579 if (output_ports_.size() <= port_number)
578 return nullptr; 580 return nullptr;
579 return output_ports_[port_number]; 581 return output_ports_[port_number];
580 } 582 }
581 583
582 void UpdateDeviceList() { 584 void UpdateDeviceList() {
583 task_thread_.message_loop()->PostTask( 585 task_thread_.message_loop()->PostTask(
584 FROM_HERE, base::Bind(&MidiServiceWinImpl::UpdateDeviceListOnTaskThread, 586 FROM_HERE, base::Bind(&MidiServiceWinImpl::UpdateDeviceListOnTaskThread,
585 base::Unretained(this))); 587 base::Unretained(this)));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 if (result != MMSYSERR_NOERROR) { 630 if (result != MMSYSERR_NOERROR) {
629 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetInErrorMessage(result); 631 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetInErrorMessage(result);
630 return; 632 return;
631 } 633 }
632 auto state = 634 auto state =
633 make_scoped_refptr(new MidiInputDeviceState(MidiDeviceInfo(caps))); 635 make_scoped_refptr(new MidiInputDeviceState(MidiDeviceInfo(caps)));
634 state->midi_handle = midi_in_handle; 636 state->midi_handle = midi_in_handle;
635 state->midi_header = CreateMIDIHDR(kBufferLength); 637 state->midi_header = CreateMIDIHDR(kBufferLength);
636 const auto& state_device_info = state->device_info; 638 const auto& state_device_info = state->device_info;
637 bool add_new_port = false; 639 bool add_new_port = false;
638 uint32 port_number = 0; 640 uint32_t port_number = 0;
639 { 641 {
640 base::AutoLock auto_lock(input_ports_lock_); 642 base::AutoLock auto_lock(input_ports_lock_);
641 const auto it = unused_input_ports_.find(state_device_info); 643 const auto it = unused_input_ports_.find(state_device_info);
642 if (it == unused_input_ports_.end()) { 644 if (it == unused_input_ports_.end()) {
643 port_number = static_cast<uint32>(input_ports_.size()); 645 port_number = static_cast<uint32_t>(input_ports_.size());
644 add_new_port = true; 646 add_new_port = true;
645 input_ports_.push_back(nullptr); 647 input_ports_.push_back(nullptr);
646 input_ports_ages_.push_back(0); 648 input_ports_ages_.push_back(0);
647 } else { 649 } else {
648 port_number = it->second.top(); 650 port_number = it->second.top();
649 it->second.pop(); 651 it->second.pop();
650 if (it->second.empty()) { 652 if (it->second.empty()) {
651 unused_input_ports_.erase(it); 653 unused_input_ports_.erase(it);
652 } 654 }
653 } 655 }
(...skipping 28 matching lines...) Expand all
682 MidiPortState::MIDI_PORT_CONNECTED)); 684 MidiPortState::MIDI_PORT_CONNECTED));
683 } 685 }
684 } 686 }
685 687
686 void OnMidiInDataOnMultimediaThread(HMIDIIN midi_in_handle, 688 void OnMidiInDataOnMultimediaThread(HMIDIIN midi_in_handle,
687 DWORD_PTR param1, 689 DWORD_PTR param1,
688 DWORD_PTR param2) { 690 DWORD_PTR param2) {
689 auto state = GetInputDeviceFromHandle(midi_in_handle); 691 auto state = GetInputDeviceFromHandle(midi_in_handle);
690 if (!state) 692 if (!state)
691 return; 693 return;
692 const uint8 status_byte = static_cast<uint8>(param1 & 0xff); 694 const uint8_t status_byte = static_cast<uint8_t>(param1 & 0xff);
693 const uint8 first_data_byte = static_cast<uint8>((param1 >> 8) & 0xff); 695 const uint8_t first_data_byte = static_cast<uint8_t>((param1 >> 8) & 0xff);
694 const uint8 second_data_byte = static_cast<uint8>((param1 >> 16) & 0xff); 696 const uint8_t second_data_byte =
697 static_cast<uint8_t>((param1 >> 16) & 0xff);
695 const DWORD elapsed_ms = param2; 698 const DWORD elapsed_ms = param2;
696 const size_t len = GetMidiMessageLength(status_byte); 699 const size_t len = GetMidiMessageLength(status_byte);
697 const uint8 kData[] = {status_byte, first_data_byte, second_data_byte}; 700 const uint8_t kData[] = {status_byte, first_data_byte, second_data_byte};
698 std::vector<uint8> data; 701 std::vector<uint8_t> data;
699 data.assign(kData, kData + len); 702 data.assign(kData, kData + len);
700 DCHECK_LE(len, arraysize(kData)); 703 DCHECK_LE(len, arraysize(kData));
701 // MIM_DATA/MIM_LONGDATA message treats the time when midiInStart() is 704 // MIM_DATA/MIM_LONGDATA message treats the time when midiInStart() is
702 // called as the origin of |elapsed_ms|. 705 // called as the origin of |elapsed_ms|.
703 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757284.aspx 706 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757284.aspx
704 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx 707 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx
705 const base::TimeTicks event_time = 708 const base::TimeTicks event_time =
706 state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms); 709 state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms);
707 task_thread_.message_loop()->PostTask( 710 task_thread_.message_loop()->PostTask(
708 FROM_HERE, base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread, 711 FROM_HERE, base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread,
(...skipping 16 matching lines...) Expand all
725 result = 728 result =
726 midiInUnprepareHeader(state->midi_handle, state->midi_header.get(), 729 midiInUnprepareHeader(state->midi_handle, state->midi_header.get(),
727 sizeof(*state->midi_header)); 730 sizeof(*state->midi_header));
728 DLOG_IF(ERROR, result != MMSYSERR_NOERROR) 731 DLOG_IF(ERROR, result != MMSYSERR_NOERROR)
729 << "Failed to uninitialize input buffer: " 732 << "Failed to uninitialize input buffer: "
730 << GetInErrorMessage(result); 733 << GetInErrorMessage(result);
731 } 734 }
732 return; 735 return;
733 } 736 }
734 if (header->dwBytesRecorded > 0) { 737 if (header->dwBytesRecorded > 0) {
735 const uint8* src = reinterpret_cast<const uint8*>(header->lpData); 738 const uint8_t* src = reinterpret_cast<const uint8_t*>(header->lpData);
736 std::vector<uint8> data; 739 std::vector<uint8_t> data;
737 data.assign(src, src + header->dwBytesRecorded); 740 data.assign(src, src + header->dwBytesRecorded);
738 // MIM_DATA/MIM_LONGDATA message treats the time when midiInStart() is 741 // MIM_DATA/MIM_LONGDATA message treats the time when midiInStart() is
739 // called as the origin of |elapsed_ms|. 742 // called as the origin of |elapsed_ms|.
740 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757284.aspx 743 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757284.aspx
741 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx 744 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx
742 const base::TimeTicks event_time = 745 const base::TimeTicks event_time =
743 state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms); 746 state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms);
744 task_thread_.message_loop()->PostTask( 747 task_thread_.message_loop()->PostTask(
745 FROM_HERE, 748 FROM_HERE,
746 base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread, 749 base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread,
747 base::Unretained(this), state->port_index, data, 750 base::Unretained(this), state->port_index, data,
748 event_time)); 751 event_time));
749 } 752 }
750 result = midiInAddBuffer(state->midi_handle, header, sizeof(*header)); 753 result = midiInAddBuffer(state->midi_handle, header, sizeof(*header));
751 DLOG_IF(ERROR, result != MMSYSERR_NOERROR) 754 DLOG_IF(ERROR, result != MMSYSERR_NOERROR)
752 << "Failed to attach input buffer: " << GetInErrorMessage(result) 755 << "Failed to attach input buffer: " << GetInErrorMessage(result)
753 << "port number:" << state->port_index; 756 << "port number:" << state->port_index;
754 } 757 }
755 758
756 void OnMidiInCloseOnMultimediaThread(HMIDIIN midi_in_handle) { 759 void OnMidiInCloseOnMultimediaThread(HMIDIIN midi_in_handle) {
757 auto state = GetInputDeviceFromHandle(midi_in_handle); 760 auto state = GetInputDeviceFromHandle(midi_in_handle);
758 if (!state) 761 if (!state)
759 return; 762 return;
760 const uint32 port_number = state->port_index; 763 const uint32_t port_number = state->port_index;
761 const auto device_info(state->device_info); 764 const auto device_info(state->device_info);
762 { 765 {
763 base::AutoLock auto_lock(input_ports_lock_); 766 base::AutoLock auto_lock(input_ports_lock_);
764 input_device_map_.erase(state->midi_handle); 767 input_device_map_.erase(state->midi_handle);
765 input_ports_[port_number] = nullptr; 768 input_ports_[port_number] = nullptr;
766 input_ports_ages_[port_number] += 1; 769 input_ports_ages_[port_number] += 1;
767 unused_input_ports_[device_info].push(port_number); 770 unused_input_ports_[device_info].push(port_number);
768 } 771 }
769 task_thread_.message_loop()->PostTask( 772 task_thread_.message_loop()->PostTask(
770 FROM_HERE, 773 FROM_HERE,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result); 814 DLOG(ERROR) << "midiInGetDevCaps failed: " << GetOutErrorMessage(result);
812 return; 815 return;
813 } 816 }
814 auto state = 817 auto state =
815 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps))); 818 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps)));
816 state->midi_handle = midi_out_handle; 819 state->midi_handle = midi_out_handle;
817 const auto& state_device_info = state->device_info; 820 const auto& state_device_info = state->device_info;
818 if (IsUnsupportedDevice(state_device_info)) 821 if (IsUnsupportedDevice(state_device_info))
819 return; 822 return;
820 bool add_new_port = false; 823 bool add_new_port = false;
821 uint32 port_number = 0; 824 uint32_t port_number = 0;
822 { 825 {
823 base::AutoLock auto_lock(output_ports_lock_); 826 base::AutoLock auto_lock(output_ports_lock_);
824 const auto it = unused_output_ports_.find(state_device_info); 827 const auto it = unused_output_ports_.find(state_device_info);
825 if (it == unused_output_ports_.end()) { 828 if (it == unused_output_ports_.end()) {
826 port_number = static_cast<uint32>(output_ports_.size()); 829 port_number = static_cast<uint32_t>(output_ports_.size());
827 add_new_port = true; 830 add_new_port = true;
828 output_ports_.push_back(nullptr); 831 output_ports_.push_back(nullptr);
829 output_ports_ages_.push_back(0); 832 output_ports_ages_.push_back(0);
830 } else { 833 } else {
831 port_number = it->second.top(); 834 port_number = it->second.top();
832 it->second.pop(); 835 it->second.pop();
833 if (it->second.empty()) 836 if (it->second.empty())
834 unused_output_ports_.erase(it); 837 unused_output_ports_.erase(it);
835 } 838 }
836 output_ports_[port_number] = state; 839 output_ports_[port_number] = state;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 sizeof(*header)); 875 sizeof(*header));
873 DLOG_IF(ERROR, result != MMSYSERR_NOERROR) 876 DLOG_IF(ERROR, result != MMSYSERR_NOERROR)
874 << "Failed to uninitialize output buffer: " 877 << "Failed to uninitialize output buffer: "
875 << GetOutErrorMessage(result); 878 << GetOutErrorMessage(result);
876 } 879 }
877 880
878 void OnMidiOutCloseOnMultimediaThread(HMIDIOUT midi_out_handle) { 881 void OnMidiOutCloseOnMultimediaThread(HMIDIOUT midi_out_handle) {
879 auto state = GetOutputDeviceFromHandle(midi_out_handle); 882 auto state = GetOutputDeviceFromHandle(midi_out_handle);
880 if (!state) 883 if (!state)
881 return; 884 return;
882 const uint32 port_number = state->port_index; 885 const uint32_t port_number = state->port_index;
883 const auto device_info(state->device_info); 886 const auto device_info(state->device_info);
884 { 887 {
885 base::AutoLock auto_lock(output_ports_lock_); 888 base::AutoLock auto_lock(output_ports_lock_);
886 output_device_map_.erase(state->midi_handle); 889 output_device_map_.erase(state->midi_handle);
887 output_ports_[port_number] = nullptr; 890 output_ports_[port_number] = nullptr;
888 output_ports_ages_[port_number] += 1; 891 output_ports_ages_[port_number] += 1;
889 unused_output_ports_[device_info].push(port_number); 892 unused_output_ports_[device_info].push(port_number);
890 state->closed = true; 893 state->closed = true;
891 } 894 }
892 task_thread_.message_loop()->PostTask( 895 task_thread_.message_loop()->PostTask(
893 FROM_HERE, 896 FROM_HERE,
894 base::Bind(&MidiServiceWinImpl::SetOutputPortStateOnTaskThread, 897 base::Bind(&MidiServiceWinImpl::SetOutputPortStateOnTaskThread,
895 base::Unretained(this), port_number, 898 base::Unretained(this), port_number,
896 MIDI_PORT_DISCONNECTED)); 899 MIDI_PORT_DISCONNECTED));
897 } 900 }
898 901
899 ///////////////////////////////////////////////////////////////////////////// 902 /////////////////////////////////////////////////////////////////////////////
900 // Callbacks on the sender thread. 903 // Callbacks on the sender thread.
901 ///////////////////////////////////////////////////////////////////////////// 904 /////////////////////////////////////////////////////////////////////////////
902 905
903 void AssertOnSenderThread() { 906 void AssertOnSenderThread() {
904 DCHECK_EQ(sender_thread_.GetThreadId(), base::PlatformThread::CurrentId()); 907 DCHECK_EQ(sender_thread_.GetThreadId(), base::PlatformThread::CurrentId());
905 } 908 }
906 909
907 void SendOnSenderThread(uint32 port_number, 910 void SendOnSenderThread(uint32_t port_number,
908 uint64 port_age, 911 uint64_t port_age,
909 const std::vector<uint8>& data, 912 const std::vector<uint8_t>& data,
910 base::TimeTicks time) { 913 base::TimeTicks time) {
911 AssertOnSenderThread(); 914 AssertOnSenderThread();
912 if (destructor_started) { 915 if (destructor_started) {
913 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is " 916 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is "
914 "being destructed. port: " << port_number; 917 "being destructed. port: " << port_number;
915 } 918 }
916 auto state = GetOutputDeviceFromPort(port_number); 919 auto state = GetOutputDeviceFromPort(port_number);
917 if (!state) { 920 if (!state) {
918 LOG(ERROR) << "ThreadSafeSendData failed due to an invalid port number. " 921 LOG(ERROR) << "ThreadSafeSendData failed due to an invalid port number. "
919 << "port: " << port_number; 922 << "port: " << port_number;
920 return; 923 return;
921 } 924 }
922 if (state->closed) { 925 if (state->closed) {
923 LOG(ERROR) 926 LOG(ERROR)
924 << "ThreadSafeSendData failed because target port is already closed." 927 << "ThreadSafeSendData failed because target port is already closed."
925 << "port: " << port_number; 928 << "port: " << port_number;
926 return; 929 return;
927 } 930 }
928 if (state->port_age != port_age) { 931 if (state->port_age != port_age) {
929 LOG(ERROR) 932 LOG(ERROR)
930 << "ThreadSafeSendData failed because target port is being closed." 933 << "ThreadSafeSendData failed because target port is being closed."
931 << "port: " << port_number << "expected port age: " << port_age 934 << "port: " << port_number << "expected port age: " << port_age
932 << "actual port age: " << state->port_age; 935 << "actual port age: " << state->port_age;
933 } 936 }
934 937
935 // MIDI Running status must be filtered out. 938 // MIDI Running status must be filtered out.
936 MidiMessageQueue message_queue(false); 939 MidiMessageQueue message_queue(false);
937 message_queue.Add(data); 940 message_queue.Add(data);
938 std::vector<uint8> message; 941 std::vector<uint8_t> message;
939 while (true) { 942 while (true) {
940 if (destructor_started) 943 if (destructor_started)
941 break; 944 break;
942 if (state->closed) 945 if (state->closed)
943 break; 946 break;
944 message_queue.Get(&message); 947 message_queue.Get(&message);
945 if (message.empty()) 948 if (message.empty())
946 break; 949 break;
947 // SendShortMidiMessageInternal can send a MIDI message up to 3 bytes. 950 // SendShortMidiMessageInternal can send a MIDI message up to 3 bytes.
948 if (message.size() <= 3) 951 if (message.size() <= 3)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 } 1044 }
1042 state->start_time = base::TimeTicks::Now(); 1045 state->start_time = base::TimeTicks::Now();
1043 state->start_time_initialized = true; 1046 state->start_time_initialized = true;
1044 } 1047 }
1045 1048
1046 void CompleteInitializationOnTaskThread(Result result) { 1049 void CompleteInitializationOnTaskThread(Result result) {
1047 AssertOnTaskThread(); 1050 AssertOnTaskThread();
1048 delegate_->OnCompleteInitialization(result); 1051 delegate_->OnCompleteInitialization(result);
1049 } 1052 }
1050 1053
1051 void ReceiveMidiDataOnTaskThread(uint32 port_index, 1054 void ReceiveMidiDataOnTaskThread(uint32_t port_index,
1052 std::vector<uint8> data, 1055 std::vector<uint8_t> data,
1053 base::TimeTicks time) { 1056 base::TimeTicks time) {
1054 AssertOnTaskThread(); 1057 AssertOnTaskThread();
1055 delegate_->OnReceiveMidiData(port_index, data, time); 1058 delegate_->OnReceiveMidiData(port_index, data, time);
1056 } 1059 }
1057 1060
1058 void AddInputPortOnTaskThread(MidiPortInfo info) { 1061 void AddInputPortOnTaskThread(MidiPortInfo info) {
1059 AssertOnTaskThread(); 1062 AssertOnTaskThread();
1060 delegate_->OnAddInputPort(info); 1063 delegate_->OnAddInputPort(info);
1061 } 1064 }
1062 1065
1063 void AddOutputPortOnTaskThread(MidiPortInfo info) { 1066 void AddOutputPortOnTaskThread(MidiPortInfo info) {
1064 AssertOnTaskThread(); 1067 AssertOnTaskThread();
1065 delegate_->OnAddOutputPort(info); 1068 delegate_->OnAddOutputPort(info);
1066 } 1069 }
1067 1070
1068 void SetInputPortStateOnTaskThread(uint32 port_index, MidiPortState state) { 1071 void SetInputPortStateOnTaskThread(uint32_t port_index, MidiPortState state) {
1069 AssertOnTaskThread(); 1072 AssertOnTaskThread();
1070 delegate_->OnSetInputPortState(port_index, state); 1073 delegate_->OnSetInputPortState(port_index, state);
1071 } 1074 }
1072 1075
1073 void SetOutputPortStateOnTaskThread(uint32 port_index, MidiPortState state) { 1076 void SetOutputPortStateOnTaskThread(uint32_t port_index,
1077 MidiPortState state) {
1074 AssertOnTaskThread(); 1078 AssertOnTaskThread();
1075 delegate_->OnSetOutputPortState(port_index, state); 1079 delegate_->OnSetOutputPortState(port_index, state);
1076 } 1080 }
1077 1081
1078 ///////////////////////////////////////////////////////////////////////////// 1082 /////////////////////////////////////////////////////////////////////////////
1079 // Fields: 1083 // Fields:
1080 ///////////////////////////////////////////////////////////////////////////// 1084 /////////////////////////////////////////////////////////////////////////////
1081 1085
1082 // Does not take ownership. 1086 // Does not take ownership.
1083 MidiServiceWinDelegate* delegate_; 1087 MidiServiceWinDelegate* delegate_;
1084 1088
1085 base::ThreadChecker thread_checker_; 1089 base::ThreadChecker thread_checker_;
1086 1090
1087 base::Thread sender_thread_; 1091 base::Thread sender_thread_;
1088 base::Thread task_thread_; 1092 base::Thread task_thread_;
1089 1093
1090 base::Lock input_ports_lock_; 1094 base::Lock input_ports_lock_;
1091 base::hash_map<HMIDIIN, scoped_refptr<MidiInputDeviceState>> 1095 base::hash_map<HMIDIIN, scoped_refptr<MidiInputDeviceState>>
1092 input_device_map_; // GUARDED_BY(input_ports_lock_) 1096 input_device_map_; // GUARDED_BY(input_ports_lock_)
1093 PortNumberCache unused_input_ports_; // GUARDED_BY(input_ports_lock_) 1097 PortNumberCache unused_input_ports_; // GUARDED_BY(input_ports_lock_)
1094 std::vector<scoped_refptr<MidiInputDeviceState>> 1098 std::vector<scoped_refptr<MidiInputDeviceState>>
1095 input_ports_; // GUARDED_BY(input_ports_lock_) 1099 input_ports_; // GUARDED_BY(input_ports_lock_)
1096 std::vector<uint64> input_ports_ages_; // GUARDED_BY(input_ports_lock_) 1100 std::vector<uint64_t> input_ports_ages_; // GUARDED_BY(input_ports_lock_)
1097 1101
1098 base::Lock output_ports_lock_; 1102 base::Lock output_ports_lock_;
1099 base::hash_map<HMIDIOUT, scoped_refptr<MidiOutputDeviceState>> 1103 base::hash_map<HMIDIOUT, scoped_refptr<MidiOutputDeviceState>>
1100 output_device_map_; // GUARDED_BY(output_ports_lock_) 1104 output_device_map_; // GUARDED_BY(output_ports_lock_)
1101 PortNumberCache unused_output_ports_; // GUARDED_BY(output_ports_lock_) 1105 PortNumberCache unused_output_ports_; // GUARDED_BY(output_ports_lock_)
1102 std::vector<scoped_refptr<MidiOutputDeviceState>> 1106 std::vector<scoped_refptr<MidiOutputDeviceState>>
1103 output_ports_; // GUARDED_BY(output_ports_lock_) 1107 output_ports_; // GUARDED_BY(output_ports_lock_)
1104 std::vector<uint64> output_ports_ages_; // GUARDED_BY(output_ports_lock_) 1108 std::vector<uint64_t> output_ports_ages_; // GUARDED_BY(output_ports_lock_)
1105 1109
1106 // True if one thread reached MidiServiceWinImpl::~MidiServiceWinImpl(). Note 1110 // True if one thread reached MidiServiceWinImpl::~MidiServiceWinImpl(). Note
1107 // that MidiServiceWinImpl::~MidiServiceWinImpl() is blocked until 1111 // that MidiServiceWinImpl::~MidiServiceWinImpl() is blocked until
1108 // |sender_thread_|, and |task_thread_| are stopped. 1112 // |sender_thread_|, and |task_thread_| are stopped.
1109 // This flag can be used as the signal that when background tasks must be 1113 // This flag can be used as the signal that when background tasks must be
1110 // interrupted. 1114 // interrupted.
1111 // TODO(toyoshim): Use std::atomic<bool> when it is allowed. 1115 // TODO(toyoshim): Use std::atomic<bool> when it is allowed.
1112 volatile bool destructor_started; 1116 volatile bool destructor_started;
1113 1117
1114 DISALLOW_COPY_AND_ASSIGN(MidiServiceWinImpl); 1118 DISALLOW_COPY_AND_ASSIGN(MidiServiceWinImpl);
(...skipping 11 matching lines...) Expand all
1126 midi_service_.reset(new MidiServiceWinImpl); 1130 midi_service_.reset(new MidiServiceWinImpl);
1127 // Note that |CompleteInitialization()| will be called from the callback. 1131 // Note that |CompleteInitialization()| will be called from the callback.
1128 midi_service_->InitializeAsync(this); 1132 midi_service_->InitializeAsync(this);
1129 } 1133 }
1130 1134
1131 void MidiManagerWin::Finalize() { 1135 void MidiManagerWin::Finalize() {
1132 midi_service_.reset(); 1136 midi_service_.reset();
1133 } 1137 }
1134 1138
1135 void MidiManagerWin::DispatchSendMidiData(MidiManagerClient* client, 1139 void MidiManagerWin::DispatchSendMidiData(MidiManagerClient* client,
1136 uint32 port_index, 1140 uint32_t port_index,
1137 const std::vector<uint8>& data, 1141 const std::vector<uint8_t>& data,
1138 double timestamp) { 1142 double timestamp) {
1139 if (!midi_service_) 1143 if (!midi_service_)
1140 return; 1144 return;
1141 1145
1142 base::TimeTicks time_to_send = base::TimeTicks::Now(); 1146 base::TimeTicks time_to_send = base::TimeTicks::Now();
1143 if (timestamp != 0.0) { 1147 if (timestamp != 0.0) {
1144 time_to_send = 1148 time_to_send =
1145 base::TimeTicks() + base::TimeDelta::FromMicroseconds( 1149 base::TimeTicks() + base::TimeDelta::FromMicroseconds(
1146 timestamp * base::Time::kMicrosecondsPerSecond); 1150 timestamp * base::Time::kMicrosecondsPerSecond);
1147 } 1151 }
1148 midi_service_->SendMidiDataAsync(port_index, data, time_to_send); 1152 midi_service_->SendMidiDataAsync(port_index, data, time_to_send);
1149 1153
1150 // TOOD(toyoshim): This calculation should be done when the date is actually 1154 // TOOD(toyoshim): This calculation should be done when the date is actually
1151 // sent. 1155 // sent.
1152 client->AccumulateMidiBytesSent(data.size()); 1156 client->AccumulateMidiBytesSent(data.size());
1153 } 1157 }
1154 1158
1155 void MidiManagerWin::OnCompleteInitialization(Result result) { 1159 void MidiManagerWin::OnCompleteInitialization(Result result) {
1156 CompleteInitialization(result); 1160 CompleteInitialization(result);
1157 } 1161 }
1158 1162
1159 void MidiManagerWin::OnAddInputPort(MidiPortInfo info) { 1163 void MidiManagerWin::OnAddInputPort(MidiPortInfo info) {
1160 AddInputPort(info); 1164 AddInputPort(info);
1161 } 1165 }
1162 1166
1163 void MidiManagerWin::OnAddOutputPort(MidiPortInfo info) { 1167 void MidiManagerWin::OnAddOutputPort(MidiPortInfo info) {
1164 AddOutputPort(info); 1168 AddOutputPort(info);
1165 } 1169 }
1166 1170
1167 void MidiManagerWin::OnSetInputPortState(uint32 port_index, 1171 void MidiManagerWin::OnSetInputPortState(uint32_t port_index,
1168 MidiPortState state) { 1172 MidiPortState state) {
1169 SetInputPortState(port_index, state); 1173 SetInputPortState(port_index, state);
1170 } 1174 }
1171 1175
1172 void MidiManagerWin::OnSetOutputPortState(uint32 port_index, 1176 void MidiManagerWin::OnSetOutputPortState(uint32_t port_index,
1173 MidiPortState state) { 1177 MidiPortState state) {
1174 SetOutputPortState(port_index, state); 1178 SetOutputPortState(port_index, state);
1175 } 1179 }
1176 1180
1177 void MidiManagerWin::OnReceiveMidiData(uint32 port_index, 1181 void MidiManagerWin::OnReceiveMidiData(uint32_t port_index,
1178 const std::vector<uint8>& data, 1182 const std::vector<uint8_t>& data,
1179 base::TimeTicks time) { 1183 base::TimeTicks time) {
1180 ReceiveMidiData(port_index, &data[0], data.size(), time); 1184 ReceiveMidiData(port_index, &data[0], data.size(), time);
1181 } 1185 }
1182 1186
1183 MidiManager* MidiManager::Create() { 1187 MidiManager* MidiManager::Create() {
1184 return new MidiManagerWin(); 1188 return new MidiManagerWin();
1185 } 1189 }
1186 1190
1187 } // namespace midi 1191 } // namespace midi
1188 } // namespace media 1192 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698