From 0d4ee4c901b4595f077a5785ae6ced6dbd1522d3 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 15 Feb 2022 22:55:34 -0800 Subject: [PATCH] VGMStream Input: Remove downmixing, add layout Downmixing should no longer be necessary, unless someone actually tries to emit up to 64 channels, while we support only 32 channels, but really only 18 channels. Also read the channel layout field from the decoder, so that the speaker layout will propagate from the files to the player. Signed-off-by: Christopher Snowhill --- Plugins/vgmstream/vgmstream/VGMDecoder.h | 1 + Plugins/vgmstream/vgmstream/VGMDecoder.m | 37 +++++++++++------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Plugins/vgmstream/vgmstream/VGMDecoder.h b/Plugins/vgmstream/vgmstream/VGMDecoder.h index 20931edbd..80009c741 100644 --- a/Plugins/vgmstream/vgmstream/VGMDecoder.h +++ b/Plugins/vgmstream/vgmstream/VGMDecoder.h @@ -32,6 +32,7 @@ BOOL canPlayForever; int sampleRate; int channels; + uint32_t channelConfig; int bitrate; long totalFrames; long framesRead; diff --git a/Plugins/vgmstream/vgmstream/VGMDecoder.m b/Plugins/vgmstream/vgmstream/VGMDecoder.m index a14d2ef6c..c5bc1247f 100644 --- a/Plugins/vgmstream/vgmstream/VGMDecoder.m +++ b/Plugins/vgmstream/vgmstream/VGMDecoder.m @@ -63,9 +63,7 @@ static NSString *get_description_tag(const char *description, const char *tag, c vgmstream_apply_config(stream, &vcfg); int output_channels = stream->channels; - - vgmstream_mixing_autodownmix(stream, 6); - vgmstream_mixing_enable(stream, MAX_BUFFER_SAMPLES, NULL, &output_channels); + uint32_t channelConfig = stream->channel_layout; int track_num = [[url fragment] intValue]; @@ -150,20 +148,21 @@ static NSString *get_description_tag(const char *description, const char *tag, c close_streamfile(tagFile); } - NSDictionary *properties = @{@"bitrate": [NSNumber numberWithInt:bitrate / 1000], - @"sampleRate": [NSNumber numberWithInt:sampleRate], - @"totalFrames": [NSNumber numberWithDouble:totalFrames], - @"bitsPerSample": [NSNumber numberWithInt:16], - @"floatingPoint": [NSNumber numberWithBool:NO], - @"channels": [NSNumber numberWithInt:channels], - @"seekable": [NSNumber numberWithBool:YES], - @"replayGainAlbumGain": rgAlbumGain, - @"replayGainAlbumPeak": rgAlbumPeak, - @"replayGainTrackGain": rgTrackGain, - @"replayGainTrackPeak": rgTrackPeak, - @"codec": codec, - @"endian": @"host", - @"encoding": @"lossy/lossless"}; + NSDictionary *properties = @{ @"bitrate": [NSNumber numberWithInt:bitrate / 1000], + @"sampleRate": [NSNumber numberWithInt:sampleRate], + @"totalFrames": [NSNumber numberWithDouble:totalFrames], + @"bitsPerSample": [NSNumber numberWithInt:16], + @"floatingPoint": [NSNumber numberWithBool:NO], + @"channels": [NSNumber numberWithInt:channels], + @"channelConfig": [NSNumber numberWithUnsignedInt:channelConfig], + @"seekable": [NSNumber numberWithBool:YES], + @"replayGainAlbumGain": rgAlbumGain, + @"replayGainAlbumPeak": rgAlbumPeak, + @"replayGainTrackGain": rgTrackGain, + @"replayGainTrackPeak": rgTrackPeak, + @"codec": codec, + @"endian": @"host", + @"encoding": @"lossy/lossless" }; if([title isEqualToString:@""]) { if(stream->num_streams > 1) { @@ -247,9 +246,7 @@ static NSString *get_description_tag(const char *description, const char *tag, c return NO; int output_channels = stream->channels; - - vgmstream_mixing_autodownmix(stream, 6); - vgmstream_mixing_enable(stream, MAX_BUFFER_SAMPLES, NULL, &output_channels); + channelConfig = stream->channel_layout; canPlayForever = stream->loop_flag; if(canPlayForever) {