After an audio interruption the audio unit no longer invokes its render callback, which results in a loss of audio. Restarting the audio unit post interruption fixes the issue.
CL also replaces deprecated AudioSession calls with equivalent AVAudioSession ones. BUG=3487 R=glaznev@webrtc.org, noahric@chromium.org Review URL: https://webrtc-codereview.appspot.com/21769004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6697 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -98,7 +98,7 @@
|
||||
'linux/audio_mixer_manager_alsa_linux.h',
|
||||
'linux/latebindingsymboltable_linux.cc',
|
||||
'linux/latebindingsymboltable_linux.h',
|
||||
'ios/audio_device_ios.cc',
|
||||
'ios/audio_device_ios.mm',
|
||||
'ios/audio_device_ios.h',
|
||||
'ios/audio_device_utility_ios.cc',
|
||||
'ios/audio_device_utility_ios.h',
|
||||
@ -175,7 +175,7 @@
|
||||
}],
|
||||
],
|
||||
}],
|
||||
['OS=="mac" or OS=="ios"', {
|
||||
['OS=="mac"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AudioToolbox.framework',
|
||||
@ -183,6 +183,19 @@
|
||||
],
|
||||
},
|
||||
}],
|
||||
['OS=="ios"', {
|
||||
'xcode_settings': {
|
||||
'CLANG_ENABLE_OBJC_ARC': 'YES',
|
||||
},
|
||||
'link_settings': {
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [
|
||||
'-framework AudioToolbox',
|
||||
'-framework AVFoundation',
|
||||
],
|
||||
},
|
||||
},
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
|
@ -349,15 +349,15 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
#if defined(WEBRTC_IOS)
|
||||
if (audioLayer == kPlatformDefaultAudio)
|
||||
{
|
||||
// Create *iPhone Audio* implementation
|
||||
ptrAudioDevice = new AudioDeviceIPhone(Id());
|
||||
// Create iOS Audio Device implementation.
|
||||
ptrAudioDevice = new AudioDeviceIOS(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "iPhone Audio APIs will be utilized");
|
||||
}
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
// Create the Mac implementation of the Device Utility.
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityIPhone(Id());
|
||||
// Create iOS Device Utility implementation.
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityIOS(Id());
|
||||
}
|
||||
// END #if defined(WEBRTC_IOS)
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace webrtc
|
||||
|
||||
class AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
public:
|
||||
static uint32_t GetTimeInMS();
|
||||
static void WaitForKey();
|
||||
static bool StringCompare(const char* str1,
|
||||
|
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IPHONE_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IPHONE_H
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IOS_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IOS_H
|
||||
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
|
||||
@ -32,14 +32,14 @@ const uint32_t ENGINE_PLAY_BUF_SIZE_IN_SAMPLES = (N_PLAY_SAMPLES_PER_SEC / 100);
|
||||
// Number of 10 ms recording blocks in recording buffer
|
||||
const uint16_t N_REC_BUFFERS = 20;
|
||||
|
||||
class AudioDeviceIPhone : public AudioDeviceGeneric {
|
||||
public:
|
||||
AudioDeviceIPhone(const int32_t id);
|
||||
~AudioDeviceIPhone();
|
||||
class AudioDeviceIOS : public AudioDeviceGeneric {
|
||||
public:
|
||||
AudioDeviceIOS(const int32_t id);
|
||||
~AudioDeviceIOS();
|
||||
|
||||
// Retrieve the currently utilized audio layer
|
||||
virtual int32_t
|
||||
ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const;
|
||||
virtual int32_t ActiveAudioLayer(
|
||||
AudioDeviceModule::AudioLayer& audioLayer) const;
|
||||
|
||||
// Main initializaton and termination
|
||||
virtual int32_t Init();
|
||||
@ -58,8 +58,7 @@ public:
|
||||
|
||||
// Device selection
|
||||
virtual int32_t SetPlayoutDevice(uint16_t index);
|
||||
virtual int32_t
|
||||
SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
|
||||
virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
|
||||
virtual int32_t SetRecordingDevice(uint16_t index);
|
||||
virtual int32_t SetRecordingDevice(
|
||||
AudioDeviceModule::WindowsDeviceType device);
|
||||
@ -109,8 +108,7 @@ public:
|
||||
virtual int32_t MicrophoneVolume(uint32_t& volume) const;
|
||||
virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
|
||||
virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
|
||||
virtual int32_t
|
||||
MicrophoneVolumeStepSize(uint16_t& stepSize) const;
|
||||
virtual int32_t MicrophoneVolumeStepSize(uint16_t& stepSize) const;
|
||||
|
||||
// Microphone mute control
|
||||
virtual int32_t MicrophoneMuteIsAvailable(bool& available);
|
||||
@ -136,8 +134,7 @@ public:
|
||||
virtual int32_t StereoRecording(bool& enabled) const;
|
||||
|
||||
// Delay information and control
|
||||
virtual int32_t
|
||||
SetPlayoutBuffer(const AudioDeviceModule::BufferType type,
|
||||
virtual int32_t SetPlayoutBuffer(const AudioDeviceModule::BufferType type,
|
||||
uint16_t sizeMS);
|
||||
virtual int32_t PlayoutBuffer(AudioDeviceModule::BufferType& type,
|
||||
uint16_t& sizeMS) const;
|
||||
@ -147,7 +144,7 @@ public:
|
||||
// CPU load
|
||||
virtual int32_t CPULoad(uint16_t& load) const;
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual bool PlayoutWarning() const;
|
||||
virtual bool PlayoutError() const;
|
||||
virtual bool RecordingWarning() const;
|
||||
@ -157,17 +154,17 @@ public:
|
||||
virtual void ClearRecordingWarning();
|
||||
virtual void ClearRecordingError();
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
|
||||
|
||||
// Reset Audio Deivce (for mobile devices only)
|
||||
// Reset Audio Device (for mobile devices only)
|
||||
virtual int32_t ResetAudioDevice();
|
||||
|
||||
// enable or disable loud speaker (for iphone only)
|
||||
virtual int32_t SetLoudspeakerStatus(bool enable);
|
||||
virtual int32_t GetLoudspeakerStatus(bool& enabled) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
void Lock() {
|
||||
_critSect.Enter();
|
||||
}
|
||||
@ -212,7 +209,7 @@ private:
|
||||
static bool RunCapture(void* ptrThis);
|
||||
bool CaptureWorkerThread();
|
||||
|
||||
private:
|
||||
private:
|
||||
AudioDeviceBuffer* _ptrAudioBuffer;
|
||||
|
||||
CriticalSectionWrapper& _critSect;
|
||||
@ -223,8 +220,9 @@ private:
|
||||
int32_t _id;
|
||||
|
||||
AudioUnit _auVoiceProcessing;
|
||||
void* _audioInterruptionObserver;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _initialized;
|
||||
bool _isShutDown;
|
||||
bool _recording;
|
||||
@ -260,8 +258,7 @@ private:
|
||||
uint32_t _playoutBufferUsed; // How much is filled
|
||||
|
||||
// Recording buffers
|
||||
int16_t
|
||||
_recordingBuffer[N_REC_BUFFERS][ENGINE_REC_BUF_SIZE_IN_SAMPLES];
|
||||
int16_t _recordingBuffer[N_REC_BUFFERS][ENGINE_REC_BUF_SIZE_IN_SAMPLES];
|
||||
uint32_t _recordingLength[N_REC_BUFFERS];
|
||||
uint32_t _recordingSeqNumber[N_REC_BUFFERS];
|
||||
uint32_t _recordingCurrentSeq;
|
||||
@ -272,4 +269,4 @@ private:
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_MAC_AUDIO_DEVICE_IPHONE_H_
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IOS_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
AudioDeviceUtilityIPhone::AudioDeviceUtilityIPhone(const int32_t id)
|
||||
AudioDeviceUtilityIOS::AudioDeviceUtilityIOS(const int32_t id)
|
||||
:
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_id(id),
|
||||
@ -24,7 +24,7 @@ AudioDeviceUtilityIPhone::AudioDeviceUtilityIPhone(const int32_t id)
|
||||
"%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
AudioDeviceUtilityIPhone::~AudioDeviceUtilityIPhone() {
|
||||
AudioDeviceUtilityIOS::~AudioDeviceUtilityIOS() {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id,
|
||||
"%s destroyed", __FUNCTION__);
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
@ -32,7 +32,7 @@ AudioDeviceUtilityIPhone::~AudioDeviceUtilityIPhone() {
|
||||
delete &_critSect;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceUtilityIPhone::Init() {
|
||||
int32_t AudioDeviceUtilityIOS::Init() {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
@ -17,15 +17,15 @@
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityIPhone: public AudioDeviceUtility {
|
||||
public:
|
||||
AudioDeviceUtilityIPhone(const int32_t id);
|
||||
AudioDeviceUtilityIPhone();
|
||||
virtual ~AudioDeviceUtilityIPhone();
|
||||
class AudioDeviceUtilityIOS: public AudioDeviceUtility {
|
||||
public:
|
||||
AudioDeviceUtilityIOS(const int32_t id);
|
||||
AudioDeviceUtilityIOS();
|
||||
virtual ~AudioDeviceUtilityIOS();
|
||||
|
||||
virtual int32_t Init();
|
||||
|
||||
private:
|
||||
private:
|
||||
CriticalSectionWrapper& _critSect;
|
||||
int32_t _id;
|
||||
AudioDeviceModule::ErrorCode _lastError;
|
||||
@ -33,4 +33,4 @@ private:
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
|
@ -43,6 +43,7 @@ using namespace webrtc::videocapturemodule;
|
||||
_owner = owner;
|
||||
_captureId = captureId;
|
||||
_captureSession = [[AVCaptureSession alloc] init];
|
||||
_captureSession.usesApplicationAudioSession = NO;
|
||||
_captureChanging = NO;
|
||||
_captureChangingCondition = [[NSCondition alloc] init];
|
||||
|
||||
|
Reference in New Issue
Block a user