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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // Start monitoring device changes. This should start before the | 482 // Start monitoring device changes. This should start before the |
483 // following UpdateDeviceList() call not to miss the event happening | 483 // following UpdateDeviceList() call not to miss the event happening |
484 // between the call and the observer registration. | 484 // between the call and the observer registration. |
485 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); | 485 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); |
486 | 486 |
487 UpdateDeviceList(); | 487 UpdateDeviceList(); |
488 | 488 |
489 task_thread_.message_loop()->PostTask( | 489 task_thread_.message_loop()->PostTask( |
490 FROM_HERE, | 490 FROM_HERE, |
491 base::Bind(&MidiServiceWinImpl::CompleteInitializationOnTaskThread, | 491 base::Bind(&MidiServiceWinImpl::CompleteInitializationOnTaskThread, |
492 base::Unretained(this), MIDI_OK)); | 492 base::Unretained(this), Result::OK)); |
493 } | 493 } |
494 | 494 |
495 void SendMidiDataAsync(uint32 port_number, | 495 void SendMidiDataAsync(uint32 port_number, |
496 const std::vector<uint8>& data, | 496 const std::vector<uint8>& data, |
497 base::TimeTicks time) final { | 497 base::TimeTicks time) final { |
498 if (destructor_started) { | 498 if (destructor_started) { |
499 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is " | 499 LOG(ERROR) << "ThreadSafeSendData failed because MidiServiceWinImpl is " |
500 "being destructed. port: " << port_number; | 500 "being destructed. port: " << port_number; |
501 return; | 501 return; |
502 } | 502 } |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 result = midiInStart(state->midi_handle); | 1026 result = midiInStart(state->midi_handle); |
1027 if (result != MMSYSERR_NOERROR) { | 1027 if (result != MMSYSERR_NOERROR) { |
1028 DLOG(ERROR) << "Failed to start input port: " | 1028 DLOG(ERROR) << "Failed to start input port: " |
1029 << GetInErrorMessage(result); | 1029 << GetInErrorMessage(result); |
1030 return; | 1030 return; |
1031 } | 1031 } |
1032 state->start_time = base::TimeTicks::Now(); | 1032 state->start_time = base::TimeTicks::Now(); |
1033 state->start_time_initialized = true; | 1033 state->start_time_initialized = true; |
1034 } | 1034 } |
1035 | 1035 |
1036 void CompleteInitializationOnTaskThread(MidiResult result) { | 1036 void CompleteInitializationOnTaskThread(Result result) { |
1037 AssertOnTaskThread(); | 1037 AssertOnTaskThread(); |
1038 delegate_->OnCompleteInitialization(result); | 1038 delegate_->OnCompleteInitialization(result); |
1039 } | 1039 } |
1040 | 1040 |
1041 void ReceiveMidiDataOnTaskThread(uint32 port_index, | 1041 void ReceiveMidiDataOnTaskThread(uint32 port_index, |
1042 std::vector<uint8> data, | 1042 std::vector<uint8> data, |
1043 base::TimeTicks time) { | 1043 base::TimeTicks time) { |
1044 AssertOnTaskThread(); | 1044 AssertOnTaskThread(); |
1045 delegate_->OnReceiveMidiData(port_index, data, time); | 1045 delegate_->OnReceiveMidiData(port_index, data, time); |
1046 } | 1046 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 base::TimeTicks() + base::TimeDelta::FromMicroseconds( | 1132 base::TimeTicks() + base::TimeDelta::FromMicroseconds( |
1133 timestamp * base::Time::kMicrosecondsPerSecond); | 1133 timestamp * base::Time::kMicrosecondsPerSecond); |
1134 } | 1134 } |
1135 midi_service_->SendMidiDataAsync(port_index, data, time_to_send); | 1135 midi_service_->SendMidiDataAsync(port_index, data, time_to_send); |
1136 | 1136 |
1137 // TOOD(toyoshim): This calculation should be done when the date is actually | 1137 // TOOD(toyoshim): This calculation should be done when the date is actually |
1138 // sent. | 1138 // sent. |
1139 client->AccumulateMidiBytesSent(data.size()); | 1139 client->AccumulateMidiBytesSent(data.size()); |
1140 } | 1140 } |
1141 | 1141 |
1142 void MidiManagerWin::OnCompleteInitialization(MidiResult result) { | 1142 void MidiManagerWin::OnCompleteInitialization(Result result) { |
1143 CompleteInitialization(result); | 1143 CompleteInitialization(result); |
1144 } | 1144 } |
1145 | 1145 |
1146 void MidiManagerWin::OnAddInputPort(MidiPortInfo info) { | 1146 void MidiManagerWin::OnAddInputPort(MidiPortInfo info) { |
1147 AddInputPort(info); | 1147 AddInputPort(info); |
1148 } | 1148 } |
1149 | 1149 |
1150 void MidiManagerWin::OnAddOutputPort(MidiPortInfo info) { | 1150 void MidiManagerWin::OnAddOutputPort(MidiPortInfo info) { |
1151 AddOutputPort(info); | 1151 AddOutputPort(info); |
1152 } | 1152 } |
(...skipping 13 matching lines...) Expand all Loading... |
1166 base::TimeTicks time) { | 1166 base::TimeTicks time) { |
1167 ReceiveMidiData(port_index, &data[0], data.size(), time); | 1167 ReceiveMidiData(port_index, &data[0], data.size(), time); |
1168 } | 1168 } |
1169 | 1169 |
1170 MidiManager* MidiManager::Create() { | 1170 MidiManager* MidiManager::Create() { |
1171 return new MidiManagerWin(); | 1171 return new MidiManagerWin(); |
1172 } | 1172 } |
1173 | 1173 |
1174 } // namespace midi | 1174 } // namespace midi |
1175 } // namespace media | 1175 } // namespace media |
OLD | NEW |