提交 d4f7f39c 编写于 作者: V vit9696

OpenCoreAudio: Added voice assistance support and language detect

上级 7001e935
...@@ -29,6 +29,7 @@ OpenCore Changelog ...@@ -29,6 +29,7 @@ OpenCore Changelog
- Fixed drivers starting with `#` not being skipped - Fixed drivers starting with `#` not being skipped
- Added audio support through AudioDxe with optional boot chime - Added audio support through AudioDxe with optional boot chime
- Added VoiceOver accessability support in boot.efi for 10.13+ - Added VoiceOver accessability support in boot.efi for 10.13+
- Added `PickerAudioAssist` option for audio assistance in picker
#### v0.5.5 #### v0.5.5
- Fixed CPU bus ratio calculation for Nehalem and Westmere - Fixed CPU bus ratio calculation for Nehalem and Westmere
......
...@@ -591,6 +591,8 @@ ...@@ -591,6 +591,8 @@
<true/> <true/>
<key>PickerAttributes</key> <key>PickerAttributes</key>
<integer>0</integer> <integer>0</integer>
<key>PickerAudioAssist</key>
<false/>
<key>PollAppleHotKeys</key> <key>PollAppleHotKeys</key>
<false/> <false/>
<key>ShowPicker</key> <key>ShowPicker</key>
......
...@@ -591,6 +591,8 @@ ...@@ -591,6 +591,8 @@
<true/> <true/>
<key>PickerAttributes</key> <key>PickerAttributes</key>
<integer>0</integer> <integer>0</integer>
<key>PickerAudioAssist</key>
<false/>
<key>PollAppleHotKeys</key> <key>PollAppleHotKeys</key>
<false/> <false/>
<key>ShowPicker</key> <key>ShowPicker</key>
......
...@@ -536,6 +536,7 @@ OcMiscBoot ( ...@@ -536,6 +536,7 @@ OcMiscBoot (
Context->AllCustomEntryCount = EntryIndex; Context->AllCustomEntryCount = EntryIndex;
Context->PollAppleHotKeys = Config->Misc.Boot.PollAppleHotKeys; Context->PollAppleHotKeys = Config->Misc.Boot.PollAppleHotKeys;
Context->HideAuxiliary = Config->Misc.Boot.HideAuxiliary; Context->HideAuxiliary = Config->Misc.Boot.HideAuxiliary;
Context->PickerAudioAssist = Config->Misc.Boot.PickerAudioAssist;
OcLoadPickerHotKeys (Context); OcLoadPickerHotKeys (Context);
......
...@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ...@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <OpenCore.h> #include <OpenCore.h>
#include <Guid/AppleVariable.h>
#include <Guid/OcVariables.h> #include <Guid/OcVariables.h>
#include <Guid/GlobalVariable.h> #include <Guid/GlobalVariable.h>
...@@ -49,6 +50,19 @@ STATIC ...@@ -49,6 +50,19 @@ STATIC
OC_AUDIO_PROTOCOL * OC_AUDIO_PROTOCOL *
mOcAudio; mOcAudio;
typedef struct OC_AUDIO_FILE_ {
UINT8 *Buffer;
UINT32 Size;
} OC_AUDIO_FILE;
STATIC OC_AUDIO_FILE mAppleAudioFiles[AppleVoiceOverAudioFileMax];
STATIC OC_AUDIO_FILE mOcAudioFiles[OcVoiceOverAudioFileMax - OcVoiceOverAudioFileBase];
//
// Note, currently we are not I/O bound, so enabling this has no effect at all.
// Reconsider it when we resolve lags with AudioDxe.
//
STATIC BOOLEAN mEnableAudioCaching = FALSE;
STATIC STATIC
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
...@@ -60,58 +74,176 @@ OcAudioAcquireFile ( ...@@ -60,58 +74,176 @@ OcAudioAcquireFile (
OUT UINT32 *BufferSize OUT UINT32 *BufferSize
) )
{ {
CHAR8 IndexPath[8];
CHAR16 FilePath[96]; CHAR16 FilePath[96];
OC_STORAGE_CONTEXT *Storage; OC_STORAGE_CONTEXT *Storage;
CONST CHAR8 *BaseType; CONST CHAR8 *BaseType;
CONST CHAR8 *BasePath; CONST CHAR8 *BasePath;
BOOLEAN Localised; BOOLEAN Localised;
OC_AUDIO_FILE *CacheFile;
Storage = (OC_STORAGE_CONTEXT *) Context; Storage = (OC_STORAGE_CONTEXT *) Context;
Localised = TRUE; Localised = TRUE;
BaseType = "AXEFIAudio"; CacheFile = NULL;
switch (File) { if (File >= OcVoiceOverAudioFileBase && File < OcVoiceOverAudioFileMax) {
case AppleVoiceOverAudioFileVoiceOverOn: if (mEnableAudioCaching) {
BasePath = "VoiceOverOn"; CacheFile = &mOcAudioFiles[File - OcVoiceOverAudioFileBase];
break; if (CacheFile->Buffer != NULL) {
case AppleVoiceOverAudioFileVoiceOverOff: *Buffer = CacheFile->Buffer;
BasePath = "VoiceOverOff"; *BufferSize = CacheFile->Size;
break; return EFI_SUCCESS;
case AppleVoiceOverAudioFileUsername: }
BasePath = "Username"; }
break;
case AppleVoiceOverAudioFilePassword: BaseType = "OCEFIAudio";
BasePath = "Password"; if (File > OcVoiceOverAudioFileIndexBase && File <= OcVoiceOverAudioFileIndexMax) {
break; AsciiSPrint (
case AppleVoiceOverAudioFileUsernameOrPasswordIncorrect: IndexPath,
BasePath = "UsernameOrPasswordIncorrect"; sizeof (IndexPath),
break; "%a%c",
case AppleVoiceOverAudioFileAccountLockedTryLater: File >= OcVoiceOverAudioFileIndexAlphabetical ? "Letter" : "",
BasePath = "AccountLockedTryLater"; "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[File - OcVoiceOverAudioFileIndexBase]
break; );
case AppleVoiceOverAudioFileAccountLocked: BasePath = IndexPath;
BasePath = "AccountLocked"; if (File >= OcVoiceOverAudioFileIndexAlphabetical) {
break; Localised = FALSE;
case AppleVoiceOverAudioFileVoiceOverBoot: }
BaseType = "OCEFIAudio"; } else {
BasePath = "VoiceOver_Boot"; switch (File) {
Localised = FALSE; case OcVoiceOverAudioFileAbortTimeout:
break; BasePath = "AbortTimeout";
case AppleVoiceOverAudioFileVoiceOverBoot2: break;
BasePath = "VoiceOver_Boot"; case OcVoiceOverAudioFileChooseOS:
Localised = FALSE; BasePath = "ChooseOS";
break; break;
case AppleVoiceOverAudioFileClick: case OcVoiceOverAudioFileDefault:
BasePath = "Click"; BasePath = "Default";
Localised = FALSE; break;
break; case OcVoiceOverAudioFileDiskImage:
case AppleVoiceOverAudioFileBeep: BasePath = "DiskImage";
BasePath = "Beep"; break;
Localised = FALSE; case OcVoiceOverAudioFileEnterPassword:
break; BasePath = "EnterPassword";
default: break;
BasePath = NULL; case OcVoiceOverAudioFileExecutionFailure:
break; BasePath = "ExecutionFailure";
break;
case OcVoiceOverAudioFileExecutionSuccessful:
BasePath = "ExecutionSuccessful";
break;
case OcVoiceOverAudioFileExternal:
BasePath = "External";
break;
case OcVoiceOverAudioFileExternalOption:
BasePath = "ExternalOption";
break;
case OcVoiceOverAudioFileLoading:
BasePath = "Loading";
break;
case OcVoiceOverAudioFilemacOS:
BasePath = "macOS";
break;
case OcVoiceOverAudioFilemacOS_Recovery:
BasePath = "macOS_Recovery";
break;
case OcVoiceOverAudioFileOtherOS:
BasePath = "OtherOS";
break;
case OcVoiceOverAudioFilePasswordAccepted:
BasePath = "PasswordAccepted";
break;
case OcVoiceOverAudioFilePasswordIncorrect:
BasePath = "PasswordIncorrect";
break;
case OcVoiceOverAudioFilePasswordRetryLimit:
BasePath = "PasswordRetryLimit";
break;
case OcVoiceOverAudioFileReloading:
BasePath = "Reloading";
break;
case OcVoiceOverAudioFileResetNVRAM:
BasePath = "ResetNVRAM";
break;
case OcVoiceOverAudioFileSelected:
BasePath = "Selected";
break;
case OcVoiceOverAudioFileShowAuxiliary:
BasePath = "ShowAuxiliary";
break;
case OcVoiceOverAudioFileTimeout:
BasePath = "Timeout";
break;
case OcVoiceOverAudioFileUEFI_Shell:
BasePath = "UEFI_Shell";
break;
case OcVoiceOverAudioFileWelcome:
BasePath = "Welcome";
break;
case OcVoiceOverAudioFileWindows:
BasePath = "Windows";
break;
default:
BasePath = NULL;
break;
}
}
} else if (File < AppleVoiceOverAudioFileMax) {
if (mEnableAudioCaching) {
CacheFile = &mAppleAudioFiles[File];
if (CacheFile->Buffer != NULL) {
*Buffer = CacheFile->Buffer;
*BufferSize = CacheFile->Size;
return EFI_SUCCESS;
}
}
BaseType = "AXEFIAudio";
switch (File) {
case AppleVoiceOverAudioFileVoiceOverOn:
BasePath = "VoiceOverOn";
break;
case AppleVoiceOverAudioFileVoiceOverOff:
BasePath = "VoiceOverOff";
break;
case AppleVoiceOverAudioFileUsername:
BasePath = "Username";
break;
case AppleVoiceOverAudioFilePassword:
BasePath = "Password";
break;
case AppleVoiceOverAudioFileUsernameOrPasswordIncorrect:
BasePath = "UsernameOrPasswordIncorrect";
break;
case AppleVoiceOverAudioFileAccountLockedTryLater:
BasePath = "AccountLockedTryLater";
break;
case AppleVoiceOverAudioFileAccountLocked:
BasePath = "AccountLocked";
break;
case AppleVoiceOverAudioFileVoiceOverBoot:
BaseType = "OCEFIAudio";
BasePath = "VoiceOver_Boot";
Localised = FALSE;
break;
case AppleVoiceOverAudioFileVoiceOverBoot2:
BasePath = "VoiceOver_Boot";
Localised = FALSE;
break;
case AppleVoiceOverAudioFileClick:
BasePath = "Click";
Localised = FALSE;
break;
case AppleVoiceOverAudioFileBeep:
BasePath = "Beep";
Localised = FALSE;
break;
default:
BasePath = NULL;
break;
}
} else {
BasePath = NULL;
} }
if (BasePath == NULL) { if (BasePath == NULL) {
...@@ -165,6 +297,11 @@ OcAudioAcquireFile ( ...@@ -165,6 +297,11 @@ OcAudioAcquireFile (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (CacheFile != NULL) {
CacheFile->Buffer = *Buffer;
CacheFile->Size = *BufferSize;
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
...@@ -176,7 +313,9 @@ OcAudioReleaseFile ( ...@@ -176,7 +313,9 @@ OcAudioReleaseFile (
IN UINT8 *Buffer IN UINT8 *Buffer
) )
{ {
FreePool (Buffer); if (!mEnableAudioCaching) {
FreePool (Buffer);
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
...@@ -186,13 +325,13 @@ OcLoadUefiAudioSupport ( ...@@ -186,13 +325,13 @@ OcLoadUefiAudioSupport (
IN OC_GLOBAL_CONFIG *Config IN OC_GLOBAL_CONFIG *Config
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
CHAR8 *AsciiDevicePath; CHAR8 *AsciiDevicePath;
CHAR16 *UnicodeDevicePath; CHAR16 *UnicodeDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
OC_AUDIO_PROTOCOL *OcAudio; OC_AUDIO_PROTOCOL *OcAudio;
UINT8 VolumeLevel; UINT8 VolumeLevel;
BOOLEAN Muted; BOOLEAN Muted;
if (!Config->Uefi.Audio.AudioSupport) { if (!Config->Uefi.Audio.AudioSupport) {
DEBUG ((DEBUG_INFO, "OC: Requested not to use audio\n")); DEBUG ((DEBUG_INFO, "OC: Requested not to use audio\n"));
...@@ -252,6 +391,8 @@ OcLoadUefiAudioSupport ( ...@@ -252,6 +391,8 @@ OcLoadUefiAudioSupport (
return FALSE; return FALSE;
} }
OcSetVoiceOverLanguage (NULL);
if (Config->Uefi.Audio.PlayChime && VolumeLevel > 0 && !Muted) { if (Config->Uefi.Audio.PlayChime && VolumeLevel > 0 && !Muted) {
DEBUG ((DEBUG_INFO, "OC: Starting to play chime...\n")); DEBUG ((DEBUG_INFO, "OC: Starting to play chime...\n"));
Status = OcAudio->PlayFile ( Status = OcAudio->PlayFile (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册