aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-11-11 13:14:02 -0800
committerChris Robinson <[email protected]>2016-11-11 13:14:02 -0800
commite69af7ab9256507145fdababd092396e85deb651 (patch)
treef3d383ecf59b1b606e14bea89d509b0a1ebf7453
parent9ef7719734505d04d093ee85fb39b4777816d6ed (diff)
Fixes for embedded HRTFs on OSX
Use an empty source file to build a stub object file, instead of /dev/null. Use _mh_dylib_header to retrieve the data on 10.7+, instead of _mh_execute_header. And shorten the names to fit in the 16-character limit. Thanks to Anna Cheremnykh for the fixes!
-rw-r--r--Alc/hrtf.c11
-rw-r--r--CMakeLists.txt8
2 files changed, 11 insertions, 8 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index ba7ad068..b3b795ac 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -912,22 +912,23 @@ static const ALubyte *GetResource(int name, size_t *size)
#include <Availability.h>
#include <mach-o/getsect.h>
+#include <mach-o/ldsyms.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
+ /* NOTE: OSX 10.7 and up need to call getsectiondata(&_mh_dylib_header, ...). However, that
* call requires 10.7.
*/
if(name == IDR_DEFAULT_44100_MHR)
- return getsectiondata(&_mh_execute_header, "binary", "default_44100_mhr", size);
+ return getsectiondata(&_mh_dylib_header, "binary", "default_44100", size);
if(name == IDR_DEFAULT_48000_MHR)
- return getsectiondata(&_mh_execute_header, "binary", "default_48000_mhr", size);
+ return getsectiondata(&_mh_dylib_header, "binary", "default_48000", size);
#else
if(name == IDR_DEFAULT_44100_MHR)
- return getsectdata("binary", "default_44100_mhr", size);
+ return getsectdata("binary", "default_44100", size);
if(name == IDR_DEFAULT_48000_MHR)
- return getsectdata("binary", "default_48000_mhr", size);
+ return getsectdata("binary", "default_48000", size);
#endif
*size = 0;
return NULL;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6e5f0f6..7cd3ca36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1111,19 +1111,21 @@ if(ALSOFT_EMBED_HRTF_DATA)
elseif(APPLE)
macro(add_custom_binary FILENAME BIN_NAME)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
+ set(stubsrcfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub.c)
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 touch "${stubsrcfile}"
+ COMMAND "${CMAKE_C_COMPILER}" -o "${stubfile}" -c "${stubsrcfile}"
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")
+ add_custom_binary(default-44100.mhr "default_44100")
+ add_custom_binary(default-48000.mhr "default_48000")
else()
set(FILENAMES default-44100.mhr default-48000.mhr)
foreach(FILENAME ${FILENAMES})