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

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

Issue 517363002: Fix a memory leak in MidiManagerAlsa initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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 <alsa/asoundlib.h> 7 #include <alsa/asoundlib.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const std::string card_name = snd_ctl_card_info_get_longname(card); 177 const std::string card_name = snd_ctl_card_info_get_longname(card);
178 size_t at_index = card_name.rfind(" at "); 178 size_t at_index = card_name.rfind(" at ");
179 if (std::string::npos != at_index) { 179 if (std::string::npos != at_index) {
180 size_t name_index = card_name.rfind(name, at_index - 1); 180 size_t name_index = card_name.rfind(name, at_index - 1);
181 if (std::string::npos != name_index) 181 if (std::string::npos != name_index)
182 manufacturer = card_name.substr(0, name_index - 1); 182 manufacturer = card_name.substr(0, name_index - 1);
183 } 183 }
184 const std::string driver = snd_ctl_card_info_get_driver(card); 184 const std::string driver = snd_ctl_card_info_get_driver(card);
185 cards.push_back(new CardInfo(name, manufacturer, driver)); 185 cards.push_back(new CardInfo(name, manufacturer, driver));
186 } 186 }
187 snd_ctl_close(handle);
187 } 188 }
188 189
189 // Enumerate all ports in all clients. 190 // Enumerate all ports in all clients.
190 snd_seq_client_info_t* client_info; 191 snd_seq_client_info_t* client_info;
191 snd_seq_client_info_alloca(&client_info); 192 snd_seq_client_info_alloca(&client_info);
192 snd_seq_port_info_t* port_info; 193 snd_seq_port_info_t* port_info;
193 snd_seq_port_info_alloca(&port_info); 194 snd_seq_port_info_alloca(&port_info);
194 195
195 snd_seq_client_info_set_client(client_info, -1); 196 snd_seq_client_info_set_client(client_info, -1);
196 // Enumerate clients. 197 // Enumerate clients.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 event_thread_.message_loop()->PostTask( 444 event_thread_.message_loop()->PostTask(
444 FROM_HERE, 445 FROM_HERE,
445 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); 446 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this)));
446 } 447 }
447 448
448 MidiManager* MidiManager::Create() { 449 MidiManager* MidiManager::Create() {
449 return new MidiManagerAlsa(); 450 return new MidiManagerAlsa();
450 } 451 }
451 452
452 } // namespace media 453 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698