diff --git a/include/DLL_VERSION.H b/include/DLL_VERSION.H index 4eb6775..db6023f 100644 --- a/include/DLL_VERSION.H +++ b/include/DLL_VERSION.H @@ -3,7 +3,7 @@ #define TBF_MAJOR 0 #define TBF_MINOR 1 -#define TBF_BUILD 4 +#define TBF_BUILD 5 #define TBF_REV 0 diff --git a/src/sound.cpp b/src/sound.cpp index 54192b1..9b538c7 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -446,13 +446,14 @@ IAudioClient_GetMixFormat_Detour (IAudioClient *This, #define TARGET_SAMPLE_RATE config.audio.sample_hz - if (pMixFormat->nSamplesPerSec != TARGET_SAMPLE_RATE) { + if (TARGET_SAMPLE_RATE != -1 && pMixFormat->nSamplesPerSec != TARGET_SAMPLE_RATE) { audio_log->Log ( L" ** Resampling Audiostream from %lu Hz to %lu Hz", pMixFormat->nSamplesPerSec, TARGET_SAMPLE_RATE ); pMixFormat->nSamplesPerSec = TARGET_SAMPLE_RATE; } pMixFormat->nAvgBytesPerSec = (pMixFormat->nSamplesPerSec * pMixFormat->nChannels * pMixFormat->wBitsPerSample) >> 3; + pMixFormat->nBlockAlign = (pMixFormat->wBitsPerSample * pMixFormat->nChannels) >> 3; g_DeviceFormat.Format.cbSize = 22; g_DeviceFormat.Format.nSamplesPerSec = pMixFormat->nSamplesPerSec; @@ -460,7 +461,6 @@ IAudioClient_GetMixFormat_Detour (IAudioClient *This, g_DeviceFormat.Format.nBlockAlign = pMixFormat->nBlockAlign; g_DeviceFormat.Format.nAvgBytesPerSec = pMixFormat->nAvgBytesPerSec; g_DeviceFormat.Format.wBitsPerSample = pMixFormat->wBitsPerSample; - //g_DeviceFormat.Format.wBitsPerSample = ((PWAVEFORMATEXTENSIBLE)pMixFormat)->Samples.wValidBitsPerSample; // We may have gotten an extensible wave format, but... we need to // truncate this sucker to a plain old WAVEFORMATEX @@ -509,7 +509,6 @@ IAudioClient_Initialize_Detour (IAudioClient *This, L" >> Channels: %lu, Samples Per Sec: %lu, Bits Per Sample: %hu\n", pFormat->nChannels, pFormat->nSamplesPerSec, pFormat->wBitsPerSample ); -#if 0 WAVEFORMATEX format; format.cbSize = pFormat->cbSize; @@ -520,16 +519,15 @@ IAudioClient_Initialize_Detour (IAudioClient *This, format.wBitsPerSample = pFormat->wBitsPerSample; format.wFormatTag = pFormat->wFormatTag; - WAVEFORMATEX *pClosestMatch = - (PWAVEFORMATEX)CoTaskMemAlloc (sizeof (WAVEFORMATEXTENSIBLE)); - +#if 0 if (This->IsFormatSupported (AUDCLNT_SHAREMODE_SHARED, pFormat, &pClosestMatch) == S_OK) { CoTaskMemFree (pClosestMatch); pClosestMatch = &format; } #endif - WAVEFORMATEX *pClosestMatch = (WAVEFORMATEX *)pFormat; + WAVEFORMATEX *pClosestMatch = + (PWAVEFORMATEX)CoTaskMemAlloc (sizeof (WAVEFORMATEXTENSIBLE)); #define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 #define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 @@ -551,14 +549,12 @@ IAudioClient_Initialize_Detour (IAudioClient *This, AUDCLNT_STREAMFLAGS_UNKNOWN4000000 ); } - if (g_DeviceFormat.Format.cbSize == 22) { - pClosestMatch->nChannels = g_DeviceFormat.Format.nChannels; - pClosestMatch->nSamplesPerSec = g_DeviceFormat.Format.nSamplesPerSec; - //pClosestMatch->nBlockAlign = g_DeviceFormat.Format.nBlockAlign; - //pClosestMatch->nAvgBytesPerSec = g_DeviceFormat.Format.nAvgBytesPerSec; - //pClosestMatch->wBitsPerSample = g_DeviceFormat.Format.wBitsPerSample; + if (This->IsFormatSupported (AUDCLNT_SHAREMODE_SHARED, &format, &pClosestMatch) != S_OK) { + CoTaskMemFree (pClosestMatch); + pClosestMatch = (WAVEFORMATEX *)pFormat; } + HRESULT ret = IAudioClient_Initialize_Original (This, AUDCLNT_SHAREMODE_SHARED, StreamFlags, hnsBufferDuration, @@ -570,15 +566,13 @@ IAudioClient_Initialize_Detour (IAudioClient *This, _com_error error (ret); -#if 0 - if (pClosestMatch != &format) + if (pClosestMatch != pFormat) CoTaskMemFree (pClosestMatch); -#endif audio_log->Log ( L" Result: 0x%04X (%s)\n", ret - AUDCLNT_ERR (0x0000), error.ErrorMessage () ); - //new_session = false; + new_session = false; //DSOUND_VIRTUAL_OVERRIDE ( ppAudioClient, 8, "IAudioClient::GetMixFormat", //IAudioClient_GetMixFormat_Original, //IAudioClient_GetMixFormat_Original, @@ -755,6 +749,7 @@ tbf::SoundFix::Init (void) dsound_dll = LoadLibrary (L"dsound.dll"); ole32_dll = LoadLibrary (L"Ole32.dll"); +#if 0 audio_log->LogEx (true, L"@ Hooking DirectSoundCreate... "); TBF_CreateDLLHook ( L"dsound.dll", "DirectSoundCreate", @@ -770,6 +765,7 @@ tbf::SoundFix::Init (void) // when the code was originally written -- test this in the future. DirectSoundCreate_Detour (NULL, &g_pDS, NULL); g_pDS->SetCooperativeLevel (NULL, DSSCL_EXCLUSIVE); +#endif new_session = true; diff --git a/tbf.VC.db b/tbf.VC.db index 211b153..a6973d2 100644 Binary files a/tbf.VC.db and b/tbf.VC.db differ diff --git a/version.ini b/version.ini index 1d7a530..326487b 100644 Binary files a/version.ini and b/version.ini differ