shithub: ft²

Download patch

ref: 425cabffb10a4dad527cbbe7d97d76efbb36a04c
parent: fdfa2bc1a33b0e566fb6c2d6762475c67b7582bd
parent: 3c4a36a34df0c3f2a33a1a2330a7a34eefc43c6e
author: Olav Sørensen <[email protected]>
date: Thu Apr 1 07:25:51 EDT 2021

Merge pull request #20 from kode54/master

Minor quality of life improvements for macOS, now it works on Big Sur

--- a/src/ft2_audioselector.c
+++ b/src/ft2_audioselector.c
@@ -24,6 +24,9 @@
 	FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocation, "r");
 	if (f == NULL)
 	{
+#if defined(__APPLE__)
+		return NULL; // SDL doesn't return devices in any appreciable order, and device 0 is most certainly not guaranteed to be the current default device
+#else
 		const char *devStringTmp = SDL_GetAudioDeviceName(0, false);
 		if (devStringTmp == NULL)
 		{
@@ -35,6 +38,7 @@
 		if (devStringLen > 0)
 			strncpy(devString, devStringTmp, MAX_DEV_STR_LEN);
 		devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination
+#endif
 	}
 	else
 	{
@@ -49,6 +53,11 @@
 		if (devString[devStringLen-1] == '\n')
 			devString[devStringLen-1]  = '\0';
 		devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination
+
+#if defined(__APPLE__)
+		if (devString[0] == '\0')
+			return NULL; // macOS SDL2 locks up indefinitely if fed an empty string for device name
+#endif
 
 		fclose(f);
 	}
--- a/src/ft2_diskop.c
+++ b/src/ft2_diskop.c
@@ -2106,7 +2106,7 @@
 	}
 
 	const int32_t pathLen = (int32_t)UNICHAR_STRLEN(FReq_CurPathU);
-	if (pathLen == 0)
+	if (pathLen == 0 && FReq_ModCurPathU[0] != '\0')
 	{
 		memset(FReq_CurPathU, 0, (PATH_MAX + 2) * sizeof (UNICHAR));
 		UNICHAR_STRCPY(FReq_CurPathU, FReq_ModCurPathU);