• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版196 (tree)
时间2020-06-24 23:51:57
作者toshinagata1964

Log Message

The app does not start on non-Japanese system. Hopefully fixed.

更改概述

差异

--- trunk/MD_package/MDAudio_MacOSX.c (revision 195)
+++ trunk/MD_package/MDAudio_MacOSX.c (revision 196)
@@ -621,8 +621,8 @@
621621 {
622622 AudioComponentDescription ccd, fcd;
623623 AudioComponent cmp = NULL;
624- const char *cName;
625- int len, n, i;
624+ char *cName;
625+ int n, i;
626626 UInt32 propSize;
627627 MDAudioMusicDeviceInfo info, *ip;
628628 MDArray **basep;
@@ -636,7 +636,7 @@
636636 return kMDErrorOutOfMemory;
637637 }
638638 }
639-
639+
640640 memset(&fcd, 0, sizeof(fcd));
641641 fcd.componentType = (music_or_effect ? kAudioUnitType_MusicDevice : kAudioUnitType_Effect);
642642 n = 0;
@@ -643,18 +643,30 @@
643643 while ((cmp = AudioComponentFindNext(cmp, &fcd)) != 0) {
644644 AudioUnit unit;
645645 CFStringRef nameRef;
646-
646+ CFIndex cflen;
647+
647648 /* Get the component information */
648- AudioComponentCopyName(cmp, &nameRef);
649- cName = CFStringGetCStringPtr(nameRef, kCFStringEncodingUTF8);
650- len = (int)strlen(cName);
651649 memset(&info, 0, sizeof(info));
652- AudioComponentGetDescription(cmp, &ccd);
653- info.code = (((UInt64)ccd.componentSubType) << 32) + ((UInt64)ccd.componentManufacturer);
654- info.name = strdup(cName);
650+ err = AudioComponentGetDescription(cmp, &ccd);
651+ if (err != noErr)
652+ continue; /* Cannot get valid description */
653+ info.code = (((UInt64)ccd.componentSubType) << 32) + ((UInt64)ccd.componentManufacturer);
655654
655+ /* Get the component name */
656+ err = AudioComponentCopyName(cmp, &nameRef);
657+ if (err != noErr)
658+ continue; /* Cannot get valid name */
659+ cflen = CFStringGetLength(nameRef);
660+ if (cflen == 0)
661+ continue; /* Empty device name */
662+ cName = malloc(cflen * 4 + 1);
663+ if (!CFStringGetCString(nameRef, cName, cflen * 4, kCFStringEncodingUTF8))
664+ continue; /* Cannot get valid name */
665+
666+ info.name = cName;
667+
656668 for (i = 0; (ip = MDArrayFetchPtr(*basep, i)) != NULL; i++) {
657- if (ip->code == info.code && strncmp(ip->name, cName, len) == 0) {
669+ if (ip->code == info.code && strncmp(ip->name, cName, cflen) == 0) {
658670 free(info.name);
659671 info.name = NULL;
660672 break;
Show on old repository browser