mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-21 11:37:14 +01:00
AudioCommon: Clean up brace placements
This commit is contained in:
parent
ba4934b75e
commit
f94e764df5
@ -40,7 +40,8 @@ public:
|
|||||||
|
|
||||||
virtual void Stop() override;
|
virtual void Stop() override;
|
||||||
|
|
||||||
static bool isValid() {
|
static bool isValid()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ public:
|
|||||||
virtual void SoundLoop() override;
|
virtual void SoundLoop() override;
|
||||||
virtual void Stop() override;
|
virtual void Stop() override;
|
||||||
|
|
||||||
static bool isValid() {
|
static bool isValid()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,15 @@ bool CoreAudioSound::Start()
|
|||||||
desc.componentFlagsMask = 0;
|
desc.componentFlagsMask = 0;
|
||||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
component = FindNextComponent(nullptr, &desc);
|
component = FindNextComponent(nullptr, &desc);
|
||||||
if (component == nullptr) {
|
if (component == nullptr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error finding audio component");
|
ERROR_LOG(AUDIO, "error finding audio component");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = OpenAComponent(component, &audioUnit);
|
err = OpenAComponent(component, &audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error opening audio component");
|
ERROR_LOG(AUDIO, "error opening audio component");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -58,7 +60,8 @@ bool CoreAudioSound::Start()
|
|||||||
kAudioUnitProperty_StreamFormat,
|
kAudioUnitProperty_StreamFormat,
|
||||||
kAudioUnitScope_Input, 0, &format,
|
kAudioUnitScope_Input, 0, &format,
|
||||||
sizeof(AudioStreamBasicDescription));
|
sizeof(AudioStreamBasicDescription));
|
||||||
if (err != noErr) {
|
if (err != noErr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error setting audio format");
|
ERROR_LOG(AUDIO, "error setting audio format");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -69,12 +72,13 @@ bool CoreAudioSound::Start()
|
|||||||
kAudioUnitProperty_SetRenderCallback,
|
kAudioUnitProperty_SetRenderCallback,
|
||||||
kAudioUnitScope_Input, 0, &callback_struct,
|
kAudioUnitScope_Input, 0, &callback_struct,
|
||||||
sizeof callback_struct);
|
sizeof callback_struct);
|
||||||
if (err != noErr) {
|
if (err != noErr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error setting audio callback");
|
ERROR_LOG(AUDIO, "error setting audio callback");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = AudioUnitSetParameter(audioUnit,
|
err = AudioUnitSetParameter(audioUnit,
|
||||||
kHALOutputParam_Volume,
|
kHALOutputParam_Volume,
|
||||||
kAudioUnitParameterFlag_Output, 0,
|
kAudioUnitParameterFlag_Output, 0,
|
||||||
m_volume / 100., 0);
|
m_volume / 100., 0);
|
||||||
@ -82,13 +86,15 @@ bool CoreAudioSound::Start()
|
|||||||
ERROR_LOG(AUDIO, "error setting volume");
|
ERROR_LOG(AUDIO, "error setting volume");
|
||||||
|
|
||||||
err = AudioUnitInitialize(audioUnit);
|
err = AudioUnitInitialize(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error initializing audiounit");
|
ERROR_LOG(AUDIO, "error initializing audiounit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = AudioOutputUnitStart(audioUnit);
|
err = AudioOutputUnitStart(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr)
|
||||||
|
{
|
||||||
ERROR_LOG(AUDIO, "error starting audiounit");
|
ERROR_LOG(AUDIO, "error starting audiounit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,7 +105,7 @@ bool CoreAudioSound::Start()
|
|||||||
void CoreAudioSound::SetVolume(int volume)
|
void CoreAudioSound::SetVolume(int volume)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
m_volume = volume;
|
m_volume = volume;
|
||||||
|
|
||||||
err = AudioUnitSetParameter(audioUnit,
|
err = AudioUnitSetParameter(audioUnit,
|
||||||
kHALOutputParam_Volume,
|
kHALOutputParam_Volume,
|
||||||
|
@ -22,7 +22,8 @@ public:
|
|||||||
virtual void SoundLoop();
|
virtual void SoundLoop();
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
|
|
||||||
static bool isValid() {
|
static bool isValid()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ unsigned int CMixer::MixerFifo::Mix(short* samples, unsigned int numSamples, boo
|
|||||||
s32 rvolume = m_RVolume;
|
s32 rvolume = m_RVolume;
|
||||||
|
|
||||||
// TODO: consider a higher-quality resampling algorithm.
|
// TODO: consider a higher-quality resampling algorithm.
|
||||||
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2) {
|
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2)
|
||||||
|
{
|
||||||
u32 indexR2 = indexR + 2; //next sample
|
u32 indexR2 = indexR + 2; //next sample
|
||||||
|
|
||||||
s16 l1 = Common::swap16(m_buffer[indexR & INDEX_MASK]); //current
|
s16 l1 = Common::swap16(m_buffer[indexR & INDEX_MASK]); //current
|
||||||
|
@ -30,7 +30,8 @@ static CMixer *g_mixer;
|
|||||||
static short buffer[2][BUFFER_SIZE];
|
static short buffer[2][BUFFER_SIZE];
|
||||||
static int curBuffer = 0;
|
static int curBuffer = 0;
|
||||||
|
|
||||||
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
|
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
|
{
|
||||||
assert(bq == bqPlayerBufferQueue);
|
assert(bq == bqPlayerBufferQueue);
|
||||||
assert(nullptr == context);
|
assert(nullptr == context);
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
|
|||||||
// Render to the fresh buffer
|
// Render to the fresh buffer
|
||||||
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenSLESStream::Start()
|
bool OpenSLESStream::Start()
|
||||||
{
|
{
|
||||||
SLresult result;
|
SLresult result;
|
||||||
@ -103,9 +105,11 @@ bool OpenSLESStream::Start()
|
|||||||
curBuffer = 0;
|
curBuffer = 0;
|
||||||
|
|
||||||
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
|
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
|
||||||
if (SL_RESULT_SUCCESS != result) {
|
if (SL_RESULT_SUCCESS != result)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
curBuffer ^= 1;
|
curBuffer ^= 1;
|
||||||
g_mixer = m_mixer;
|
g_mixer = m_mixer;
|
||||||
return true;
|
return true;
|
||||||
@ -113,7 +117,8 @@ bool OpenSLESStream::Start()
|
|||||||
|
|
||||||
void OpenSLESStream::Stop()
|
void OpenSLESStream::Stop()
|
||||||
{
|
{
|
||||||
if (bqPlayerObject != nullptr) {
|
if (bqPlayerObject != nullptr)
|
||||||
|
{
|
||||||
(*bqPlayerObject)->Destroy(bqPlayerObject);
|
(*bqPlayerObject)->Destroy(bqPlayerObject);
|
||||||
bqPlayerObject = nullptr;
|
bqPlayerObject = nullptr;
|
||||||
bqPlayerPlay = nullptr;
|
bqPlayerPlay = nullptr;
|
||||||
@ -121,11 +126,15 @@ void OpenSLESStream::Stop()
|
|||||||
bqPlayerMuteSolo = nullptr;
|
bqPlayerMuteSolo = nullptr;
|
||||||
bqPlayerVolume = nullptr;
|
bqPlayerVolume = nullptr;
|
||||||
}
|
}
|
||||||
if (outputMixObject != nullptr) {
|
|
||||||
|
if (outputMixObject != nullptr)
|
||||||
|
{
|
||||||
(*outputMixObject)->Destroy(outputMixObject);
|
(*outputMixObject)->Destroy(outputMixObject);
|
||||||
outputMixObject = nullptr;
|
outputMixObject = nullptr;
|
||||||
}
|
}
|
||||||
if (engineObject != nullptr) {
|
|
||||||
|
if (engineObject != nullptr)
|
||||||
|
{
|
||||||
(*engineObject)->Destroy(engineObject);
|
(*engineObject)->Destroy(engineObject);
|
||||||
engineObject = nullptr;
|
engineObject = nullptr;
|
||||||
engineEngine = nullptr;
|
engineEngine = nullptr;
|
||||||
|
@ -19,7 +19,8 @@ PulseAudio::PulseAudio(CMixer *mixer)
|
|||||||
: SoundStream(mixer)
|
: SoundStream(mixer)
|
||||||
, m_thread()
|
, m_thread()
|
||||||
, m_run_thread()
|
, m_run_thread()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool PulseAudio::Start()
|
bool PulseAudio::Start()
|
||||||
{
|
{
|
||||||
|
@ -33,23 +33,32 @@ public:
|
|||||||
virtual void Update() {}
|
virtual void Update() {}
|
||||||
virtual void Clear(bool mute) { m_muted = mute; }
|
virtual void Clear(bool mute) { m_muted = mute; }
|
||||||
bool IsMuted() const { return m_muted; }
|
bool IsMuted() const { return m_muted; }
|
||||||
virtual void StartLogAudio(const char *filename) {
|
|
||||||
if (! m_logAudio) {
|
virtual void StartLogAudio(const char *filename)
|
||||||
|
{
|
||||||
|
if (! m_logAudio)
|
||||||
|
{
|
||||||
m_logAudio = true;
|
m_logAudio = true;
|
||||||
g_wave_writer.Start(filename, m_mixer->GetSampleRate());
|
g_wave_writer.Start(filename, m_mixer->GetSampleRate());
|
||||||
g_wave_writer.SetSkipSilence(false);
|
g_wave_writer.SetSkipSilence(false);
|
||||||
NOTICE_LOG(DSPHLE, "Starting Audio logging");
|
NOTICE_LOG(DSPHLE, "Starting Audio logging");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
WARN_LOG(DSPHLE, "Audio logging already started");
|
WARN_LOG(DSPHLE, "Audio logging already started");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StopLogAudio() {
|
virtual void StopLogAudio()
|
||||||
if (m_logAudio) {
|
{
|
||||||
|
if (m_logAudio)
|
||||||
|
{
|
||||||
m_logAudio = false;
|
m_logAudio = false;
|
||||||
g_wave_writer.Stop();
|
g_wave_writer.Stop();
|
||||||
NOTICE_LOG(DSPHLE, "Stopping Audio logging");
|
NOTICE_LOG(DSPHLE, "Stopping Audio logging");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
WARN_LOG(DSPHLE, "Audio logging already stopped");
|
WARN_LOG(DSPHLE, "Audio logging already stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,10 @@ ALDeviceList::ALDeviceList()
|
|||||||
*/
|
*/
|
||||||
ALDeviceList::~ALDeviceList()
|
ALDeviceList::~ALDeviceList()
|
||||||
{
|
{
|
||||||
for (auto& di : vDeviceInfo) {
|
for (auto& di : vDeviceInfo)
|
||||||
if (di.pvstrExtensions) {
|
{
|
||||||
|
if (di.pvstrExtensions)
|
||||||
|
{
|
||||||
di.pvstrExtensions->clear();
|
di.pvstrExtensions->clear();
|
||||||
delete di.pvstrExtensions;
|
delete di.pvstrExtensions;
|
||||||
}
|
}
|
||||||
@ -171,13 +173,13 @@ char * ALDeviceList::GetDeviceName(s32 index)
|
|||||||
*/
|
*/
|
||||||
void ALDeviceList::GetDeviceVersion(s32 index, s32 *major, s32 *minor)
|
void ALDeviceList::GetDeviceVersion(s32 index, s32 *major, s32 *minor)
|
||||||
{
|
{
|
||||||
if (index < GetNumDevices()) {
|
if (index < GetNumDevices())
|
||||||
|
{
|
||||||
if (major)
|
if (major)
|
||||||
*major = vDeviceInfo[index].iMajorVersion;
|
*major = vDeviceInfo[index].iMajorVersion;
|
||||||
if (minor)
|
if (minor)
|
||||||
*minor = vDeviceInfo[index].iMinorVersion;
|
*minor = vDeviceInfo[index].iMinorVersion;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -198,9 +200,12 @@ bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
|
|||||||
{
|
{
|
||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
|
|
||||||
if (index < GetNumDevices()) {
|
if (index < GetNumDevices())
|
||||||
for (auto& ext : *vDeviceInfo[index].pvstrExtensions) {
|
{
|
||||||
if (!strcasecmp(ext.c_str(), szExtName)) {
|
for (auto& ext : *vDeviceInfo[index].pvstrExtensions)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(ext.c_str(), szExtName))
|
||||||
|
{
|
||||||
bReturn = true;
|
bReturn = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -224,9 +229,11 @@ s32 ALDeviceList::GetDefaultDevice()
|
|||||||
void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
|
void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
|
||||||
{
|
{
|
||||||
s32 dMajor = 0, dMinor = 0;
|
s32 dMajor = 0, dMinor = 0;
|
||||||
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
|
for (u32 i = 0; i < vDeviceInfo.size(); i++)
|
||||||
|
{
|
||||||
GetDeviceVersion(i, &dMajor, &dMinor);
|
GetDeviceVersion(i, &dMajor, &dMinor);
|
||||||
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) {
|
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor)))
|
||||||
|
{
|
||||||
vDeviceInfo[i].bSelected = false;
|
vDeviceInfo[i].bSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,9 +245,11 @@ void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
|
|||||||
void ALDeviceList::FilterDevicesMaxVer(s32 major, s32 minor)
|
void ALDeviceList::FilterDevicesMaxVer(s32 major, s32 minor)
|
||||||
{
|
{
|
||||||
s32 dMajor = 0, dMinor = 0;
|
s32 dMajor = 0, dMinor = 0;
|
||||||
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
|
for (u32 i = 0; i < vDeviceInfo.size(); i++)
|
||||||
|
{
|
||||||
GetDeviceVersion(i, &dMajor, &dMinor);
|
GetDeviceVersion(i, &dMajor, &dMinor);
|
||||||
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) {
|
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor)))
|
||||||
|
{
|
||||||
vDeviceInfo[i].bSelected = false;
|
vDeviceInfo[i].bSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,14 +262,18 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
|
|||||||
{
|
{
|
||||||
bool bFound;
|
bool bFound;
|
||||||
|
|
||||||
for (auto& di : vDeviceInfo) {
|
for (auto& di : vDeviceInfo)
|
||||||
|
{
|
||||||
bFound = false;
|
bFound = false;
|
||||||
for (auto& ext : *di.pvstrExtensions) {
|
for (auto& ext : *di.pvstrExtensions)
|
||||||
if (!strcasecmp(ext.c_str(), szExtName)) {
|
{
|
||||||
|
if (!strcasecmp(ext.c_str(), szExtName))
|
||||||
|
{
|
||||||
bFound = true;
|
bFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bFound)
|
if (!bFound)
|
||||||
di.bSelected = false;
|
di.bSelected = false;
|
||||||
}
|
}
|
||||||
@ -271,9 +284,11 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
|
|||||||
*/
|
*/
|
||||||
void ALDeviceList::ResetFilters()
|
void ALDeviceList::ResetFilters()
|
||||||
{
|
{
|
||||||
for (s32 i = 0; i < GetNumDevices(); i++) {
|
for (s32 i = 0; i < GetNumDevices(); i++)
|
||||||
|
{
|
||||||
vDeviceInfo[i].bSelected = true;
|
vDeviceInfo[i].bSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
filterIndex = 0;
|
filterIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,11 +299,14 @@ s32 ALDeviceList::GetFirstFilteredDevice()
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < GetNumDevices(); i++) {
|
for (i = 0; i < GetNumDevices(); i++)
|
||||||
if (vDeviceInfo[i].bSelected == true) {
|
{
|
||||||
|
if (vDeviceInfo[i].bSelected == true)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterIndex = i + 1;
|
filterIndex = i + 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -300,11 +318,14 @@ s32 ALDeviceList::GetNextFilteredDevice()
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = filterIndex; i < GetNumDevices(); i++) {
|
for (i = filterIndex; i < GetNumDevices(); i++)
|
||||||
if (vDeviceInfo[i].bSelected == true) {
|
{
|
||||||
|
if (vDeviceInfo[i].bSelected == true)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterIndex = i + 1;
|
filterIndex = i + 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user