From 60bd665e74cfeeaf70882173a0dd56c883e2014a Mon Sep 17 00:00:00 2001
From: "Suren A. Chilingaryan" <csa@suren.me>
Date: Fri, 12 Mar 2021 03:55:34 +0100
Subject: Added to git tree

---
 fixes/mac-fixes/README                         | 41 ++++++++++++++++++++++++++
 fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch | 12 ++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 fixes/mac-fixes/README
 create mode 100644 fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch

(limited to 'fixes/mac-fixes')

diff --git a/fixes/mac-fixes/README b/fixes/mac-fixes/README
new file mode 100644
index 0000000..072233e
--- /dev/null
+++ b/fixes/mac-fixes/README
@@ -0,0 +1,41 @@
+mac is unsupported port for  Monkey Audio Loseless Codec (ape) Acutally, it is
+known for lot of problems on 64bit platforms. Here is patch fixing another one.
+
+
+Some description for future use
+===============================
+ The problems is actully related to converting pointers to/from int type. 
+The portability requires intptr_t to be used for that purposes. However,
+in many places 'int' still specified. Therefore, if acutal pointer is 
+above int size on AMD64, the crashes occurs.
+
+It looks new/malloc on my Gentoo system in the beginning allocates  memory
+in the lower segments and everything goes smoothly. However, after a while
+the allocation from higher regions is started. This could be traced by
+monitoring the result of 
+    mac_info = (PlayerInfo *)g_malloc0(sizeof(PlayerInfo));
+    decompress = CreateIAPEDecompress(pUTF16, &nRetVal);
+in function 'decompress_init' of mac.cpp (xmms-mac). After few iterations they 
+would return high address ptr. Actually, the good method of accelerating 
+crashes, is usage of following code (within decompress_init):
+    
+    rep:
+    decompress = CreateIAPEDecompress(pUTF16, &nRetVal);
+    if (decompress < (void*)0x7FFFFFFF) {
+        void *a=malloc((int)1000*rand());
+        delete decompress;
+        free(a);
+        goto rep;
+    }
+
+Few notes on mac
+================
+MACLib.cpp	- C(stdcall) functions for class construction
+APEDecompress	- main working class which widly utilizes
+UnBitArray	- classes to work with actual data (many int usages within)
+  pIO 		- after a lot of black magick is initialiozed by function 
+		call:
+		    CAPEDecompress::GetInfo
+		which in his order calls:
+		    CAPEInfo::GetInfo
+
diff --git a/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch b/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch
new file mode 100644
index 0000000..aba0379
--- /dev/null
+++ b/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch
@@ -0,0 +1,12 @@
+diff -dPNur mac-3.99-u4-b5-s4/src/MACLib/APEDecompress.cpp mac-3.99-u4-b5-s4-new/src/MACLib/APEDecompress.cpp
+--- mac-3.99-u4-b5-s4/src/MACLib/APEDecompress.cpp	2006-06-01 11:00:58.000000000 +0200
++++ mac-3.99-u4-b5-s4-new/src/MACLib/APEDecompress.cpp	2008-04-12 17:39:39.000000000 +0200
+@@ -369,7 +369,7 @@
+ *****************************************************************************************/
+ intptr_t CAPEDecompress::GetInfo(APE_DECOMPRESS_FIELDS Field, intptr_t nParam1, intptr_t nParam2)
+ {
+-    int nRetVal = 0;
++    intptr_t nRetVal = 0;
+     BOOL bHandled = TRUE;
+ 
+     switch (Field)
-- 
cgit v1.2.3