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

Unified Diff: webrtc/modules/audio_device/ios/audio_device_ios.mm

Issue 1498953002: Reland of "Create rtc::AtomicInt POD struct." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: initializer to audio_device_ios.mm Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.h ('k') | webrtc/modules/pacing/packet_router.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/ios/audio_device_ios.mm
diff --git a/webrtc/modules/audio_device/ios/audio_device_ios.mm b/webrtc/modules/audio_device/ios/audio_device_ios.mm
index b0d26be6ec28837a4cebd6e66ffd869e2af2d0e5..95834d25311e39eb251ba1bf29fbfcca01723ea9 100644
--- a/webrtc/modules/audio_device/ios/audio_device_ios.mm
+++ b/webrtc/modules/audio_device/ios/audio_device_ios.mm
@@ -28,7 +28,7 @@
namespace webrtc {
// Protects |g_audio_session_users|.
-static rtc::GlobalLockPod g_lock;
+static rtc::GlobalLockPod g_lock = {{0}};
// Counts number of users (=instances of this object) who needs an active
// audio session. This variable is used to ensure that we only activate an audio
@@ -288,8 +288,8 @@ static void LogDeviceInfo() {
AudioDeviceIOS::AudioDeviceIOS()
: audio_device_buffer_(nullptr),
vpio_unit_(nullptr),
- recording_(0),
- playing_(0),
+ recording_({0}),
+ playing_({0}),
initialized_(false),
rec_is_initialized_(false),
play_is_initialized_(false),
@@ -359,7 +359,7 @@ int32_t AudioDeviceIOS::InitPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(initialized_);
RTC_DCHECK(!play_is_initialized_);
- RTC_DCHECK(!playing_);
+ RTC_DCHECK(!Playing());
if (!rec_is_initialized_) {
if (!InitPlayOrRecord()) {
LOG_F(LS_ERROR) << "InitPlayOrRecord failed for InitPlayout!";
@@ -375,7 +375,7 @@ int32_t AudioDeviceIOS::InitRecording() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(initialized_);
RTC_DCHECK(!rec_is_initialized_);
- RTC_DCHECK(!recording_);
+ RTC_DCHECK(!Recording());
if (!play_is_initialized_) {
if (!InitPlayOrRecord()) {
LOG_F(LS_ERROR) << "InitPlayOrRecord failed for InitRecording!";
@@ -390,9 +390,9 @@ int32_t AudioDeviceIOS::StartPlayout() {
LOGI() << "StartPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(play_is_initialized_);
- RTC_DCHECK(!playing_);
+ RTC_DCHECK(!Playing());
fine_audio_buffer_->ResetPlayout();
- if (!recording_) {
+ if (!Recording()) {
OSStatus result = AudioOutputUnitStart(vpio_unit_);
if (result != noErr) {
LOG_F(LS_ERROR) << "AudioOutputUnitStart failed for StartPlayout: "
@@ -401,21 +401,21 @@ int32_t AudioDeviceIOS::StartPlayout() {
}
LOG(LS_INFO) << "Voice-Processing I/O audio unit is now started";
}
- rtc::AtomicOps::ReleaseStore(&playing_, 1);
+ rtc::AtomicInt::ReleaseStore(&playing_, 1);
return 0;
}
int32_t AudioDeviceIOS::StopPlayout() {
LOGI() << "StopPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- if (!play_is_initialized_ || !playing_) {
+ if (!play_is_initialized_ || !Playing()) {
return 0;
}
- if (!recording_) {
+ if (!Recording()) {
ShutdownPlayOrRecord();
}
play_is_initialized_ = false;
- rtc::AtomicOps::ReleaseStore(&playing_, 0);
+ rtc::AtomicInt::ReleaseStore(&playing_, 0);
return 0;
}
@@ -423,9 +423,9 @@ int32_t AudioDeviceIOS::StartRecording() {
LOGI() << "StartRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(rec_is_initialized_);
- RTC_DCHECK(!recording_);
+ RTC_DCHECK(!Recording());
fine_audio_buffer_->ResetRecord();
- if (!playing_) {
+ if (!Playing()) {
OSStatus result = AudioOutputUnitStart(vpio_unit_);
if (result != noErr) {
LOG_F(LS_ERROR) << "AudioOutputUnitStart failed for StartRecording: "
@@ -434,21 +434,21 @@ int32_t AudioDeviceIOS::StartRecording() {
}
LOG(LS_INFO) << "Voice-Processing I/O audio unit is now started";
}
- rtc::AtomicOps::ReleaseStore(&recording_, 1);
+ rtc::AtomicInt::ReleaseStore(&recording_, 1);
return 0;
}
int32_t AudioDeviceIOS::StopRecording() {
LOGI() << "StopRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- if (!rec_is_initialized_ || !recording_) {
+ if (!rec_is_initialized_ || !Recording()) {
return 0;
}
- if (!playing_) {
+ if (!Playing()) {
ShutdownPlayOrRecord();
}
rec_is_initialized_ = false;
- rtc::AtomicOps::ReleaseStore(&recording_, 0);
+ rtc::AtomicInt::ReleaseStore(&recording_, 0);
return 0;
}
@@ -1028,7 +1028,7 @@ OSStatus AudioDeviceIOS::OnRecordedDataIsAvailable(
UInt32 in_number_frames) {
OSStatus result = noErr;
// Simply return if recording is not enabled.
- if (!rtc::AtomicOps::AcquireLoad(&recording_))
+ if (!Recording())
return result;
if (in_number_frames != record_parameters_.frames_per_buffer()) {
// We have seen short bursts (1-2 frames) where |in_number_frames| changes.
@@ -1087,7 +1087,7 @@ OSStatus AudioDeviceIOS::OnGetPlayoutData(
SInt8* destination = static_cast<SInt8*>(io_data->mBuffers[0].mData);
// Produce silence and give audio unit a hint about it if playout is not
// activated.
- if (!rtc::AtomicOps::AcquireLoad(&playing_)) {
+ if (!Playing()) {
*io_action_flags |= kAudioUnitRenderAction_OutputIsSilence;
memset(destination, 0, dataSizeInBytes);
return noErr;
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.h ('k') | webrtc/modules/pacing/packet_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698