| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/media/midi_host.h" | 5 #include "content/browser/media/midi_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool IsSystemRealTimeMessage(uint8_t data) { | 39 bool IsSystemRealTimeMessage(uint8_t data) { |
| 40 return 0xf8 <= data && data <= 0xff; | 40 return 0xf8 <= data && data <= 0xff; |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 using midi::kSysExByte; | 45 using midi::kSysExByte; |
| 46 using midi::kEndOfSysExByte; | 46 using midi::kEndOfSysExByte; |
| 47 using midi::mojom::PortState; |
| 47 using midi::mojom::Result; | 48 using midi::mojom::Result; |
| 48 | 49 |
| 49 MidiHost::MidiHost(int renderer_process_id, | 50 MidiHost::MidiHost(int renderer_process_id, |
| 50 midi::MidiManager* midi_manager) | 51 midi::MidiManager* midi_manager) |
| 51 : BrowserMessageFilter(MidiMsgStart), | 52 : BrowserMessageFilter(MidiMsgStart), |
| 52 renderer_process_id_(renderer_process_id), | 53 renderer_process_id_(renderer_process_id), |
| 53 has_sys_ex_permission_(false), | 54 has_sys_ex_permission_(false), |
| 54 is_session_requested_(false), | 55 is_session_requested_(false), |
| 55 midi_manager_(midi_manager), | 56 midi_manager_(midi_manager), |
| 56 sent_bytes_in_flight_(0), | 57 sent_bytes_in_flight_(0), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 received_messages_queues_.push_back(nullptr); | 160 received_messages_queues_.push_back(nullptr); |
| 160 Send(new MidiMsg_AddInputPort(info)); | 161 Send(new MidiMsg_AddInputPort(info)); |
| 161 } | 162 } |
| 162 | 163 |
| 163 void MidiHost::AddOutputPort(const midi::MidiPortInfo& info) { | 164 void MidiHost::AddOutputPort(const midi::MidiPortInfo& info) { |
| 164 base::AutoLock auto_lock(output_port_count_lock_); | 165 base::AutoLock auto_lock(output_port_count_lock_); |
| 165 output_port_count_++; | 166 output_port_count_++; |
| 166 Send(new MidiMsg_AddOutputPort(info)); | 167 Send(new MidiMsg_AddOutputPort(info)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void MidiHost::SetInputPortState(uint32_t port, | 170 void MidiHost::SetInputPortState(uint32_t port, PortState state) { |
| 170 midi::MidiPortState state) { | |
| 171 Send(new MidiMsg_SetInputPortState(port, state)); | 171 Send(new MidiMsg_SetInputPortState(port, state)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void MidiHost::SetOutputPortState(uint32_t port, | 174 void MidiHost::SetOutputPortState(uint32_t port, PortState state) { |
| 175 midi::MidiPortState state) { | |
| 176 Send(new MidiMsg_SetOutputPortState(port, state)); | 175 Send(new MidiMsg_SetOutputPortState(port, state)); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void MidiHost::ReceiveMidiData(uint32_t port, | 178 void MidiHost::ReceiveMidiData(uint32_t port, |
| 180 const uint8_t* data, | 179 const uint8_t* data, |
| 181 size_t length, | 180 size_t length, |
| 182 double timestamp) { | 181 double timestamp) { |
| 183 TRACE_EVENT0("midi", "MidiHost::ReceiveMidiData"); | 182 TRACE_EVENT0("midi", "MidiHost::ReceiveMidiData"); |
| 184 | 183 |
| 185 base::AutoLock auto_lock(messages_queues_lock_); | 184 base::AutoLock auto_lock(messages_queues_lock_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 262 } |
| 264 waiting_data_length = midi::GetMidiMessageLength(current); | 263 waiting_data_length = midi::GetMidiMessageLength(current); |
| 265 if (waiting_data_length == 0) | 264 if (waiting_data_length == 0) |
| 266 return false; // Error: |current| should have been a valid status byte. | 265 return false; // Error: |current| should have been a valid status byte. |
| 267 --waiting_data_length; // Found status byte | 266 --waiting_data_length; // Found status byte |
| 268 } | 267 } |
| 269 return waiting_data_length == 0 && !in_sysex; | 268 return waiting_data_length == 0 && !in_sysex; |
| 270 } | 269 } |
| 271 | 270 |
| 272 } // namespace content | 271 } // namespace content |
| OLD | NEW |