commit 79e4f7b5749f12866a3b63f460d3e51559f1e137
parent 252fc5e9896155c03e4e8642092589c9b7e4fec3
Author: Olav Sørensen <olav.sorensen@live.no>
Date: Thu, 1 Apr 2021 11:26:32 +0200
Merge branch 'master' of https://github.com/8bitbubsy/ft2-clone
Diffstat:
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/ft2_audioselector.c b/src/ft2_audioselector.c
@@ -24,6 +24,9 @@ char *getAudioOutputDeviceFromConfig(void)
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 @@ char *getAudioOutputDeviceFromConfig(void)
if (devStringLen > 0)
strncpy(devString, devStringTmp, MAX_DEV_STR_LEN);
devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination
+#endif
}
else
{
@@ -50,6 +54,11 @@ char *getAudioOutputDeviceFromConfig(void)
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);
}
diff --git a/src/ft2_diskop.c b/src/ft2_diskop.c
@@ -2106,7 +2106,7 @@ static void setDiskOpItem(uint8_t item)
}
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);