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