| 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 #include <ks.h> | 8 #include <ks.h> |
| 9 #include <ksmedia.h> | 9 #include <ksmedia.h> |
| 10 #include <mmreg.h> | 10 #include <mmreg.h> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 delete header; | 94 delete header; |
| 95 } | 95 } |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 typedef scoped_ptr<MIDIHDR, MIDIHDRDeleter> ScopedMIDIHDR; | 98 typedef scoped_ptr<MIDIHDR, MIDIHDRDeleter> ScopedMIDIHDR; |
| 99 | 99 |
| 100 ScopedMIDIHDR CreateMIDIHDR(size_t size) { | 100 ScopedMIDIHDR CreateMIDIHDR(size_t size) { |
| 101 ScopedMIDIHDR header(new MIDIHDR); | 101 ScopedMIDIHDR header(new MIDIHDR); |
| 102 ZeroMemory(header.get(), sizeof(*header)); | 102 ZeroMemory(header.get(), sizeof(*header)); |
| 103 header->lpData = new char[size]; | 103 header->lpData = new char[size]; |
| 104 header->dwBufferLength = size; | 104 header->dwBufferLength = static_cast<DWORD>(size); |
| 105 return header.Pass(); | 105 return header.Pass(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void SendShortMidiMessageInternal(HMIDIOUT midi_out_handle, | 108 void SendShortMidiMessageInternal(HMIDIOUT midi_out_handle, |
| 109 const std::vector<uint8>& message) { | 109 const std::vector<uint8>& message) { |
| 110 DCHECK_LE(message.size(), static_cast<size_t>(3)) | 110 DCHECK_LE(message.size(), static_cast<size_t>(3)) |
| 111 << "A short MIDI message should be up to 3 bytes."; | 111 << "A short MIDI message should be up to 3 bytes."; |
| 112 | 112 |
| 113 DWORD packed_message = 0; | 113 DWORD packed_message = 0; |
| 114 for (size_t i = 0; i < message.size(); ++i) | 114 for (size_t i = 0; i < message.size(); ++i) |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 make_scoped_refptr(new MidiInputDeviceState(MidiDeviceInfo(caps))); | 612 make_scoped_refptr(new MidiInputDeviceState(MidiDeviceInfo(caps))); |
| 613 state->midi_handle = midi_in_handle; | 613 state->midi_handle = midi_in_handle; |
| 614 state->midi_header = CreateMIDIHDR(kBufferLength); | 614 state->midi_header = CreateMIDIHDR(kBufferLength); |
| 615 const auto& state_device_info = state->device_info; | 615 const auto& state_device_info = state->device_info; |
| 616 bool add_new_port = false; | 616 bool add_new_port = false; |
| 617 uint32 port_number = 0; | 617 uint32 port_number = 0; |
| 618 { | 618 { |
| 619 base::AutoLock auto_lock(input_ports_lock_); | 619 base::AutoLock auto_lock(input_ports_lock_); |
| 620 const auto it = unused_input_ports_.find(state_device_info); | 620 const auto it = unused_input_ports_.find(state_device_info); |
| 621 if (it == unused_input_ports_.end()) { | 621 if (it == unused_input_ports_.end()) { |
| 622 port_number = input_ports_.size(); | 622 port_number = static_cast<uint32>(input_ports_.size()); |
| 623 add_new_port = true; | 623 add_new_port = true; |
| 624 input_ports_.push_back(nullptr); | 624 input_ports_.push_back(nullptr); |
| 625 input_ports_ages_.push_back(0); | 625 input_ports_ages_.push_back(0); |
| 626 } else { | 626 } else { |
| 627 port_number = it->second.top(); | 627 port_number = it->second.top(); |
| 628 it->second.pop(); | 628 it->second.pop(); |
| 629 if (it->second.empty()) { | 629 if (it->second.empty()) { |
| 630 unused_input_ports_.erase(it); | 630 unused_input_ports_.erase(it); |
| 631 } | 631 } |
| 632 } | 632 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 auto state = | 793 auto state = |
| 794 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps))); | 794 make_scoped_refptr(new MidiOutputDeviceState(MidiDeviceInfo(caps))); |
| 795 state->midi_handle = midi_out_handle; | 795 state->midi_handle = midi_out_handle; |
| 796 const auto& state_device_info = state->device_info; | 796 const auto& state_device_info = state->device_info; |
| 797 bool add_new_port = false; | 797 bool add_new_port = false; |
| 798 uint32 port_number = 0; | 798 uint32 port_number = 0; |
| 799 { | 799 { |
| 800 base::AutoLock auto_lock(output_ports_lock_); | 800 base::AutoLock auto_lock(output_ports_lock_); |
| 801 const auto it = unused_output_ports_.find(state_device_info); | 801 const auto it = unused_output_ports_.find(state_device_info); |
| 802 if (it == unused_output_ports_.end()) { | 802 if (it == unused_output_ports_.end()) { |
| 803 port_number = output_ports_.size(); | 803 port_number = static_cast<uint32>(output_ports_.size()); |
| 804 add_new_port = true; | 804 add_new_port = true; |
| 805 output_ports_.push_back(nullptr); | 805 output_ports_.push_back(nullptr); |
| 806 output_ports_ages_.push_back(0); | 806 output_ports_ages_.push_back(0); |
| 807 } else { | 807 } else { |
| 808 port_number = it->second.top(); | 808 port_number = it->second.top(); |
| 809 it->second.pop(); | 809 it->second.pop(); |
| 810 if (it->second.empty()) | 810 if (it->second.empty()) |
| 811 unused_output_ports_.erase(it); | 811 unused_output_ports_.erase(it); |
| 812 } | 812 } |
| 813 output_ports_[port_number] = state; | 813 output_ports_[port_number] = state; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 // TOOD(toyoshim): This calculation should be done when the date is actually | 1124 // TOOD(toyoshim): This calculation should be done when the date is actually |
| 1125 // sent. | 1125 // sent. |
| 1126 client->AccumulateMidiBytesSent(data.size()); | 1126 client->AccumulateMidiBytesSent(data.size()); |
| 1127 } | 1127 } |
| 1128 | 1128 |
| 1129 MidiManager* MidiManager::Create() { | 1129 MidiManager* MidiManager::Create() { |
| 1130 return new MidiManagerWin(); | 1130 return new MidiManagerWin(); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 } // namespace media | 1133 } // namespace media |
| OLD | NEW |