| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_alsa.h" | 5 #include "media/midi/midi_manager_alsa.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <poll.h> | 8 #include <poll.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 value->SetInteger("portId", port_id_); | 380 value->SetInteger("portId", port_id_); |
| 381 value->SetInteger("midiDevice", midi_device_); | 381 value->SetInteger("midiDevice", midi_device_); |
| 382 | 382 |
| 383 // Flatten id fields. | 383 // Flatten id fields. |
| 384 SetStringIfNonEmpty(value.get(), "bus", id_.bus()); | 384 SetStringIfNonEmpty(value.get(), "bus", id_.bus()); |
| 385 SetStringIfNonEmpty(value.get(), "vendorId", id_.vendor_id()); | 385 SetStringIfNonEmpty(value.get(), "vendorId", id_.vendor_id()); |
| 386 SetStringIfNonEmpty(value.get(), "modelId", id_.model_id()); | 386 SetStringIfNonEmpty(value.get(), "modelId", id_.model_id()); |
| 387 SetStringIfNonEmpty(value.get(), "usbInterfaceNum", id_.usb_interface_num()); | 387 SetStringIfNonEmpty(value.get(), "usbInterfaceNum", id_.usb_interface_num()); |
| 388 SetStringIfNonEmpty(value.get(), "serial", id_.serial()); | 388 SetStringIfNonEmpty(value.get(), "serial", id_.serial()); |
| 389 | 389 |
| 390 return value.Pass(); | 390 return std::move(value); |
| 391 } | 391 } |
| 392 | 392 |
| 393 std::string MidiManagerAlsa::MidiPort::JSONValue() const { | 393 std::string MidiManagerAlsa::MidiPort::JSONValue() const { |
| 394 std::string json; | 394 std::string json; |
| 395 JSONStringValueSerializer serializer(&json); | 395 JSONStringValueSerializer serializer(&json); |
| 396 serializer.Serialize(*Value().get()); | 396 serializer.Serialize(*Value().get()); |
| 397 return json; | 397 return json; |
| 398 } | 398 } |
| 399 | 399 |
| 400 // TODO(agoode): Do not use SHA256 here. Instead store a persistent | 400 // TODO(agoode): Do not use SHA256 here. Instead store a persistent |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 uint32_t web_port_index = 0; | 571 uint32_t web_port_index = 0; |
| 572 switch (port->type()) { | 572 switch (port->type()) { |
| 573 case MidiPort::Type::kInput: | 573 case MidiPort::Type::kInput: |
| 574 web_port_index = num_input_ports_++; | 574 web_port_index = num_input_ports_++; |
| 575 break; | 575 break; |
| 576 case MidiPort::Type::kOutput: | 576 case MidiPort::Type::kOutput: |
| 577 web_port_index = num_output_ports_++; | 577 web_port_index = num_output_ports_++; |
| 578 break; | 578 break; |
| 579 } | 579 } |
| 580 port->set_web_port_index(web_port_index); | 580 port->set_web_port_index(web_port_index); |
| 581 MidiPortStateBase::push_back(port.Pass()); | 581 MidiPortStateBase::push_back(std::move(port)); |
| 582 return web_port_index; | 582 return web_port_index; |
| 583 } | 583 } |
| 584 | 584 |
| 585 MidiManagerAlsa::AlsaSeqState::AlsaSeqState() = default; | 585 MidiManagerAlsa::AlsaSeqState::AlsaSeqState() = default; |
| 586 | 586 |
| 587 MidiManagerAlsa::AlsaSeqState::~AlsaSeqState() = default; | 587 MidiManagerAlsa::AlsaSeqState::~AlsaSeqState() = default; |
| 588 | 588 |
| 589 void MidiManagerAlsa::AlsaSeqState::ClientStart(int client_id, | 589 void MidiManagerAlsa::AlsaSeqState::ClientStart(int client_id, |
| 590 const std::string& client_name, | 590 const std::string& client_name, |
| 591 snd_seq_client_type_t type) { | 591 snd_seq_client_type_t type) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 if (direction == PortDirection::kOutput || | 698 if (direction == PortDirection::kOutput || |
| 699 direction == PortDirection::kDuplex) { | 699 direction == PortDirection::kDuplex) { |
| 700 midi_ports->push_back(make_scoped_ptr(new MidiPort( | 700 midi_ports->push_back(make_scoped_ptr(new MidiPort( |
| 701 path, id, client_id, port_id, midi_device, client->name(), | 701 path, id, client_id, port_id, midi_device, client->name(), |
| 702 port->name(), manufacturer, version, MidiPort::Type::kOutput))); | 702 port->name(), manufacturer, version, MidiPort::Type::kOutput))); |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 | 707 |
| 708 return midi_ports.Pass(); | 708 return midi_ports; |
| 709 } | 709 } |
| 710 | 710 |
| 711 MidiManagerAlsa::AlsaSeqState::Port::Port( | 711 MidiManagerAlsa::AlsaSeqState::Port::Port( |
| 712 const std::string& name, | 712 const std::string& name, |
| 713 MidiManagerAlsa::AlsaSeqState::PortDirection direction, | 713 MidiManagerAlsa::AlsaSeqState::PortDirection direction, |
| 714 bool midi) | 714 bool midi) |
| 715 : name_(name), direction_(direction), midi_(midi) { | 715 : name_(name), direction_(direction), midi_(midi) { |
| 716 } | 716 } |
| 717 | 717 |
| 718 MidiManagerAlsa::AlsaSeqState::Port::~Port() = default; | 718 MidiManagerAlsa::AlsaSeqState::Port::~Port() = default; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 if (old_port == port_state_.end()) { | 1169 if (old_port == port_state_.end()) { |
| 1170 // Add new port. | 1170 // Add new port. |
| 1171 const auto& opaque_key = new_port->OpaqueKey(); | 1171 const auto& opaque_key = new_port->OpaqueKey(); |
| 1172 const auto& manufacturer = new_port->manufacturer(); | 1172 const auto& manufacturer = new_port->manufacturer(); |
| 1173 const auto& port_name = new_port->port_name(); | 1173 const auto& port_name = new_port->port_name(); |
| 1174 const auto& version = new_port->version(); | 1174 const auto& version = new_port->version(); |
| 1175 const auto& type = new_port->type(); | 1175 const auto& type = new_port->type(); |
| 1176 const auto& client_id = new_port->client_id(); | 1176 const auto& client_id = new_port->client_id(); |
| 1177 const auto& port_id = new_port->port_id(); | 1177 const auto& port_id = new_port->port_id(); |
| 1178 | 1178 |
| 1179 uint32_t web_port_index = port_state_.push_back(new_port.Pass()); | 1179 uint32_t web_port_index = port_state_.push_back(std::move(new_port)); |
| 1180 it = new_port_state->erase(it); | 1180 it = new_port_state->erase(it); |
| 1181 | 1181 |
| 1182 MidiPortInfo info(opaque_key, manufacturer, port_name, version, | 1182 MidiPortInfo info(opaque_key, manufacturer, port_name, version, |
| 1183 MIDI_PORT_OPENED); | 1183 MIDI_PORT_OPENED); |
| 1184 switch (type) { | 1184 switch (type) { |
| 1185 case MidiPort::Type::kInput: | 1185 case MidiPort::Type::kInput: |
| 1186 if (Subscribe(web_port_index, client_id, port_id)) | 1186 if (Subscribe(web_port_index, client_id, port_id)) |
| 1187 AddInputPort(info); | 1187 AddInputPort(info); |
| 1188 break; | 1188 break; |
| 1189 case MidiPort::Type::kOutput: | 1189 case MidiPort::Type::kOutput: |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 source_map_[AddrToInt(client_id, port_id)] = port_index; | 1348 source_map_[AddrToInt(client_id, port_id)] = port_index; |
| 1349 return true; | 1349 return true; |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 MidiManager* MidiManager::Create() { | 1352 MidiManager* MidiManager::Create() { |
| 1353 return new MidiManagerAlsa(); | 1353 return new MidiManagerAlsa(); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 } // namespace midi | 1356 } // namespace midi |
| 1357 } // namespace media | 1357 } // namespace media |
| OLD | NEW |