Merge pull request #2134 from WizardCM/wasapi-samplerate

Log Sample Rate for WASAPI devices
This commit is contained in:
Jim
2019-10-21 23:30:18 -07:00
committed by GitHub
4 changed files with 26 additions and 7 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();