Skip to content
Snippets Groups Projects
Commit 20c285b4 authored by Edric Milaret's avatar Edric Milaret
Browse files

ios: disable non-compatible part of coreaudiolayer

Device management is done another way in iOS thus we don't have
access to CoreAudio/Hardware in CoreAudio framework. Disabling those
part allow us to compile. Maybe some things will need to be rewritten.
In this case it we'll be done in another patch (either as fixing
existing code or as another layer if need be)

Change-Id: I9f8e365bb173cf1df8bd6431371b844b092ec0cb
Tuleap: #313
parent 8ea43ee9
Branches
Tags
No related merge requests found
......@@ -102,7 +102,7 @@ AM_CONDITIONAL(HAVE_IOS, test "${HAVE_IOS}" = "1")
dnl FIXME this should be deduced automatically
AC_DEFINE_UNQUOTED([HAVE_COREAUDIO],
`if test "${HAVE_OSX}" = "1"; then echo 1; else echo 0; fi`,
`if test "${HAVE_OSX}" = "1" || test "${HAVE_IOS}" = "1"; then echo 1; else echo 0; fi`,
[Define if you have CoreAudio])
dnl Android is linux, but a bit different
......
......@@ -24,6 +24,10 @@ if HAVE_OSX
SUBDIRS += coreaudio
endif
if HAVE_IOS
SUBDIRS += coreaudio
endif
if HAVE_PORTAUDIO
SUBDIRS += portaudio
endif
......@@ -89,6 +93,10 @@ if HAVE_OSX
libaudio_la_LIBADD += ./coreaudio/libcoreaudiolayer.la
endif
if HAVE_IOS
libaudio_la_LIBADD += ./coreaudio/libcoreaudiolayer.la
endif
if BUILD_OPENSL
libaudio_la_LIBADD += ./opensl/libopensl.la
libaudio_la_LDFLAGS += -lOpenSLES
......
......@@ -4,5 +4,9 @@ if HAVE_OSX
noinst_LTLIBRARIES = libcoreaudiolayer.la
endif
if HAVE_IOS
noinst_LTLIBRARIES = libcoreaudiolayer.la
endif
libcoreaudiolayer_la_SOURCES = corelayer.cpp corelayer.h audiodevice.cpp audiodevice.h
libcoreaudiolayer_la_CXXFLAGS = -I$(top_srcdir)/src
......@@ -20,6 +20,8 @@
#include "audiodevice.h"
#if !TARGET_OS_IPHONE
namespace ring {
AudioDevice::AudioDevice(AudioDeviceID devid, bool isInput)
......@@ -168,3 +170,5 @@ std::string AudioDevice::getName() const
}
} // namespace ring
#endif // TARGET_OS_IPHONE
......@@ -21,14 +21,19 @@
#ifndef AUDIO_DEVICE_H
#define AUDIO_DEVICE_H
#import <TargetConditionals.h>
#if !TARGET_OS_IPHONE
#include <CoreServices/CoreServices.h>
#include <CoreAudio/CoreAudio.h>
#endif
#include <string>
namespace ring {
class AudioDevice {
#if !TARGET_OS_IPHONE
public:
AudioDevice() : id_(kAudioDeviceUnknown) { }
AudioDevice(AudioDeviceID devid, bool isInput);
......@@ -48,6 +53,7 @@ public:
private:
int countChannels() const;
std::string getName() const;
#endif
};
}
......
......@@ -57,8 +57,10 @@ std::vector<std::string> CoreLayer::getCaptureDeviceList() const
{
std::vector<std::string> ret;
#if !TARGET_OS_IPHONE
for (auto x : getDeviceList(true))
ret.push_back(x.name_);
#endif
return ret;
}
......@@ -67,10 +69,10 @@ std::vector<std::string> CoreLayer::getPlaybackDeviceList() const
{
std::vector<std::string> ret;
#if !TARGET_OS_IPHONE
for (auto x : getDeviceList(false))
{
ret.push_back(x.name_);
}
#endif
return ret;
}
......@@ -175,6 +177,7 @@ void CoreLayer::initAudioLayerIO()
// Input buffer setup. Note that ioData is empty and we have to store data
// in another buffer.
#if !TARGET_OS_IPHONE
UInt32 bufferSizeFrames = 0;
size = sizeof(UInt32);
checkErr(AudioUnitGetProperty(ioUnit_,
......@@ -183,6 +186,14 @@ void CoreLayer::initAudioLayerIO()
outputBus,
&bufferSizeFrames,
&size));
#else
Float32 bufferDuration;
UInt32 propSize = sizeof(Float32);
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration,
&propSize,
&bufferDuration);
UInt32 bufferSizeFrames = audioInputFormat_.sample_rate * bufferDuration;
#endif
UInt32 bufferSizeBytes = bufferSizeFrames * sizeof(Float32);
size = offsetof(AudioBufferList, mBuffers[0]) +
......@@ -392,6 +403,7 @@ void CoreLayer::updatePreference(AudioPreference &preference, int index, DeviceT
std::vector<AudioDevice> CoreLayer::getDeviceList(bool getCapture) const
{
std::vector<AudioDevice> ret;
#if !TARGET_OS_IPHONE
UInt32 propsize;
AudioObjectPropertyAddress theAddress = {
......@@ -422,7 +434,7 @@ std::vector<AudioDevice> CoreLayer::getDeviceList(bool getCapture) const
}
}
delete[] devids;
#endif
return ret;
}
......
......@@ -25,7 +25,9 @@
#include "noncopyable.h"
#include <CoreFoundation/CoreFoundation.h>
#include <AudioToolbox/AudioToolbox.h>
#if !TARGET_OS_IPHONE
#include <CoreAudio/AudioHardware.h>
#endif
#define checkErr( err) \
if(err) {\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment