OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_winrt.h" | 5 #include "media/midi/midi_manager_winrt.h" |
6 | 6 |
7 #pragma warning(disable : 4467) | 7 #pragma warning(disable : 4467) |
8 | 8 |
9 #include <initguid.h> // Required by <devpkey.h> | 9 #include <initguid.h> // Required by <devpkey.h> |
10 | 10 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 } | 800 } |
801 | 801 |
802 ScopedComPtr<IBuffer> buffer; | 802 ScopedComPtr<IBuffer> buffer; |
803 hr = message->get_RawData(buffer.Receive()); | 803 hr = message->get_RawData(buffer.Receive()); |
804 if (FAILED(hr)) { | 804 if (FAILED(hr)) { |
805 VLOG(1) << "get_RawData failed: " << PrintHr(hr); | 805 VLOG(1) << "get_RawData failed: " << PrintHr(hr); |
806 return hr; | 806 return hr; |
807 } | 807 } |
808 | 808 |
809 uint8_t* p_buffer_data = nullptr; | 809 uint8_t* p_buffer_data = nullptr; |
810 hr = GetPointerToBufferData(buffer.get(), &p_buffer_data); | 810 hr = GetPointerToBufferData(buffer.Get(), &p_buffer_data); |
811 if (FAILED(hr)) | 811 if (FAILED(hr)) |
812 return hr; | 812 return hr; |
813 | 813 |
814 uint32_t data_length = 0; | 814 uint32_t data_length = 0; |
815 hr = buffer->get_Length(&data_length); | 815 hr = buffer->get_Length(&data_length); |
816 if (FAILED(hr)) { | 816 if (FAILED(hr)) { |
817 VLOG(1) << "get_Length failed: " << PrintHr(hr); | 817 VLOG(1) << "get_Length failed: " << PrintHr(hr); |
818 return hr; | 818 return hr; |
819 } | 819 } |
820 | 820 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 return; | 1019 return; |
1020 } | 1020 } |
1021 | 1021 |
1022 hr = buffer->put_Length(static_cast<UINT32>(data.size())); | 1022 hr = buffer->put_Length(static_cast<UINT32>(data.size())); |
1023 if (FAILED(hr)) { | 1023 if (FAILED(hr)) { |
1024 VLOG(1) << "put_Length failed: " << PrintHr(hr); | 1024 VLOG(1) << "put_Length failed: " << PrintHr(hr); |
1025 return; | 1025 return; |
1026 } | 1026 } |
1027 | 1027 |
1028 uint8_t* p_buffer_data = nullptr; | 1028 uint8_t* p_buffer_data = nullptr; |
1029 hr = GetPointerToBufferData(buffer.get(), &p_buffer_data); | 1029 hr = GetPointerToBufferData(buffer.Get(), &p_buffer_data); |
1030 if (FAILED(hr)) | 1030 if (FAILED(hr)) |
1031 return; | 1031 return; |
1032 | 1032 |
1033 std::copy(data.begin(), data.end(), p_buffer_data); | 1033 std::copy(data.begin(), data.end(), p_buffer_data); |
1034 | 1034 |
1035 hr = port->handle->SendBuffer(buffer.get()); | 1035 hr = port->handle->SendBuffer(buffer.Get()); |
1036 if (FAILED(hr)) { | 1036 if (FAILED(hr)) { |
1037 VLOG(1) << "SendBuffer failed: " << PrintHr(hr); | 1037 VLOG(1) << "SendBuffer failed: " << PrintHr(hr); |
1038 return; | 1038 return; |
1039 } | 1039 } |
1040 } | 1040 } |
1041 | 1041 |
1042 void MidiManagerWinrt::OnPortManagerReady() { | 1042 void MidiManagerWinrt::OnPortManagerReady() { |
1043 DCHECK(com_thread_checker_->CalledOnValidThread()); | 1043 DCHECK(com_thread_checker_->CalledOnValidThread()); |
1044 DCHECK(port_manager_ready_count_ < 2); | 1044 DCHECK(port_manager_ready_count_ < 2); |
1045 | 1045 |
1046 if (++port_manager_ready_count_ == 2) | 1046 if (++port_manager_ready_count_ == 2) |
1047 CompleteInitialization(Result::OK); | 1047 CompleteInitialization(Result::OK); |
1048 } | 1048 } |
1049 | 1049 |
1050 } // namespace midi | 1050 } // namespace midi |
OLD | NEW |