Skip to content

Commit 1fcfb24

Browse files
authored
Merge branch 'main' into flac-channel-order
2 parents 70b5351 + 1b89018 commit 1fcfb24

40 files changed

+611
-516
lines changed

.github/workflows/clang-format-check.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/cpp-linter.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: cpp-linter
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
paths:
6+
- 'Sources/CSFBAudioEngine/**.h'
7+
- 'Sources/CSFBAudioEngine/**.hpp'
8+
- 'Sources/CSFBAudioEngine/**.m'
9+
- 'Sources/CSFBAudioEngine/**.mm'
10+
pull_request:
11+
branches: [ "main" ]
12+
paths:
13+
- 'Sources/CSFBAudioEngine/**.h'
14+
- 'Sources/CSFBAudioEngine/**.hpp'
15+
- 'Sources/CSFBAudioEngine/**.m'
16+
- 'Sources/CSFBAudioEngine/**.mm'
17+
permissions:
18+
contents: read
19+
pull-requests: write
20+
jobs:
21+
cpp-linter:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
- name: cpp-linter
27+
uses: cpp-linter/cpp-linter-action@v2
28+
id: linter
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
style: 'file'
33+
tidy-checks: '-*'
34+
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}
35+
format-review: true
36+
- name: Fail fast?!
37+
if: steps.linter.outputs.checks-failed > 0
38+
run: exit 1

