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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 169193002: Convert scoped_ptr_malloc -> scoped_ptr, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/alsa/audio_manager_alsa.cc ('k') | net/base/io_buffer.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/audio/mac/audio_manager_mac.h" 5 #include "media/audio/mac/audio_manager_mac.h"
6 6
7 #include <CoreAudio/AudioHardware.h> 7 #include <CoreAudio/AudioHardware.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 0, 69 0,
70 NULL, 70 NULL,
71 &size); 71 &size);
72 if (result || !size) 72 if (result || !size)
73 return; 73 return;
74 74
75 int device_count = size / sizeof(AudioDeviceID); 75 int device_count = size / sizeof(AudioDeviceID);
76 76
77 // Get the array of device ids for all the devices, which includes both 77 // Get the array of device ids for all the devices, which includes both
78 // input devices and output devices. 78 // input devices and output devices.
79 scoped_ptr_malloc<AudioDeviceID> 79 scoped_ptr<AudioDeviceID, base::FreeDeleter>
80 devices(reinterpret_cast<AudioDeviceID*>(malloc(size))); 80 devices(static_cast<AudioDeviceID*>(malloc(size)));
81 AudioDeviceID* device_ids = devices.get(); 81 AudioDeviceID* device_ids = devices.get();
82 result = AudioObjectGetPropertyData(kAudioObjectSystemObject, 82 result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
83 &property_address, 83 &property_address,
84 0, 84 0,
85 NULL, 85 NULL,
86 &size, 86 &size,
87 device_ids); 87 device_ids);
88 if (result) 88 if (result)
89 return; 89 return;
90 90
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 AudioObjectPropertyAddress pa = { 481 AudioObjectPropertyAddress pa = {
482 kAudioDevicePropertyRelatedDevices, 482 kAudioDevicePropertyRelatedDevices,
483 kAudioDevicePropertyScopeOutput, 483 kAudioDevicePropertyScopeOutput,
484 kAudioObjectPropertyElementMaster 484 kAudioObjectPropertyElementMaster
485 }; 485 };
486 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size); 486 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size);
487 if (result || !size) 487 if (result || !size)
488 return std::string(); 488 return std::string();
489 489
490 int device_count = size / sizeof(AudioDeviceID); 490 int device_count = size / sizeof(AudioDeviceID);
491 scoped_ptr_malloc<AudioDeviceID> 491 scoped_ptr<AudioDeviceID, base::FreeDeleter>
492 devices(reinterpret_cast<AudioDeviceID*>(malloc(size))); 492 devices(static_cast<AudioDeviceID*>(malloc(size)));
493 result = AudioObjectGetPropertyData( 493 result = AudioObjectGetPropertyData(
494 device, &pa, 0, NULL, &size, devices.get()); 494 device, &pa, 0, NULL, &size, devices.get());
495 if (result) 495 if (result)
496 return std::string(); 496 return std::string();
497 497
498 std::vector<std::string> associated_devices; 498 std::vector<std::string> associated_devices;
499 for (int i = 0; i < device_count; ++i) { 499 for (int i = 0; i < device_count; ++i) {
500 // Get the number of output channels of the device. 500 // Get the number of output channels of the device.
501 pa.mSelector = kAudioDevicePropertyStreams; 501 pa.mSelector = kAudioDevicePropertyStreams;
502 size = 0; 502 size = 0;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 bool AudioManagerMac::ShouldDeferOutputStreamStart() { 737 bool AudioManagerMac::ShouldDeferOutputStreamStart() {
738 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 738 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
739 return power_observer_->ShouldDeferOutputStreamStart(); 739 return power_observer_->ShouldDeferOutputStreamStart();
740 } 740 }
741 741
742 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 742 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
743 return new AudioManagerMac(audio_log_factory); 743 return new AudioManagerMac(audio_log_factory);
744 } 744 }
745 745
746 } // namespace media 746 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/audio_manager_alsa.cc ('k') | net/base/io_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698