OLD | NEW |
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 | 8 |
9 // Prevent unnecessary functions from being included from <mmsystem.h> | 9 // Prevent unnecessary functions from being included from <mmsystem.h> |
10 #define MMNODRV | 10 #define MMNODRV |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 << GetInErrorMessage(result); | 508 << GetInErrorMessage(result); |
509 continue; | 509 continue; |
510 } | 510 } |
511 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id)); | 511 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id)); |
512 if (!in_device) | 512 if (!in_device) |
513 continue; | 513 continue; |
514 MidiPortInfo info( | 514 MidiPortInfo info( |
515 base::IntToString(static_cast<int>(device_id)), | 515 base::IntToString(static_cast<int>(device_id)), |
516 "", | 516 "", |
517 base::WideToUTF8(caps.szPname), | 517 base::WideToUTF8(caps.szPname), |
518 base::IntToString(static_cast<int>(caps.vDriverVersion))); | 518 base::IntToString(static_cast<int>(caps.vDriverVersion)), |
| 519 MIDI_PORT_OPENED); |
519 AddInputPort(info); | 520 AddInputPort(info); |
520 in_device->set_port_index(inport_index++); | 521 in_device->set_port_index(inport_index++); |
521 in_devices_.push_back(in_device.release()); | 522 in_devices_.push_back(in_device.release()); |
522 } | 523 } |
523 | 524 |
524 const UINT num_out_devices = midiOutGetNumDevs(); | 525 const UINT num_out_devices = midiOutGetNumDevs(); |
525 out_devices_.reserve(num_out_devices); | 526 out_devices_.reserve(num_out_devices); |
526 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) { | 527 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) { |
527 MIDIOUTCAPS caps = {}; | 528 MIDIOUTCAPS caps = {}; |
528 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps)); | 529 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps)); |
529 if (result != MMSYSERR_NOERROR) { | 530 if (result != MMSYSERR_NOERROR) { |
530 DLOG(ERROR) << "Failed to obtain output device info: " | 531 DLOG(ERROR) << "Failed to obtain output device info: " |
531 << GetOutErrorMessage(result); | 532 << GetOutErrorMessage(result); |
532 continue; | 533 continue; |
533 } | 534 } |
534 scoped_ptr<OutDeviceInfo> out_port(OutDeviceInfo::Create(device_id)); | 535 scoped_ptr<OutDeviceInfo> out_port(OutDeviceInfo::Create(device_id)); |
535 if (!out_port) | 536 if (!out_port) |
536 continue; | 537 continue; |
537 MidiPortInfo info( | 538 MidiPortInfo info( |
538 base::IntToString(static_cast<int>(device_id)), | 539 base::IntToString(static_cast<int>(device_id)), |
539 "", | 540 "", |
540 base::WideToUTF8(caps.szPname), | 541 base::WideToUTF8(caps.szPname), |
541 base::IntToString(static_cast<int>(caps.vDriverVersion))); | 542 base::IntToString(static_cast<int>(caps.vDriverVersion)), |
| 543 MIDI_PORT_OPENED); |
542 AddOutputPort(info); | 544 AddOutputPort(info); |
543 out_devices_.push_back(out_port.release()); | 545 out_devices_.push_back(out_port.release()); |
544 } | 546 } |
545 | 547 |
546 CompleteInitialization(MIDI_OK); | 548 CompleteInitialization(MIDI_OK); |
547 } | 549 } |
548 | 550 |
549 MidiManagerWin::~MidiManagerWin() { | 551 MidiManagerWin::~MidiManagerWin() { |
550 // Cleanup order is important. |send_thread_| must be stopped before | 552 // Cleanup order is important. |send_thread_| must be stopped before |
551 // |out_devices_| is cleared. | 553 // |out_devices_| is cleared. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 FROM_HERE, | 591 FROM_HERE, |
590 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent, | 592 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent, |
591 base::Unretained(client), data.size())); | 593 base::Unretained(client), data.size())); |
592 } | 594 } |
593 | 595 |
594 MidiManager* MidiManager::Create() { | 596 MidiManager* MidiManager::Create() { |
595 return new MidiManagerWin(); | 597 return new MidiManagerWin(); |
596 } | 598 } |
597 | 599 |
598 } // namespace media | 600 } // namespace media |
OLD | NEW |