mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
Merge pull request #2134 from WizardCM/wasapi-samplerate
Log Sample Rate for WASAPI devices
This commit is contained in:
commit
4c85ac65a3
@ -3685,19 +3685,19 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="sampleRate">
|
||||
<property name="currentText">
|
||||
<string notr="true">44.1khz</string>
|
||||
<string notr="true">44.1 kHz</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>44.1khz</string>
|
||||
<string>44.1 kHz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>48khz</string>
|
||||
<string>48 kHz</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
@ -2189,9 +2189,9 @@ void OBSBasicSettings::LoadAudioSettings()
|
||||
|
||||
const char *str;
|
||||
if (sampleRate == 48000)
|
||||
str = "48khz";
|
||||
str = "48 kHz";
|
||||
else
|
||||
str = "44.1khz";
|
||||
str = "44.1 kHz";
|
||||
|
||||
int sampleRateIdx = ui->sampleRate->findText(str);
|
||||
if (sampleRateIdx != -1)
|
||||
@ -3253,7 +3253,7 @@ void OBSBasicSettings::SaveAudioSettings()
|
||||
}
|
||||
|
||||
int sampleRate = 44100;
|
||||
if (sampleRateStr == "48khz")
|
||||
if (sampleRateStr == "48 kHz")
|
||||
sampleRate = 48000;
|
||||
|
||||
if (WidgetChanged(ui->sampleRate))
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <audioclient.h>
|
||||
#include <propsys.h>
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user