aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/hrtf.c25
-rw-r--r--CMakeLists.txt16
2 files changed, 41 insertions, 0 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 7786befc..ba7ad068 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -908,6 +908,31 @@ static const ALubyte *GetResource(int name, size_t *size)
return LockResource(res);
}
+#elif defined(__APPLE__)
+
+#include <Availability.h>
+#include <mach-o/getsect.h>
+
+static const ALubyte *GetResource(int name, size_t *size)
+{
+#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
+ /* NOTE: OSX 10.7 and up need to call getsectiondata(&_mh_execute_header, ...). However, that
+ * call requires 10.7.
+ */
+ if(name == IDR_DEFAULT_44100_MHR)
+ return getsectiondata(&_mh_execute_header, "binary", "default_44100_mhr", size);
+ if(name == IDR_DEFAULT_48000_MHR)
+ return getsectiondata(&_mh_execute_header, "binary", "default_48000_mhr", size);
+#else
+ if(name == IDR_DEFAULT_44100_MHR)
+ return getsectdata("binary", "default_44100_mhr", size);
+ if(name == IDR_DEFAULT_48000_MHR)
+ return getsectdata("binary", "default_48000_mhr", size);
+#endif
+ *size = 0;
+ return NULL;
+}
+
#else
extern const ALubyte _binary_default_44100_mhr_start[] HIDDEN_DECL;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e371bc3..e6e5f0f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1108,6 +1108,22 @@ option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library foot
if(ALSOFT_EMBED_HRTF_DATA)
if(WIN32)
set(ALC_OBJS ${ALC_OBJS} Alc/hrtf_res.rc)
+ elseif(APPLE)
+ macro(add_custom_binary FILENAME BIN_NAME)
+ set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
+ set(stubfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub${CMAKE_C_OUTPUT_EXTENSION})
+ add_custom_command(OUTPUT ${outfile}
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
+ COMMAND "${CMAKE_C_COMPILER}" -o "${stubfile}" -c /dev/null
+ COMMAND "${CMAKE_LINKER}" -r -o "${outfile}" -sectcreate binary ${BIN_NAME} ${FILENAME} "${stubfile}"
+ COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
+ VERBATIM
+ )
+ set(ALC_OBJS ${ALC_OBJS} ${outfile})
+ endmacro()
+ add_custom_binary(default-44100.mhr "default_44100_mhr")
+ add_custom_binary(default-48000.mhr "default_48000_mhr")
else()
set(FILENAMES default-44100.mhr default-48000.mhr)
foreach(FILENAME ${FILENAMES})