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

Side by Side Diff: webrtc/sound/alsasoundsystem.cc

Issue 1405023016: Convert usage of ARRAY_SIZE to arraysize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: static_cast<int> Created 5 years, 1 month 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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/sound/alsasoundsystem.h" 11 #include "webrtc/sound/alsasoundsystem.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include "webrtc/sound/sounddevicelocator.h" 14
15 #include "webrtc/sound/soundinputstreaminterface.h" 15 #include "webrtc/base/arraysize.h"
16 #include "webrtc/sound/soundoutputstreaminterface.h"
17 #include "webrtc/base/common.h" 16 #include "webrtc/base/common.h"
18 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
19 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/base/stringutils.h" 19 #include "webrtc/base/stringutils.h"
21 #include "webrtc/base/timeutils.h" 20 #include "webrtc/base/timeutils.h"
22 #include "webrtc/base/worker.h" 21 #include "webrtc/base/worker.h"
22 #include "webrtc/sound/sounddevicelocator.h"
23 #include "webrtc/sound/soundinputstreaminterface.h"
24 #include "webrtc/sound/soundoutputstreaminterface.h"
23 25
24 namespace rtc { 26 namespace rtc {
25 27
26 // Lookup table from the rtc format enum in soundsysteminterface.h to 28 // Lookup table from the rtc format enum in soundsysteminterface.h to
27 // ALSA's enums. 29 // ALSA's enums.
28 static const snd_pcm_format_t kCricketFormatToAlsaFormatTable[] = { 30 static const snd_pcm_format_t kCricketFormatToAlsaFormatTable[] = {
29 // The order here must match the order in soundsysteminterface.h 31 // The order here must match the order in soundsysteminterface.h
30 SND_PCM_FORMAT_S16_LE, 32 SND_PCM_FORMAT_S16_LE,
31 }; 33 };
32 34
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 601
600 bool AlsaSoundSystem::GetDefaultDevice(SoundDeviceLocator **device) { 602 bool AlsaSoundSystem::GetDefaultDevice(SoundDeviceLocator **device) {
601 if (!IsInitialized()) { 603 if (!IsInitialized()) {
602 return false; 604 return false;
603 } 605 }
604 *device = new AlsaDeviceLocator("Default device", "default"); 606 *device = new AlsaDeviceLocator("Default device", "default");
605 return true; 607 return true;
606 } 608 }
607 609
608 inline size_t AlsaSoundSystem::FrameSize(const OpenParams &params) { 610 inline size_t AlsaSoundSystem::FrameSize(const OpenParams &params) {
609 ASSERT(static_cast<int>(params.format) <
610 ARRAY_SIZE(kCricketFormatToSampleSizeTable));
611 return kCricketFormatToSampleSizeTable[params.format] * params.channels; 611 return kCricketFormatToSampleSizeTable[params.format] * params.channels;
612 } 612 }
613 613
614 template <typename StreamInterface> 614 template <typename StreamInterface>
615 StreamInterface *AlsaSoundSystem::OpenDevice( 615 StreamInterface *AlsaSoundSystem::OpenDevice(
616 const SoundDeviceLocator *device, 616 const SoundDeviceLocator *device,
617 const OpenParams &params, 617 const OpenParams &params,
618 snd_pcm_stream_t type, 618 snd_pcm_stream_t type,
619 StreamInterface *(AlsaSoundSystem::*start_fn)( 619 StreamInterface *(AlsaSoundSystem::*start_fn)(
620 snd_pcm_t *handle, 620 snd_pcm_t *handle,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // kLowLatency is 0, so we treat it the same as a request for zero latency. 655 // kLowLatency is 0, so we treat it the same as a request for zero latency.
656 // Compute what the user asked for. 656 // Compute what the user asked for.
657 latency = rtc::kNumMicrosecsPerSec * 657 latency = rtc::kNumMicrosecsPerSec *
658 params.latency / 658 params.latency /
659 params.freq / 659 params.freq /
660 FrameSize(params); 660 FrameSize(params);
661 // And this is what we'll actually use. 661 // And this is what we'll actually use.
662 latency = std::max(latency, kMinimumLatencyUsecs); 662 latency = std::max(latency, kMinimumLatencyUsecs);
663 } 663 }
664 664
665 ASSERT(static_cast<int>(params.format) < 665 ASSERT(params.format < arraysize(kCricketFormatToAlsaFormatTable));
666 ARRAY_SIZE(kCricketFormatToAlsaFormatTable));
667 666
668 err = symbol_table_.snd_pcm_set_params()( 667 err = symbol_table_.snd_pcm_set_params()(
669 handle, 668 handle,
670 kCricketFormatToAlsaFormatTable[params.format], 669 kCricketFormatToAlsaFormatTable[params.format],
671 // SoundSystemInterface only supports interleaved audio. 670 // SoundSystemInterface only supports interleaved audio.
672 SND_PCM_ACCESS_RW_INTERLEAVED, 671 SND_PCM_ACCESS_RW_INTERLEAVED,
673 params.channels, 672 params.channels,
674 params.freq, 673 params.freq,
675 1, // Allow ALSA to resample. 674 1, // Allow ALSA to resample.
676 latency); 675 latency);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 733 }
735 return new AlsaInputStream( 734 return new AlsaInputStream(
736 this, handle, frame_size, wait_timeout_ms, flags, freq); 735 this, handle, frame_size, wait_timeout_ms, flags, freq);
737 } 736 }
738 737
739 inline const char *AlsaSoundSystem::GetError(int err) { 738 inline const char *AlsaSoundSystem::GetError(int err) {
740 return symbol_table_.snd_strerror()(err); 739 return symbol_table_.snd_strerror()(err);
741 } 740 }
742 741
743 } // namespace rtc 742 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportdescription.cc ('k') | webrtc/sound/automaticallychosensoundsystem_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698