From 0f528807672b874d25cfb06b76d8f1db76e0aec6 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sun, 9 Nov 2014 11:15:35 +0100 Subject: [PATCH] Astyle --- neo/renderer/Cinematic.cpp | 10 +- neo/renderer/Image_files.cpp | 4 +- neo/sound/XAudio2/XA2_SoundHardware.cpp | 250 +++++++++++++----------- neo/sound/snd_local.h | 9 +- 4 files changed, 143 insertions(+), 130 deletions(-) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 02567cb1..a9a35a60 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -2047,7 +2047,7 @@ struct jpeg_error_mgr jerr; */ #ifdef USE_NEWER_JPEG -METHODDEF(boolean) +METHODDEF( boolean ) #else METHODDEF boolean #endif @@ -2083,7 +2083,7 @@ fill_input_buffer( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG -METHODDEF(void) +METHODDEF( void ) #else METHODDEF void #endif @@ -2111,7 +2111,7 @@ init_source( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG -METHODDEF(void) +METHODDEF( void ) #else METHODDEF void #endif @@ -2151,7 +2151,7 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes ) */ #ifdef USE_NEWER_JPEG -METHODDEF(void) +METHODDEF( void ) #else METHODDEF void #endif @@ -2162,7 +2162,7 @@ term_source( j_decompress_ptr cinfo ) } #ifdef USE_NEWER_JPEG -GLOBAL(void) +GLOBAL( void ) #else GLOBAL void #endif diff --git a/neo/renderer/Image_files.cpp b/neo/renderer/Image_files.cpp index 9392860b..6ffd44b8 100644 --- a/neo/renderer/Image_files.cpp +++ b/neo/renderer/Image_files.cpp @@ -455,7 +455,7 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int* byte* fbuffer; byte* bbuf; int len; - + /* In this example we want to open the input file before doing anything else, * so that the setjmp() error recovery below can assume the file is open. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that @@ -509,7 +509,7 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int* #ifdef USE_NEWER_JPEG jpeg_mem_src( &cinfo, fbuffer, len ); #else - jpeg_stdio_src( &cinfo, fbuffer ); + jpeg_stdio_src( &cinfo, fbuffer ); #endif /* Step 3: read file parameters with jpeg_read_header() */ diff --git a/neo/sound/XAudio2/XA2_SoundHardware.cpp b/neo/sound/XAudio2/XA2_SoundHardware.cpp index 1e4731c4..72da11fd 100644 --- a/neo/sound/XAudio2/XA2_SoundHardware.cpp +++ b/neo/sound/XAudio2/XA2_SoundHardware.cpp @@ -258,123 +258,135 @@ void idSoundHardware_XAudio2::Init() // Register the sound engine callback pXAudio2->RegisterForCallbacks( &soundEngineCallback ); soundEngineCallback.hardware = this; - UINT32 deviceCount = 0; - DWORD outputSampleRate = 44100; // Max( (DWORD)XAUDIO2FX_REVERB_MIN_FRAMERATE, Min( (DWORD)XAUDIO2FX_REVERB_MAX_FRAMERATE, deviceDetails.OutputFormat.Format.nSamplesPerSec ) ); - - // RB: not available on Windows 8 SDK + UINT32 deviceCount = 0; + DWORD outputSampleRate = 44100; // Max( (DWORD)XAUDIO2FX_REVERB_MIN_FRAMERATE, Min( (DWORD)XAUDIO2FX_REVERB_MAX_FRAMERATE, deviceDetails.OutputFormat.Format.nSamplesPerSec ) ); + + // RB: not available on Windows 8 SDK #if defined(USE_WINRT) //(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) - - IMMDeviceEnumerator *immDevEnum = nullptr; - IMMDeviceCollection *immDevCollection = nullptr; - IMMDevice *immDev = nullptr; - std::vector vAudioDevices; - - HRESULT hResult = CoCreateInstance( - __uuidof(MMDeviceEnumerator), NULL, - CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**) &immDevEnum); - - if (FAILED(hResult)) { - idLib::Warning( "Failed to get audio enumerator" ); - pXAudio2->Release(); - pXAudio2 = NULL; - return; - } - - hResult = immDevEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &immDevCollection); - if (FAILED(hResult)) { - idLib::Warning( "Failed to get audio endpoints" ); - pXAudio2->Release(); - pXAudio2 = NULL; - return; - } - - hResult = immDevCollection->GetCount(&deviceCount); - if (FAILED(hResult)) { - idLib::Warning( "No audio devices found" ); - pXAudio2->Release(); - pXAudio2 = NULL; - return; - } - - for (UINT i = 0; i < deviceCount; i++) { - IPropertyStore *propStore = nullptr; - PROPVARIANT varName; - PROPVARIANT varId; - - PropVariantInit(&varId); - PropVariantInit(&varName); - - hResult = immDevCollection->Item(i, &immDev); - if (SUCCEEDED(hResult)) { - hResult = immDev->OpenPropertyStore(STGM_READ, &propStore); - } - if (SUCCEEDED(hResult)) { - hResult = propStore->GetValue(PKEY_AudioEndpoint_Path, &varId); - } - - if (SUCCEEDED(hResult)) { - hResult = propStore->GetValue(PKEY_Device_FriendlyName, &varName); - } - - if (SUCCEEDED(hResult)) { - assert(varId.vt == VT_LPWSTR); - assert(varName.vt == VT_LPWSTR); - - // Now save somewhere the device display name & id - AudioDevice ad; - ad.name = varName.pwszVal; - ad.id = varId.pwszVal; - - vAudioDevices.push_back(ad); - } - - PropVariantClear(&varName); - PropVariantClear(&varId); - - if (propStore != nullptr) { - propStore->Release(); - } - - if (immDev != nullptr) { - immDev->Release(); - } - } - - - immDevCollection->Release(); - immDevEnum->Release(); - - int preferredDevice = s_device.GetInteger(); - if (!vAudioDevices.empty()) { - if (SUCCEEDED(pXAudio2->CreateMasteringVoice(&pMasterVoice, - XAUDIO2_DEFAULT_CHANNELS, - outputSampleRate, - 0, - vAudioDevices.at(0).id.c_str(), - NULL, - AudioCategory_GameEffects))) - { - XAUDIO2_VOICE_DETAILS deviceDetails; - pMasterVoice->GetVoiceDetails(&deviceDetails); - - pMasterVoice->SetVolume(DBtoLinear(s_volume_dB.GetFloat())); - - outputChannels = deviceDetails.InputChannels; - DWORD win8_channelMask; - pMasterVoice->GetChannelMask(&win8_channelMask); - - channelMask = (unsigned int)win8_channelMask; - idLib::Printf( "Using device %s\n", vAudioDevices.at(0).name ); - } - else { - idLib::Warning("Failed to create master voice"); - pXAudio2->Release(); - pXAudio2 = NULL; - return; - } - } - -#else + + IMMDeviceEnumerator* immDevEnum = nullptr; + IMMDeviceCollection* immDevCollection = nullptr; + IMMDevice* immDev = nullptr; + std::vector vAudioDevices; + + HRESULT hResult = CoCreateInstance( + __uuidof( MMDeviceEnumerator ), NULL, + CLSCTX_ALL, __uuidof( IMMDeviceEnumerator ), ( void** ) &immDevEnum ); + + if( FAILED( hResult ) ) + { + idLib::Warning( "Failed to get audio enumerator" ); + pXAudio2->Release(); + pXAudio2 = NULL; + return; + } + + hResult = immDevEnum->EnumAudioEndpoints( eRender, DEVICE_STATE_ACTIVE, &immDevCollection ); + if( FAILED( hResult ) ) + { + idLib::Warning( "Failed to get audio endpoints" ); + pXAudio2->Release(); + pXAudio2 = NULL; + return; + } + + hResult = immDevCollection->GetCount( &deviceCount ); + if( FAILED( hResult ) ) + { + idLib::Warning( "No audio devices found" ); + pXAudio2->Release(); + pXAudio2 = NULL; + return; + } + + for( UINT i = 0; i < deviceCount; i++ ) + { + IPropertyStore* propStore = nullptr; + PROPVARIANT varName; + PROPVARIANT varId; + + PropVariantInit( &varId ); + PropVariantInit( &varName ); + + hResult = immDevCollection->Item( i, &immDev ); + if( SUCCEEDED( hResult ) ) + { + hResult = immDev->OpenPropertyStore( STGM_READ, &propStore ); + } + if( SUCCEEDED( hResult ) ) + { + hResult = propStore->GetValue( PKEY_AudioEndpoint_Path, &varId ); + } + + if( SUCCEEDED( hResult ) ) + { + hResult = propStore->GetValue( PKEY_Device_FriendlyName, &varName ); + } + + if( SUCCEEDED( hResult ) ) + { + assert( varId.vt == VT_LPWSTR ); + assert( varName.vt == VT_LPWSTR ); + + // Now save somewhere the device display name & id + AudioDevice ad; + ad.name = varName.pwszVal; + ad.id = varId.pwszVal; + + vAudioDevices.push_back( ad ); + } + + PropVariantClear( &varName ); + PropVariantClear( &varId ); + + if( propStore != nullptr ) + { + propStore->Release(); + } + + if( immDev != nullptr ) + { + immDev->Release(); + } + } + + + immDevCollection->Release(); + immDevEnum->Release(); + + int preferredDevice = s_device.GetInteger(); + if( !vAudioDevices.empty() ) + { + if( SUCCEEDED( pXAudio2->CreateMasteringVoice( &pMasterVoice, + XAUDIO2_DEFAULT_CHANNELS, + outputSampleRate, + 0, + vAudioDevices.at( 0 ).id.c_str(), + NULL, + AudioCategory_GameEffects ) ) ) + { + XAUDIO2_VOICE_DETAILS deviceDetails; + pMasterVoice->GetVoiceDetails( &deviceDetails ); + + pMasterVoice->SetVolume( DBtoLinear( s_volume_dB.GetFloat() ) ); + + outputChannels = deviceDetails.InputChannels; + DWORD win8_channelMask; + pMasterVoice->GetChannelMask( &win8_channelMask ); + + channelMask = ( unsigned int )win8_channelMask; + idLib::Printf( "Using device %s\n", vAudioDevices.at( 0 ).name ); + } + else + { + idLib::Warning( "Failed to create master voice" ); + pXAudio2->Release(); + pXAudio2 = NULL; + return; + } + } + +#else if( pXAudio2->GetDeviceCount( &deviceCount ) != S_OK || deviceCount == 0 ) { idLib::Warning( "No audio devices found" ); @@ -427,7 +439,7 @@ void idSoundHardware_XAudio2::Init() return; } - + if( FAILED( pXAudio2->CreateMasteringVoice( &pMasterVoice, XAUDIO2_DEFAULT_CHANNELS, outputSampleRate, 0, preferredDevice, NULL ) ) ) { idLib::Warning( "Failed to create master voice" ); @@ -439,9 +451,9 @@ void idSoundHardware_XAudio2::Init() outputChannels = deviceDetails.OutputFormat.Format.nChannels; channelMask = deviceDetails.OutputFormat.dwChannelMask; - + #endif // #if (_WIN32_WINNT < 0x0602 /*_WIN32_WINNT_WIN8*/) - + idSoundVoice::InitSurround( outputChannels, channelMask ); #if defined(USE_DOOMCLASSIC) diff --git a/neo/sound/snd_local.h b/neo/sound/snd_local.h index 208b8fba..fac0c9ae 100644 --- a/neo/sound/snd_local.h +++ b/neo/sound/snd_local.h @@ -145,13 +145,14 @@ ID_INLINE_EXTERN ALCenum CheckALCErrors_( ALCdevice* device, const char* filenam #include #include -DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_Path, 0x9c119480, 0xddc2, 0x4954, 0xa1, 0x50, 0x5b, 0xd2, 0x40, 0xd4, 0x54, 0xad, 1); +DEFINE_PROPERTYKEY( PKEY_AudioEndpoint_Path, 0x9c119480, 0xddc2, 0x4954, 0xa1, 0x50, 0x5b, 0xd2, 0x40, 0xd4, 0x54, 0xad, 1 ); #pragma comment(lib,"xaudio2.lib") -struct AudioDevice { - std::wstring name; - std::wstring id; +struct AudioDevice +{ + std::wstring name; + std::wstring id; }; #else #include