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

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

Issue 1911913002: Convert //media/audio from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast + windows build Created 4 years, 8 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 0, 126 0,
127 NULL, 127 NULL,
128 &size); 128 &size);
129 if (result || !size) 129 if (result || !size)
130 return; 130 return;
131 131
132 int device_count = size / sizeof(AudioDeviceID); 132 int device_count = size / sizeof(AudioDeviceID);
133 133
134 // Get the array of device ids for all the devices, which includes both 134 // Get the array of device ids for all the devices, which includes both
135 // input devices and output devices. 135 // input devices and output devices.
136 scoped_ptr<AudioDeviceID, base::FreeDeleter> 136 std::unique_ptr<AudioDeviceID, base::FreeDeleter> devices(
danakj 2016/04/22 22:47:37 include memory
dcheng 2016/04/22 23:13:20 Already in related header.
137 devices(static_cast<AudioDeviceID*>(malloc(size))); 137 static_cast<AudioDeviceID*>(malloc(size)));
138 AudioDeviceID* device_ids = devices.get(); 138 AudioDeviceID* device_ids = devices.get();
139 result = AudioObjectGetPropertyData(kAudioObjectSystemObject, 139 result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
140 &property_address, 140 &property_address,
141 0, 141 0,
142 NULL, 142 NULL,
143 &size, 143 &size,
144 device_ids); 144 device_ids);
145 if (result) 145 if (result)
146 return; 146 return;
147 147
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 AudioObjectPropertyAddress pa; 405 AudioObjectPropertyAddress pa;
406 pa.mSelector = kAudioDevicePropertyStreamConfiguration; 406 pa.mSelector = kAudioDevicePropertyStreamConfiguration;
407 pa.mScope = scope; 407 pa.mScope = scope;
408 pa.mElement = kAudioObjectPropertyElementMaster; 408 pa.mElement = kAudioObjectPropertyElementMaster;
409 409
410 UInt32 size; 410 UInt32 size;
411 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size); 411 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size);
412 if (result != noErr || !size) 412 if (result != noErr || !size)
413 return false; 413 return false;
414 414
415 scoped_ptr<uint8_t[]> list_storage(new uint8_t[size]); 415 std::unique_ptr<uint8_t[]> list_storage(new uint8_t[size]);
416 AudioBufferList& buffer_list = 416 AudioBufferList& buffer_list =
417 *reinterpret_cast<AudioBufferList*>(list_storage.get()); 417 *reinterpret_cast<AudioBufferList*>(list_storage.get());
418 418
419 result = AudioObjectGetPropertyData(device, &pa, 0, 0, &size, &buffer_list); 419 result = AudioObjectGetPropertyData(device, &pa, 0, 0, &size, &buffer_list);
420 if (result != noErr) 420 if (result != noErr)
421 return false; 421 return false;
422 422
423 // Determine number of channels based on the AudioBufferList. 423 // Determine number of channels based on the AudioBufferList.
424 // |mNumberBuffers] is the number of interleaved channels in the buffer. 424 // |mNumberBuffers] is the number of interleaved channels in the buffer.
425 // If the number is 1, the buffer is noninterleaved. 425 // If the number is 1, the buffer is noninterleaved.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 AudioObjectPropertyAddress pa = { 527 AudioObjectPropertyAddress pa = {
528 kAudioDevicePropertyRelatedDevices, 528 kAudioDevicePropertyRelatedDevices,
529 kAudioDevicePropertyScopeOutput, 529 kAudioDevicePropertyScopeOutput,
530 kAudioObjectPropertyElementMaster 530 kAudioObjectPropertyElementMaster
531 }; 531 };
532 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size); 532 OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size);
533 if (result || !size) 533 if (result || !size)
534 return std::string(); 534 return std::string();
535 535
536 int device_count = size / sizeof(AudioDeviceID); 536 int device_count = size / sizeof(AudioDeviceID);
537 scoped_ptr<AudioDeviceID, base::FreeDeleter> 537 std::unique_ptr<AudioDeviceID, base::FreeDeleter> devices(
538 devices(static_cast<AudioDeviceID*>(malloc(size))); 538 static_cast<AudioDeviceID*>(malloc(size)));
539 result = AudioObjectGetPropertyData( 539 result = AudioObjectGetPropertyData(
540 device, &pa, 0, NULL, &size, devices.get()); 540 device, &pa, 0, NULL, &size, devices.get());
541 if (result) 541 if (result)
542 return std::string(); 542 return std::string();
543 543
544 std::vector<std::string> associated_devices; 544 std::vector<std::string> associated_devices;
545 for (int i = 0; i < device_count; ++i) { 545 for (int i = 0; i < device_count; ++i) {
546 // Get the number of output channels of the device. 546 // Get the number of output channels of the device.
547 pa.mSelector = kAudioDevicePropertyStreams; 547 pa.mSelector = kAudioDevicePropertyStreams;
548 size = 0; 548 size = 0;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 ScopedAudioManagerPtr CreateAudioManager( 937 ScopedAudioManagerPtr CreateAudioManager(
938 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 938 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
939 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 939 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
940 AudioLogFactory* audio_log_factory) { 940 AudioLogFactory* audio_log_factory) {
941 return ScopedAudioManagerPtr( 941 return ScopedAudioManagerPtr(
942 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), 942 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner),
943 audio_log_factory)); 943 audio_log_factory));
944 } 944 }
945 945
946 } // namespace media 946 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698