win-wasapi: Log device sample rate when initialized

This commit is contained in:
Matt Gajownik 2019-10-19 19:16:25 +11:00
parent acf2eae1e5
commit a6a86caf21
2 changed files with 20 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#define WIN32_MEAN_AND_LEAN
#include <windows.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <audioclient.h>
#include <propsys.h>

View File

@ -28,6 +28,7 @@ class WASAPISource {
obs_source_t *source;
string device_id;
string device_name;
string device_sample = "-";
bool isInputDevice;
bool useDeviceTiming = false;
bool isDefaultDevice = false;
@ -289,7 +290,8 @@ void WASAPISource::InitCapture()
client->Start();
active = true;
blog(LOG_INFO, "WASAPI: Device '%s' initialized", device_name.c_str());
blog(LOG_INFO, "WASAPI: Device '%s' [%s Hz] initialized",
device_name.c_str(), device_sample.c_str());
}
void WASAPISource::Initialize()
@ -308,6 +310,22 @@ void WASAPISource::Initialize()
device_name = GetDeviceName(device);
HRESULT resSample;
IPropertyStore *store = nullptr;
PWAVEFORMATEX deviceFormatProperties;
PROPVARIANT prop;
resSample = device->OpenPropertyStore(STGM_READ, &store);
if (!FAILED(resSample)) {
resSample =
store->GetValue(PKEY_AudioEngine_DeviceFormat, &prop);
if (!FAILED(resSample)) {
deviceFormatProperties =
(PWAVEFORMATEX)prop.blob.pBlobData;
device_sample = std::to_string(
deviceFormatProperties->nSamplesPerSec);
}
}
InitClient();
if (!isInputDevice)
InitRender();