Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: media/midi/midi_manager_alsa.cc

Issue 2253943004: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/gpu/vt_video_decode_accelerator_mac.cc ('k') | media/midi/midi_manager_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 632
633 MidiManagerAlsa::AlsaSeqState::AlsaSeqState() = default; 633 MidiManagerAlsa::AlsaSeqState::AlsaSeqState() = default;
634 634
635 MidiManagerAlsa::AlsaSeqState::~AlsaSeqState() = default; 635 MidiManagerAlsa::AlsaSeqState::~AlsaSeqState() = default;
636 636
637 void MidiManagerAlsa::AlsaSeqState::ClientStart(int client_id, 637 void MidiManagerAlsa::AlsaSeqState::ClientStart(int client_id,
638 const std::string& client_name, 638 const std::string& client_name,
639 snd_seq_client_type_t type) { 639 snd_seq_client_type_t type) {
640 ClientExit(client_id); 640 ClientExit(client_id);
641 clients_.insert(std::make_pair( 641 clients_.insert(
642 client_id, base::WrapUnique(new Client(client_name, type)))); 642 std::make_pair(client_id, base::MakeUnique<Client>(client_name, type)));
643 if (IsCardClient(type, client_id)) 643 if (IsCardClient(type, client_id))
644 ++card_client_count_; 644 ++card_client_count_;
645 } 645 }
646 646
647 bool MidiManagerAlsa::AlsaSeqState::ClientStarted(int client_id) { 647 bool MidiManagerAlsa::AlsaSeqState::ClientStarted(int client_id) {
648 return clients_.find(client_id) != clients_.end(); 648 return clients_.find(client_id) != clients_.end();
649 } 649 }
650 650
651 void MidiManagerAlsa::AlsaSeqState::ClientExit(int client_id) { 651 void MidiManagerAlsa::AlsaSeqState::ClientExit(int client_id) {
652 auto it = clients_.find(client_id); 652 auto it = clients_.find(client_id);
653 if (it != clients_.end()) { 653 if (it != clients_.end()) {
654 if (IsCardClient(it->second->type(), client_id)) 654 if (IsCardClient(it->second->type(), client_id))
655 --card_client_count_; 655 --card_client_count_;
656 clients_.erase(it); 656 clients_.erase(it);
657 } 657 }
658 } 658 }
659 659
660 void MidiManagerAlsa::AlsaSeqState::PortStart( 660 void MidiManagerAlsa::AlsaSeqState::PortStart(
661 int client_id, 661 int client_id,
662 int port_id, 662 int port_id,
663 const std::string& port_name, 663 const std::string& port_name,
664 MidiManagerAlsa::AlsaSeqState::PortDirection direction, 664 MidiManagerAlsa::AlsaSeqState::PortDirection direction,
665 bool midi) { 665 bool midi) {
666 auto it = clients_.find(client_id); 666 auto it = clients_.find(client_id);
667 if (it != clients_.end()) 667 if (it != clients_.end())
668 it->second->AddPort(port_id, 668 it->second->AddPort(port_id,
669 base::WrapUnique(new Port(port_name, direction, midi))); 669 base::MakeUnique<Port>(port_name, direction, midi));
670 } 670 }
671 671
672 void MidiManagerAlsa::AlsaSeqState::PortExit(int client_id, int port_id) { 672 void MidiManagerAlsa::AlsaSeqState::PortExit(int client_id, int port_id) {
673 auto it = clients_.find(client_id); 673 auto it = clients_.find(client_id);
674 if (it != clients_.end()) 674 if (it != clients_.end())
675 it->second->RemovePort(port_id); 675 it->second->RemovePort(port_id);
676 } 676 }
677 677
678 snd_seq_client_type_t MidiManagerAlsa::AlsaSeqState::ClientType( 678 snd_seq_client_type_t MidiManagerAlsa::AlsaSeqState::ClientType(
679 int client_id) const { 679 int client_id) const {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 std::string version; 732 std::string version;
733 if (!driver.empty()) { 733 if (!driver.empty()) {
734 version = driver + " / "; 734 version = driver + " / ";
735 } 735 }
736 version += 736 version +=
737 base::StringPrintf("ALSA library version %d.%d.%d", SND_LIB_MAJOR, 737 base::StringPrintf("ALSA library version %d.%d.%d", SND_LIB_MAJOR,
738 SND_LIB_MINOR, SND_LIB_SUBMINOR); 738 SND_LIB_MINOR, SND_LIB_SUBMINOR);
739 PortDirection direction = port->direction(); 739 PortDirection direction = port->direction();
740 if (direction == PortDirection::kInput || 740 if (direction == PortDirection::kInput ||
741 direction == PortDirection::kDuplex) { 741 direction == PortDirection::kDuplex) {
742 midi_ports->push_back(base::WrapUnique(new MidiPort( 742 midi_ports->push_back(base::MakeUnique<MidiPort>(
743 path, id, client_id, port_id, midi_device, client->name(), 743 path, id, client_id, port_id, midi_device, client->name(),
744 port->name(), manufacturer, version, MidiPort::Type::kInput))); 744 port->name(), manufacturer, version, MidiPort::Type::kInput));
745 } 745 }
746 if (direction == PortDirection::kOutput || 746 if (direction == PortDirection::kOutput ||
747 direction == PortDirection::kDuplex) { 747 direction == PortDirection::kDuplex) {
748 midi_ports->push_back(base::WrapUnique(new MidiPort( 748 midi_ports->push_back(base::MakeUnique<MidiPort>(
749 path, id, client_id, port_id, midi_device, client->name(), 749 path, id, client_id, port_id, midi_device, client->name(),
750 port->name(), manufacturer, version, MidiPort::Type::kOutput))); 750 port->name(), manufacturer, version, MidiPort::Type::kOutput));
751 } 751 }
752 } 752 }
753 } 753 }
754 } 754 }
755 755
756 return midi_ports; 756 return midi_ports;
757 } 757 }
758 758
759 MidiManagerAlsa::AlsaSeqState::Port::Port( 759 MidiManagerAlsa::AlsaSeqState::Port::Port(
760 const std::string& name, 760 const std::string& name,
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 source_map_[AddrToInt(client_id, port_id)] = port_index; 1397 source_map_[AddrToInt(client_id, port_id)] = port_index;
1398 return true; 1398 return true;
1399 } 1399 }
1400 1400
1401 MidiManager* MidiManager::Create() { 1401 MidiManager* MidiManager::Create() {
1402 return new MidiManagerAlsa(); 1402 return new MidiManagerAlsa();
1403 } 1403 }
1404 1404
1405 } // namespace midi 1405 } // namespace midi
1406 } // namespace media 1406 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/vt_video_decode_accelerator_mac.cc ('k') | media/midi/midi_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698