[Android Audio] Be able to turn audio on or off

This commit is contained in:
zilmar 2016-08-11 20:46:03 +10:00
parent a277fc0a60
commit a3fd417e27
2 changed files with 81 additions and 62 deletions

View File

@ -13,6 +13,14 @@
#include "trace.h"
#include "main.h"
short Set_EnableAudio = 0;
extern bool g_AudioEnabled;
void SettingsChanged(void *)
{
g_AudioEnabled = GetSystemSetting(Set_EnableAudio) != 0;
}
void SetupAudioSettings(void)
{
SetModuleName("AndroidAudio");
@ -29,4 +37,11 @@ void SetupAudioSettings (void)
g_ModuleLogLevel[TraceAudioInitShutdown] = GetSetting(Logging_LogAudioInitShutdown);
g_ModuleLogLevel[TraceAudioInterface] = GetSetting(Logging_LogAudioInterface);
Set_EnableAudio = FindSystemSettingId("Enable Audio");
if (Set_EnableAudio != 0)
{
SettingsRegisterChange(true, Set_EnableAudio, NULL, SettingsChanged);
g_AudioEnabled = GetSystemSetting(Set_EnableAudio) != 0;
}
}

View File

@ -36,6 +36,8 @@ typedef struct threadLock_
} threadLock;
#endif
bool g_AudioEnabled = true;
/* Read header for type definition */
AUDIO_INFO g_AudioInfo;
@ -204,7 +206,6 @@ static void CloseAudio(void)
WriteTrace(TraceAudioInitShutdown, TraceDebug, "Done");
}
static bool CreatePrimaryBuffer(void)
{
WriteTrace(TraceAudioInitShutdown, TraceDebug, "Start");
@ -636,7 +637,10 @@ EXPORT void CALL AiDacrateChanged(int SystemType)
EXPORT void CALL AiLenChanged(void)
{
WriteTrace(TraceAudioInterface, TraceDebug, "Start (DRAM_ADDR = 0x%X LenReg = 0x%X)", *g_AudioInfo.AI__LEN_REG, *g_AudioInfo.AI__DRAM_ADDR_REG);
if (!g_AudioEnabled)
{
return;
}
uint32_t LenReg = *g_AudioInfo.AI__LEN_REG;
uint8_t * p = g_AudioInfo.RDRAM + (*g_AudioInfo.AI__DRAM_ADDR_REG & 0xFFFFFF);