Skip to content

Commit

Permalink
Fix Compile Failure for macOS, iOS and modern Xcode (#69)
Browse files Browse the repository at this point in the history
This PR fixes #63 which was caused by CELT C-Flag.

Also implement condition to not include `UIKit`, which cause the macOS
build fail
  • Loading branch information
Krzmbrzl authored Sep 30, 2024
2 parents c6f7819 + 2218e7b commit d34fd19
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
submodules: 'recursive'
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.1'
xcode-version: '14'
- name: Build
run: |
gem install --verbose xcpretty
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/celt-0.7.0-build/Base.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0

SKIP_INSTALL = YES

OTHER_CFLAGS = -x c++
//OTHER_CFLAGS = -x c++

HEADER_SEARCH_PATHS = .
ALWAYS_SEARCH_USER_PATHS = NO
Expand Down
4 changes: 2 additions & 2 deletions src/MKMacAudioDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ static OSStatus inputCallback(void *udata, AudioUnitRenderActionFlags *flags, co
actual read bytes count. We need to write it back otherwise
we'll reallocate the buffer even if not needed.
*/
UInt32 dataByteSize = dev->_buflist.mBuffers->mDataByteSize;
UInt32 dataByteSize = dev->_recordBufList.mBuffers->mDataByteSize;
err = AudioUnitRender(dev->_recordAudioUnit, flags, ts, busnum, nframes, &dev->_recordBufList);
if (err != noErr) {
NSLog(@"MKMacAudioDevice: AudioUnitRender failed. err = %ld", (unsigned long)err);
return err;
}
dev->_buflist.mBuffers->mDataByteSize = dataByteSize;
dev->_recordBufList.mBuffers->mDataByteSize = dataByteSize;

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
short *buf = (short *) dev->_recordBufList.mBuffers->mData;
Expand Down
14 changes: 13 additions & 1 deletion src/MKVoiceProcessingDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
#import <AudioUnit/AudioUnit.h>
#import <AudioUnit/AUComponent.h>
#import <AudioToolbox/AudioToolbox.h>
#import <UIKit/UIKit.h>
#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
#define IS_UIDEVICE_AVAILABLE 1
#elif TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_MACCATALYST
#define IS_UIDEVICE_AVAILABLE 1
#else
#define IS_UIDEVICE_AVAILABLE 0
#endif

#if IS_UIDEVICE_AVAILABLE
#import <UIKit/UIKit.h>
#endif

@interface MKVoiceProcessingDevice () {
@public
Expand All @@ -24,6 +34,7 @@ @interface MKVoiceProcessingDevice () {
}
@end

#if IS_UIDEVICE_AVAILABLE
// DeviceIsRunningiOS7OrGreater returns YES if
// the iOS device is on iOS 7 or greater.
static BOOL DeviceIsRunningiOS7OrGreater() {
Expand All @@ -38,6 +49,7 @@ static BOOL DeviceIsRunningiOS7OrGreater() {
}
return iOS7OrGreater;
}
#endif

static OSStatus inputCallback(void *udata, AudioUnitRenderActionFlags *flags, const AudioTimeStamp *ts,
UInt32 busnum, UInt32 nframes, AudioBufferList *buflist) {
Expand Down

0 comments on commit d34fd19

Please sign in to comment.