From 6b8d30038475d6c7f4efff7c3ca25384254400e0 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 22 Jan 2022 21:03:52 -0800 Subject: [PATCH] Opus input: Support switching gain modes based on player settings, since the Opus tag reader doesn't support Opus gain tags yet --- Plugins/Opus/Opus/OpusDecoder.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Plugins/Opus/Opus/OpusDecoder.m b/Plugins/Opus/Opus/OpusDecoder.m index 56684c710..42ee99d3f 100644 --- a/Plugins/Opus/Opus/OpusDecoder.m +++ b/Plugins/Opus/Opus/OpusDecoder.m @@ -89,6 +89,17 @@ opus_int64 sourceTell(void *_stream) seekable = op_seekable(opusRef); totalFrames = op_pcm_total(opusRef, -1); + + NSString * gainMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"volumeScaling"]; + BOOL isAlbum = [gainMode hasPrefix:@"albumGain"]; + BOOL isTrack = [gainMode hasPrefix:@"trackGain"]; + + if (isAlbum || isTrack) { + op_set_gain_offset(opusRef, isAlbum ? OP_HEADER_GAIN : OP_TRACK_GAIN, 0); + } + else { + op_set_gain_offset(opusRef, OP_ABSOLUTE_GAIN, 0); + } [self willChangeValueForKey:@"properties"]; [self didChangeValueForKey:@"properties"];