Package.resolved

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ let package = Package(
3232

3333
// Standalone dependencies from source
3434
.package(url: "https://github.com/sbooth/CDUMB", from: "2.0.3"),
35-
.package(url: "https://github.com/sbooth/CXXMonkeysAudio", from: "11.82.0"),
35+
.package(url: "https://github.com/sbooth/CXXMonkeysAudio", from: "12.13.0"),
3636
.package(url: "https://github.com/sbooth/CXXTagLib", from: "2.1.1"),
3737

3838
// Standalone dependencies not easily packaged using SPM
39-
.package(url: "https://github.com/sbooth/wavpack-binary-xcframework", .upToNextMinor(from: "0.1.2")),
39+
.package(url: "https://github.com/sbooth/wavpack-binary-xcframework", .upToNextMinor(from: "0.2.0")),
4040

4141
// Xiph ecosystem
4242
.package(url: "https://github.com/sbooth/ogg-binary-xcframework", .upToNextMinor(from: "0.1.3")),
4343
// flac-binary-xcframework requires ogg-binary-xcframework
4444
.package(url: "https://github.com/sbooth/flac-binary-xcframework", .upToNextMinor(from: "0.2.0")),
4545
// opus-binary-xcframework requires ogg-binary-xcframework
46-
.package(url: "https://github.com/sbooth/opus-binary-xcframework", .upToNextMinor(from: "0.2.2")),
46+
.package(url: "https://github.com/sbooth/opus-binary-xcframework", .upToNextMinor(from: "0.3.0")),
4747
// vorbis-binary-xcframework requires ogg-binary-xcframework
4848
.package(url: "https://github.com/sbooth/vorbis-binary-xcframework", .upToNextMinor(from: "0.1.2")),
4949
// libspeex does not depend on libogg
@@ -53,7 +53,7 @@ let package = Package(
5353
.package(url: "https://github.com/sbooth/lame-binary-xcframework", .upToNextMinor(from: "0.1.2")),
5454
// Technically only the musepack *encoder* is LGPL'd but for now the decoder and encoder are packaged together
5555
.package(url: "https://github.com/sbooth/mpc-binary-xcframework", .upToNextMinor(from: "0.1.2")),
56-
.package(url: "https://github.com/sbooth/mpg123-binary-xcframework", .upToNextMinor(from: "0.3.0")),
56+
.package(url: "https://github.com/sbooth/mpg123-binary-xcframework", .upToNextMinor(from: "0.3.1")),
5757
// sndfile-binary-xcframework requires ogg-binary-xcframework, flac-binary-xcframework, opus-binary-xcframework, and vorbis-binary-xcframework
5858
.package(url: "https://github.com/sbooth/sndfile-binary-xcframework", .upToNextMinor(from: "0.1.2")),
5959
.package(url: "https://github.com/sbooth/tta-cpp-binary-xcframework", .upToNextMinor(from: "0.1.2")),

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ The output file's format is inferred from the file extension.
7272
More complex conversions are supported including writing to `Data` instead of files:
7373

7474
~~~swift
75-
let output = OutputSource.makeForData()
76-
let encoder = try AudioEncoder(outputSource: output, encoderName: .coreAudio)
75+
let output = OutputTarget.makeForData()
76+
let encoder = try AudioEncoder(outputTarget: output, encoderName: .coreAudio)
7777
encoder.settings = [
7878
.coreAudioFileTypeID: kAudioFileM4AType,
7979
.coreAudioFormatID: kAudioFormatMPEG4AAC,
@@ -114,9 +114,9 @@ Three special decoder subclasses that decorate an underlying audio decoder insta
114114

115115
## Encoding
116116

117-
[Audio encoders](Sources/CSFBAudioEngine/Encoders/) in SFBAudioEngine process input data and convert it to their output format. Audio encoders write data to an [SFBOutputSource](Sources/CSFBAudioEngine/include/SFBOutputSource.h) which may refer to a file, buffer, or data.
117+
[Audio encoders](Sources/CSFBAudioEngine/SFBAudioEngine/Encoders/) in SFBAudioEngine process input data and convert it to their output format. Audio encoders write data to an [SFBOutputTarget](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBOutputTarget.h) which may refer to a file, buffer, or data.
118118

119-
All audio encoders in SFBAudioEngine implement the [SFBAudioEncoding](Sources/CSFBAudioEngine/include/SFBAudioEncoding.h) protocol. PCM-consuming encoders additionally implement [SFBPCMEncoding](Sources/CSFBAudioEngine/include/SFBPCMEncoding.h). Currently there are no encoders consuming DSD in SFBAudioEngine.
119+
All audio encoders in SFBAudioEngine implement the [SFBAudioEncoding](Sources/CSFBAudioEngine/include/SFBAudioEncoding.h) protocol. PCM-consuming encoders additionally implement [SFBPCMEncoding](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBPCMEncoding.h). Currently there are no encoders consuming DSD in SFBAudioEngine.
120120

121121
Encoders don't support arbitrary input formats. The processing format used by an encoder is derived from a desired format combined with the encoder's settings.
122122

Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,11 @@ - (BOOL)openReturningError:(NSError **)error {
313313
AVAudioChannelLayout *channelLayout = nil;
314314

315315
if (_channelMask != 0) {
316-
if (__builtin_popcount(_channelMask) == _streamInfo.channels) {
316+
if (static_cast<uint32_t>(__builtin_popcount(_channelMask)) == _streamInfo.channels) {
317317
channelLayout = channelLayoutFromWAVEMask(_channelMask);
318318
} else {
319-
os_log_error(gSFBAudioDecoderLog, "Ignoring invalid channel mask 0x%x (%d channels) for %u-channel stream", _channelMask, __builtin_popcount(_channelMask), _streamInfo.channels);
319+
os_log_error(gSFBAudioDecoderLog, "Ignoring invalid channel mask 0x%x (%d channels) for %u-channel stream",
320+
_channelMask, __builtin_popcount(_channelMask), _streamInfo.channels);
320321
}
321322
}
322323

@@ -618,14 +619,16 @@ - (void)handleFLACMetadata:(const FLAC__StreamDecoder *)decoder metadata:(const
618619
const char *prefix = "WAVEFORMATEXTENSIBLE_CHANNEL_MASK=";
619620
constexpr auto prefixLength = 34;
620621
constexpr auto minValidLength = prefixLength + 2 + 1 /* '0xN' */;
621-
if (comment.length >= minValidLength && comment.entry[0] == prefix[0] && memcmp(comment.entry, prefix, prefixLength) == 0) {
622+
if (comment.length >= minValidLength && comment.entry[0] == prefix[0] &&
623+
memcmp(comment.entry, prefix, prefixLength) == 0) {
622624
if (_channelMask != 0) {
623625
os_log_debug(gSFBAudioDecoderLog, "Multiple WAVEFORMATEXTENSIBLE_CHANNEL_MASK Vorbis comments");
624626
}
625627
const char *value = reinterpret_cast<const char *>(comment.entry) + prefixLength;
626628
_channelMask = static_cast<uint32_t>(std::strtoul(value, nullptr, 16));
627629
if (_channelMask == 0 || _channelMask > 0x3FFFF) {
628-
os_log_error(gSFBAudioDecoderLog, "Invalid value \"%{public}s\" for WAVEFORMATEXTENSIBLE_CHANNEL_MASK", value);
630+
os_log_error(gSFBAudioDecoderLog,
631+
"Invalid value \"%{public}s\" for WAVEFORMATEXTENSIBLE_CHANNEL_MASK", value);
629632
_channelMask = 0;
630633
}
631634
}

Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ - (BOOL)openReturningError:(NSError **)error {
238238

239239
AudioChannelLayoutTag tag = 0;
240240
UInt32 propertySize = sizeof(tag);
241-
OSStatus result = AudioFormatGetProperty(kAudioFormatProperty_TagForChannelLayout, sizeof(layout), &layout,
241+
OSStatus status = AudioFormatGetProperty(kAudioFormatProperty_TagForChannelLayout, sizeof layout, &layout,
242242
&propertySize, &tag);
243-
if (result == noErr) {
243+
if (status == noErr) {
244244
channelLayout = [[AVAudioChannelLayout alloc] initWithLayoutTag:tag];
245245
} else {
246246
channelLayout = [AVAudioChannelLayout layoutWithLayout:&layout];

Sources/CSFBAudioEngine/Encoders/SFBAudioEncoder+Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern os_log_t gSFBAudioEncoderLog;
1515

1616
@interface SFBAudioEncoder () {
1717
@package
18-
SFBOutputSource *_outputSource;
18+
SFBOutputTarget *_outputTarget;
1919
AVAudioFormat *_sourceFormat;
2020
AVAudioFormat *_processingFormat;
2121
AVAudioFormat *_outputFormat;

Sources/CSFBAudioEngine/Encoders/SFBAudioEncoder.m

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface SFBAudioEncoderSubclassInfo : NSObject
2929

3030
@implementation SFBAudioEncoder
3131

32-
@synthesize outputSource = _outputSource;
32+
@synthesize outputTarget = _outputTarget;
3333
@synthesize sourceFormat = _sourceFormat;
3434
@synthesize processingFormat = _processingFormat;
3535
@synthesize outputFormat = _outputFormat;
@@ -126,27 +126,27 @@ - (instancetype)initWithURL:(NSURL *)url error:(NSError **)error {
126126
- (instancetype)initWithURL:(NSURL *)url mimeType:(NSString *)mimeType error:(NSError **)error {
127127
NSParameterAssert(url != nil);
128128

129-
SFBOutputSource *outputSource = [SFBOutputSource outputSourceForURL:url error:error];
130-
if (!outputSource) {
129+
SFBOutputTarget *outputTarget = [SFBOutputTarget outputTargetForURL:url error:error];
130+
if (!outputTarget) {
131131
return nil;
132132
}
133-
return [self initWithOutputSource:outputSource mimeType:mimeType error:error];
133+
return [self initWithOutputTarget:outputTarget mimeType:mimeType error:error];
134134
}
135135

136-
- (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource {
137-
return [self initWithOutputSource:outputSource mimeType:nil error:nil];
136+
- (instancetype)initWithOutputTarget:(SFBOutputTarget *)outputTarget {
137+
return [self initWithOutputTarget:outputTarget mimeType:nil error:nil];
138138
}
139139

140-
- (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource error:(NSError **)error {
141-
return [self initWithOutputSource:outputSource mimeType:nil error:error];
140+
- (instancetype)initWithOutputTarget:(SFBOutputTarget *)outputTarget error:(NSError **)error {
141+
return [self initWithOutputTarget:outputTarget mimeType:nil error:error];
142142
}
143143

144-
- (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource
144+
- (instancetype)initWithOutputTarget:(SFBOutputTarget *)outputTarget
145145
mimeType:(NSString *)mimeType
146146
error:(NSError **)error {
147-
NSParameterAssert(outputSource != nil);
147+
NSParameterAssert(outputTarget != nil);
148148

149-
NSString *lowercaseExtension = outputSource.url.pathExtension.lowercaseString;
149+
NSString *lowercaseExtension = outputTarget.url.pathExtension.lowercaseString;
150150
NSString *lowercaseMIMEType = mimeType.lowercaseString;
151151

152152
int score = 10;
@@ -177,20 +177,20 @@ - (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource
177177
}
178178

179179
if (!subclass) {
180-
os_log_debug(gSFBAudioEncoderLog, "Unable to determine content type for %{public}@", outputSource);
180+
os_log_debug(gSFBAudioEncoderLog, "Unable to determine content type for %{public}@", outputTarget);
181181
if (error) {
182182
NSMutableDictionary *userInfo = [NSMutableDictionary
183183
dictionaryWithObject:
184184
NSLocalizedString(@"The file's extension may be missing or may not match the file's type.",
185185
@"")
186186
forKey:NSLocalizedRecoverySuggestionErrorKey];
187187

188-
if (outputSource.url) {
188+
if (outputTarget.url) {
189189
userInfo[NSLocalizedDescriptionKey] = [NSString
190190
localizedStringWithFormat:NSLocalizedString(
191191
@"The type of the file “%@” could not be determined.", @""),
192-
SFBLocalizedNameForURL(outputSource.url)];
193-
userInfo[NSURLErrorKey] = outputSource.url;
192+
SFBLocalizedNameForURL(outputTarget.url)];
193+
userInfo[NSURLErrorKey] = outputTarget.url;
194194
} else {
195195
userInfo[NSLocalizedDescriptionKey] =
196196
NSLocalizedString(@"The type of the file could not be determined.", @"");
@@ -204,7 +204,7 @@ - (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource
204204
}
205205

206206
if ((self = [[subclass alloc] init])) {
207-
_outputSource = outputSource;
207+
_outputTarget = outputTarget;
208208
os_log_debug(gSFBAudioEncoderLog, "Created %{public}@ based on score of %i", self, score);
209209
}
210210

@@ -218,21 +218,21 @@ - (instancetype)initWithURL:(NSURL *)url encoderName:(SFBAudioEncoderName)encode
218218
- (instancetype)initWithURL:(NSURL *)url encoderName:(SFBAudioEncoderName)encoderName error:(NSError **)error {
219219
NSParameterAssert(url != nil);
220220

221-
SFBOutputSource *outputSource = [SFBOutputSource outputSourceForURL:url error:error];
222-
if (!outputSource) {
221+
SFBOutputTarget *outputTarget = [SFBOutputTarget outputTargetForURL:url error:error];
222+
if (!outputTarget) {
223223
return nil;
224224
}
225-
return [self initWithOutputSource:outputSource encoderName:encoderName error:error];
225+
return [self initWithOutputTarget:outputTarget encoderName:encoderName error:error];
226226
}
227227

228-
- (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource encoderName:(SFBAudioEncoderName)encoderName {
229-
return [self initWithOutputSource:outputSource encoderName:encoderName error:nil];
228+
- (instancetype)initWithOutputTarget:(SFBOutputTarget *)outputTarget encoderName:(SFBAudioEncoderName)encoderName {
229+
return [self initWithOutputTarget:outputTarget encoderName:encoderName error:nil];
230230
}
231231

232-
- (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource
232+
- (instancetype)initWithOutputTarget:(SFBOutputTarget *)outputTarget
233233
encoderName:(SFBAudioEncoderName)encoderName
234234
error:(NSError **)error {
235-
NSParameterAssert(outputSource != nil);
235+
NSParameterAssert(outputTarget != nil);
236236

237237
Class subclass = nil;
238238
for (SFBAudioEncoderSubclassInfo *subclassInfo in _registeredSubclasses) {
@@ -254,7 +254,7 @@ - (instancetype)initWithOutputSource:(SFBOutputSource *)outputSource
254254
}
255255

256256
if ((self = [[subclass alloc] init])) {
257-
_outputSource = outputSource;
257+
_outputTarget = outputTarget;
258258
}
259259

260260
return self;
@@ -302,8 +302,8 @@ - (BOOL)setSourceFormat:(AVAudioFormat *)sourceFormat error:(NSError **)error {
302302
}
303303

304304
- (BOOL)openReturningError:(NSError **)error {
305-
if (!_outputSource.isOpen) {
306-
return [_outputSource openReturningError:error];
305+
if (!_outputTarget.isOpen) {
306+
return [_outputTarget openReturningError:error];
307307
}
308308
return YES;
309309
}
@@ -313,8 +313,8 @@ - (BOOL)closeReturningError:(NSError **)error {
313313
_processingFormat = nil;
314314
_outputFormat = nil;
315315
_settings = nil;
316-
if (_outputSource.isOpen) {
317-
return [_outputSource closeReturningError:error];
316+
if (_outputTarget.isOpen) {
317+
return [_outputTarget closeReturningError:error];
318318
}
319319
return YES;
320320
}

0 commit comments

Comments
 (0)