Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix iOS 16 guard for intents and add EQ tap format logging

Barnabase000009d3570
diff --git a/ios/AbsorbPlayerCore/Sources/AbsorbPlayerCore/Intents.swift b/ios/AbsorbPlayerCore/Sources/AbsorbPlayerCore/Intents.swift
index 272f8e6c..07793a1c 100644
--- a/ios/AbsorbPlayerCore/Sources/AbsorbPlayerCore/Intents.swift
+++ b/ios/AbsorbPlayerCore/Sources/AbsorbPlayerCore/Intents.swift
@@ -48,7 +48,12 @@ public func activateAbsorbAudioSession() {
// same Swift type. AppDependencyManager.shared.add() in the host app is
// keyed by Swift type identity, and types declared only in the widget
// extension target wouldn't match anything the host app registered.
+//
+// Each intent is marked iOS 16+ since AppIntents itself is iOS 16+.
+// Runner deploys back to iOS 15; the widget extension is iOS 17. Runner
+// guards its use of these symbols with `if #available(iOS 16, *)`.
+@available(iOS 16.0, *)
public struct AbsorbSkipBackIntent: AudioPlaybackIntent {
public static let title: LocalizedStringResource = "Skip Back"
public static let description = IntentDescription("Skip backward in the current audiobook.")
@@ -70,6 +75,7 @@ public struct AbsorbSkipBackIntent: AudioPlaybackIntent {
}
}
+@available(iOS 16.0, *)
public struct AbsorbPlayPauseIntent: AudioPlaybackIntent {
public static let title: LocalizedStringResource = "Play or Pause"
public static let description = IntentDescription("Toggle audiobook playback.")
@@ -93,6 +99,7 @@ public struct AbsorbPlayPauseIntent: AudioPlaybackIntent {
}
}
+@available(iOS 16.0, *)
public struct AbsorbSkipForwardIntent: AudioPlaybackIntent {
public static let title: LocalizedStringResource = "Skip Forward"
public static let description = IntentDescription("Skip forward in the current audiobook.")
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 2d9255ce..16772997 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -53,6 +53,16 @@ let flutterEngine = FlutterEngine(name: "SharedEngine", project: nil, allowHeadl
}
}
+ // Same routing for the EQ tap's format diagnostics, so when a user
+ // reports "EQ on, this book has no sound" we can see the post-decode
+ // PCM format the tap actually received (low-bitrate AAC m4b often
+ // shows up here as mono / unusual sample rate).
+ AudioEQProcessor.setFormatLogger { [weak self] line in
+ DispatchQueue.main.async {
+ self?.widgetChannel?.invokeMethod("log", arguments: ["msg": line])
+ }
+ }
+
// Register the native player core as an AppIntent dependency. The widget
// intent declares `@Dependency var core: AbsorbPlayerCoreProtocol` - that
// signals to iOS to launch this host app process to run the intent's
diff --git a/packages/just_audio/darwin/just_audio/Sources/just_audio/AudioEQProcessor.m b/packages/just_audio/darwin/just_audio/Sources/just_audio/AudioEQProcessor.m
index 91044201..0af71cdc 100644
--- a/packages/just_audio/darwin/just_audio/Sources/just_audio/AudioEQProcessor.m
+++ b/packages/just_audio/darwin/just_audio/Sources/just_audio/AudioEQProcessor.m
@@ -142,6 +142,11 @@ static void tapFinalize(MTAudioProcessingTapRef tap) {
if (ctx) free(ctx);
}
+// Diagnostics callback set by AppDelegate so format info from tapPrepare
+// can land in absorb's in-app log via the Flutter widget channel. NSLog
+// alone only shows in Xcode/Console.app on a Mac.
+static void (^sFormatLogger)(NSString *) = NULL;
+
static void tapPrepare(MTAudioProcessingTapRef tap,
CMItemCount maxFrames,
const AudioStreamBasicDescription *processingFormat) {
@@ -150,7 +155,11 @@ static void tapPrepare(MTAudioProcessingTapRef tap,
ctx->sampleRate = (float)processingFormat->mSampleRate;
ctx->numChannels = (int)processingFormat->mChannelsPerFrame;
- if (ctx->numChannels > MAX_CHANNELS) ctx->numChannels = MAX_CHANNELS;
+ int truncated = 0;
+ if (ctx->numChannels > MAX_CHANNELS) {
+ truncated = ctx->numChannels;
+ ctx->numChannels = MAX_CHANNELS;
+ }
// Zero delay lines
memset(ctx->delays, 0, sizeof(ctx->delays));
@@ -158,6 +167,43 @@ static void tapPrepare(MTAudioProcessingTapRef tap,
// Build initial coefficients
rebuildCoefficients(ctx);
+
+ // Diagnostics: dump the audio format so we can correlate "tap enabled
+ // produces silence" reports to specific format fingerprints (e.g. low
+ // bitrate AAC at 22050Hz mono). Format is the post-decode PCM the tap
+ // actually receives, not the source file's compressed format.
+ int enabled = atomic_load_explicit(&sParams.enabled, memory_order_relaxed);
+ UInt32 fmtID = processingFormat->mFormatID;
+ char fmtIDChars[5] = {
+ (char)((fmtID >> 24) & 0xff),
+ (char)((fmtID >> 16) & 0xff),
+ (char)((fmtID >> 8) & 0xff),
+ (char)(fmtID & 0xff),
+ 0
+ };
+ UInt32 flags = processingFormat->mFormatFlags;
+ NSString *line = [NSString stringWithFormat:
+ @"[EQDiag] tapPrepare enabled=%d sampleRate=%.1f channels=%u (truncated_from=%d) "
+ @"formatID='%s' flags=0x%x [%s%s%s%s%s%s] bitsPerChannel=%u "
+ @"bytesPerFrame=%u framesPerPacket=%u maxFrames=%lld",
+ enabled,
+ processingFormat->mSampleRate,
+ (unsigned)processingFormat->mChannelsPerFrame,
+ truncated,
+ fmtIDChars,
+ (unsigned)flags,
+ (flags & 0x1) ? "Float " : "",
+ (flags & 0x2) ? "BigEndian " : "",
+ (flags & 0x4) ? "SignedInt " : "",
+ (flags & 0x8) ? "Packed " : "",
+ (flags & 0x10) ? "AlignedHigh " : "",
+ (flags & 0x20) ? "NonInterleaved" : "Interleaved",
+ (unsigned)processingFormat->mBitsPerChannel,
+ (unsigned)processingFormat->mBytesPerFrame,
+ (unsigned)processingFormat->mFramesPerPacket,
+ (long long)maxFrames];
+ NSLog(@"%@", line);
+ if (sFormatLogger) sFormatLogger(line);
}
static void tapUnprepare(MTAudioProcessingTapRef tap) {
diff --git a/packages/just_audio/darwin/just_audio/Sources/just_audio/include/just_audio/AudioEQProcessor.h b/packages/just_audio/darwin/just_audio/Sources/just_audio/include/just_audio/AudioEQProcessor.h
index 552f0531..dd76c2f3 100644
--- a/packages/just_audio/darwin/just_audio/Sources/just_audio/include/just_audio/AudioEQProcessor.h
+++ b/packages/just_audio/darwin/just_audio/Sources/just_audio/include/just_audio/AudioEQProcessor.h
@@ -30,6 +30,11 @@ NS_ASSUME_NONNULL_BEGIN
/// Enable mono downmix.
- (void)setMonoEnabled:(BOOL)enabled;
+/// Sets a callback that gets each `[EQDiag]` line emitted from
+/// tapPrepare so callers can route format info into their own logger
+/// (e.g. absorb's in-app log via the widget channel). Pass nil to clear.
++ (void)setFormatLogger:(nullable void (^)(NSString *line))logger;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/pubspec.yaml b/pubspec.yaml
index 0083d152..d7746558 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: absorb
description: An Audiobookshelf Client
publish_to: 'none'
-version: 1.8.78+107
+version: 1.8.78+108
environment:
sdk: '>=3.1.0 <4.0.0'