File a991c13d0df734a5d0fea7db6b181176858f3e58.patch of Package aqualung
From a991c13d0df734a5d0fea7db6b181176858f3e58 Mon Sep 17 00:00:00 2001
From: Daniel Pielmeier <billie80@users.noreply.github.com>
Date: Mon, 14 Aug 2023 09:48:36 +0200
Subject: [PATCH] Add support for recent versions of Monkey's Audio
---
configure.ac | 10 ++++----
src/Makefile.am | 2 +-
src/decoder/dec_mac.cpp | 55 ++++++++++++++++++++++-------------------
3 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6d95a3f..7e46398 100644
--- a/configure.ac
+++ b/configure.ac
@@ -275,11 +275,11 @@ AQUALUNG_DETECT([lavc], [Libav / FFmpeg],
[AQUALUNG_FOUND([lavc])],
[AQUALUNG_MISSING([lavc], [$lavc_PKG_ERRORS])])])
-AQUALUNG_DETECT([mac], [Monkey's Audio Codec],
- [AC_CHECK_LIB([mac], [CreateIAPEDecompress],
- [AQUALUNG_FOUND([mac], [-lmac -lstdc++])],
- [AQUALUNG_MISSING([mac],
- [Monkey's Audio Codec support requires libmac])],
+AQUALUNG_DETECT([MAC], [Monkey's Audio Codec],
+ [AC_CHECK_LIB([MAC], [CreateIAPEDecompress],
+ [AQUALUNG_FOUND([MAC], [-lMAC -lstdc++])],
+ [AQUALUNG_MISSING([MAC],
+ [Monkey's Audio Codec support requires libMAC])],
[-lstdc++])])
AQUALUNG_DETECT([mod], [MOD Audio],
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c1afa2..940e243 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,7 +25,7 @@ aqualung_CFLAGS = $(xml_CFLAGS) $(gtk_CFLAGS) $(glib_CFLAGS) \
aqualung_LDADD = $(LDADD) $(xml_LIBS) $(gtk_LIBS) $(glib_LIBS) \
$(alsa_LIBS) $(jack_LIBS) $(oss_LIBS) $(pulse_LIBS) \
$(sndio_LIBS) $(winmm_LIBS) \
- $(flac_LIBS) $(lame_LIBS) $(lavc_LIBS) $(mac_LIBS) \
+ $(flac_LIBS) $(lame_LIBS) $(lavc_LIBS) $(MAC_LIBS) \
$(mad_LIBS) $(mod_LIBS) $(mpc_LIBS) $(sndfile_LIBS) \
$(speex_LIBS) $(vorbis_LIBS) $(vorbisenc_LIBS) \
$(wavpack_LIBS) \
diff --git a/src/decoder/dec_mac.cpp b/src/decoder/dec_mac.cpp
index c868ee9..b007f74 100644
--- a/src/decoder/dec_mac.cpp
+++ b/src/decoder/dec_mac.cpp
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <glib.h>
/* expand this to nothing so there's no error when including MACLib.h */
@@ -31,9 +32,9 @@
#define DLLEXPORT
#include "../undef_ac_pkg.h"
-#include <mac/All.h>
-#include <mac/MACLib.h>
-#include <mac/CharacterHelper.h>
+#include <MAC/All.h>
+#include <MAC/MACLib.h>
+#include <MAC/CharacterHelper.h>
#include "../undef_ac_pkg.h"
#include <config.h> /* re-establish undefined autoconf macros */
@@ -60,16 +61,16 @@ decode_mac(decoder_t * dec) {
mac_pdata_t * pd = (mac_pdata_t *)dec->pdata;
file_decoder_t * fdec = dec->fdec;
- IAPEDecompress * pdecompress = (IAPEDecompress *)pd->decompress;
+ APE::IAPEDecompress * pdecompress = (APE::IAPEDecompress *)pd->decompress;
- int act_read = 0;
+ APE::int64 act_read = 0;
unsigned long scale = 1 << (pd->bits_per_sample - 1);
float fbuf[2 * BLOCKS_PER_READ];
int n = 0;
switch (pd->bits_per_sample) {
case 8:
- char data8[2 * BLOCKS_PER_READ];
+ unsigned char data8[2 * BLOCKS_PER_READ];
pdecompress->GetData(data8, BLOCKS_PER_READ, &act_read);
if (!act_read) {
return 1;
@@ -84,7 +85,7 @@ decode_mac(decoder_t * dec) {
case 16:
short data16[2 * BLOCKS_PER_READ];
- pdecompress->GetData((char *)data16, BLOCKS_PER_READ, &act_read);
+ pdecompress->GetData((unsigned char *)data16, BLOCKS_PER_READ, &act_read);
if (!act_read) {
return 1;
}
@@ -100,7 +101,7 @@ decode_mac(decoder_t * dec) {
case 32:
int data32[2 * BLOCKS_PER_READ];
- pdecompress->GetData((char *)data32, BLOCKS_PER_READ, &act_read);
+ pdecompress->GetData((unsigned char *)data32, BLOCKS_PER_READ, &act_read);
if (!act_read) {
return 1;
}
@@ -170,31 +171,33 @@ mac_decoder_open(decoder_t * dec, char * filename) {
mac_pdata_t * pd = (mac_pdata_t *)dec->pdata;
file_decoder_t * fdec = dec->fdec;
metadata_t * meta;
- IAPEDecompress * pdecompress = (IAPEDecompress *)pd->decompress;
+ APE::IAPEDecompress * pdecompress = (APE::IAPEDecompress *)pd->decompress;
const char * comp_level = NULL;
int ret = 0;
#ifdef __OpenBSD__
wchar_t * pUTF16 = GetUTF16FromANSI(filename);
-#else
- wchar_t * pUTF16 = CAPECharacterHelper::GetUTF16FromANSI(filename);
-#endif
pdecompress = CreateIAPEDecompress(pUTF16, &ret);
free(pUTF16);
+#else
+ gunichar2 * pUTF16 = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL);
+ pdecompress = CreateIAPEDecompress((wchar_t *)pUTF16, &ret, FALSE, FALSE, FALSE);
+ g_free(pUTF16);
+#endif
if (!pdecompress || ret != ERROR_SUCCESS) {
return DECODER_OPEN_BADLIB;
}
pd->decompress = (void *)pdecompress;
- pd->sample_rate = pdecompress->GetInfo(APE_INFO_SAMPLE_RATE);
- pd->bits_per_sample = pdecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE);
- pd->bitrate = pdecompress->GetInfo(APE_DECOMPRESS_AVERAGE_BITRATE);
- pd->channels = pdecompress->GetInfo(APE_INFO_CHANNELS);
- pd->length_in_ms = pdecompress->GetInfo(APE_DECOMPRESS_LENGTH_MS);
- pd->block_align = pdecompress->GetInfo(APE_INFO_BLOCK_ALIGN);
- pd->compression_level = pdecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL);
+ pd->sample_rate = pdecompress->GetInfo(APE::IAPEDecompress::APE_INFO_SAMPLE_RATE);
+ pd->bits_per_sample = pdecompress->GetInfo(APE::IAPEDecompress::APE_INFO_BITS_PER_SAMPLE);
+ pd->bitrate = pdecompress->GetInfo(APE::IAPEDecompress::APE_DECOMPRESS_AVERAGE_BITRATE);
+ pd->channels = pdecompress->GetInfo(APE::IAPEDecompress::APE_INFO_CHANNELS);
+ pd->length_in_ms = pdecompress->GetInfo(APE::IAPEDecompress::APE_DECOMPRESS_LENGTH_MS);
+ pd->block_align = pdecompress->GetInfo(APE::IAPEDecompress::APE_INFO_BLOCK_ALIGN);
+ pd->compression_level = pdecompress->GetInfo(APE::IAPEDecompress::APE_INFO_COMPRESSION_LEVEL);
if ((pd->channels != 1) && (pd->channels != 2)) {
printf("Sorry, MAC file with %d channels is not supported.\n", pd->channels);
@@ -218,19 +221,19 @@ mac_decoder_open(decoder_t * dec, char * filename) {
fdec->file_lib = MAC_LIB;
switch (pd->compression_level) {
- case COMPRESSION_LEVEL_FAST:
+ case APE_COMPRESSION_LEVEL_FAST:
comp_level = _("Compression: Fast");
break;
- case COMPRESSION_LEVEL_NORMAL:
+ case APE_COMPRESSION_LEVEL_NORMAL:
comp_level = _("Compression: Normal");
break;
- case COMPRESSION_LEVEL_HIGH:
+ case APE_COMPRESSION_LEVEL_HIGH:
comp_level = _("Compression: High");
break;
- case COMPRESSION_LEVEL_EXTRA_HIGH:
+ case APE_COMPRESSION_LEVEL_EXTRA_HIGH:
comp_level = _("Compression: Extra High");
break;
- case COMPRESSION_LEVEL_INSANE:
+ case APE_COMPRESSION_LEVEL_INSANE:
comp_level = _("Compression: Insane");
break;
default:
@@ -255,7 +258,7 @@ void
mac_decoder_close(decoder_t * dec) {
mac_pdata_t * pd = (mac_pdata_t *)dec->pdata;
- IAPEDecompress * pdecompress = (IAPEDecompress *)pd->decompress;
+ APE::IAPEDecompress * pdecompress = (APE::IAPEDecompress *)pd->decompress;
delete(pdecompress);
rb_free(pd->rb);
@@ -294,7 +297,7 @@ mac_decoder_seek(decoder_t * dec, unsigned long long seek_to_pos) {
mac_pdata_t * pd = (mac_pdata_t *)dec->pdata;
file_decoder_t * fdec = dec->fdec;
- IAPEDecompress * pdecompress = (IAPEDecompress *)pd->decompress;
+ APE::IAPEDecompress * pdecompress = (APE::IAPEDecompress *)pd->decompress;
char flush_dest;
pdecompress->Seek(seek_to_pos);