Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for iOS #881

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
cmake_generator: "Unix Makefiles"
cmake_options:
-DCMAKE_FRAMEWORK=ON
- name: iOS Clang cross compilation
os: macOS-latest
vcpkg_triplet: arm64-ios
cmake_generator: "Unix Makefiles"
cmake_options:
-DCMAKE_SYSTEM_NAME=iOS

runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
Expand Down
35 changes: 25 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,25 @@ elseif(UNIX)

if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
target_sources(PortAudio PRIVATE
src/hostapi/coreaudio/pa_mac_core.c
src/hostapi/coreaudio/pa_mac_core_blocking.c
src/hostapi/coreaudio/pa_mac_core_blocking.h
src/hostapi/coreaudio/pa_mac_core_internal.h
src/hostapi/coreaudio/pa_mac_core_utilities.c
src/hostapi/coreaudio/pa_mac_core_utilities.h
)
if(IOS)
philburk marked this conversation as resolved.
Show resolved Hide resolved
target_sources(PortAudio PRIVATE
src/hostapi/coreaudio_ios/pa_ios_core.c
src/hostapi/coreaudio_ios/pa_ios_core_blocking.c
src/hostapi/coreaudio_ios/pa_ios_core_blocking.h
src/hostapi/coreaudio_ios/pa_ios_core_internal.h
src/hostapi/coreaudio_ios/pa_ios_core_utilities.c
src/hostapi/coreaudio_ios/pa_ios_core_utilities.h
)
else()
target_sources(PortAudio PRIVATE
src/hostapi/coreaudio/pa_mac_core.c
src/hostapi/coreaudio/pa_mac_core_blocking.c
src/hostapi/coreaudio/pa_mac_core_blocking.h
src/hostapi/coreaudio/pa_mac_core_internal.h
src/hostapi/coreaudio/pa_mac_core_utilities.c
src/hostapi/coreaudio/pa_mac_core_utilities.h
)
endif()
target_include_directories(PortAudio PRIVATE src/hostapi/coreaudio)
set(PORTAUDIO_PUBLIC_HEADERS "${PORTAUDIO_PUBLIC_HEADERS}" include/pa_mac_core.h)

Expand All @@ -315,8 +326,12 @@ elseif(UNIX)
-Wl,-framework,CoreFoundation
-Wl,-framework,CoreServices
)
target_compile_definitions(PortAudio PUBLIC PA_USE_COREAUDIO=1)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_COREAUDIO=1")
if(IOS)
target_compile_definitions(PortAudio PUBLIC PA_USE_COREAUDIO_IOS=1)
else()
target_compile_definitions(PortAudio PUBLIC PA_USE_COREAUDIO=1)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_COREAUDIO=1")
endif()

# Use C11 so that we can make use of atomic library and avoid deprecation errors.
set_property(TARGET PortAudio PROPERTY C_STANDARD 11)
Expand Down
59 changes: 59 additions & 0 deletions include/pa_ios_core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef PA_IOS_CORE_H
#define PA_IOS_CORE_H
/*
* PortAudio Portable Real-Time Audio Library
* iOS Core Audio specific extensions
* portaudio.h should be included before this file.
*
* Copyright (c) 2019 Hans Petter Selasky
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/

/** @file
* @ingroup public_header
* @brief iOS-specific PortAudio API extension header file.
*/

#include "portaudio.h"

#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif /** __cplusplus */

#endif /* PA_IOS_CORE_H */
7 changes: 7 additions & 0 deletions src/common/pa_hostapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ are defaulted to 1.
#define PA_USE_COREAUDIO 1
#endif

#ifndef PA_USE_COREAUDIO_IOS
#define PA_USE_COREAUDIO_IOS 0
#elif (PA_USE_COREAUDIO_IOS != 0) && (PA_USE_COREAUDIO_IOS != 1)
#undef PA_USE_COREAUDIO_IOS
#define PA_USE_COREAUDIO_IOS 1
#endif

#ifndef PA_USE_ASIHPI
#define PA_USE_ASIHPI 0
#elif (PA_USE_ASIHPI != 0) && (PA_USE_ASIHPI != 1)
Expand Down
Loading
Loading