clang-format: Apply formatting
Code submissions have continually suffered from formatting inconsistencies that constantly have to be addressed. Using clang-format simplifies this by making code formatting more consistent, and allows automation of the code formatting so that maintainers can focus more on the code itself instead of code formatting.
This commit is contained in:
@@ -11,40 +11,40 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define OPT_DEVICE_ID "device_id"
|
||||
#define OPT_DEVICE_ID "device_id"
|
||||
#define OPT_USE_DEVICE_TIMING "use_device_timing"
|
||||
|
||||
static void GetWASAPIDefaults(obs_data_t *settings);
|
||||
|
||||
#define OBS_KSAUDIO_SPEAKER_4POINT1 \
|
||||
(KSAUDIO_SPEAKER_SURROUND|SPEAKER_LOW_FREQUENCY)
|
||||
(KSAUDIO_SPEAKER_SURROUND | SPEAKER_LOW_FREQUENCY)
|
||||
|
||||
class WASAPISource {
|
||||
ComPtr<IMMDevice> device;
|
||||
ComPtr<IAudioClient> client;
|
||||
ComPtr<IMMDevice> device;
|
||||
ComPtr<IAudioClient> client;
|
||||
ComPtr<IAudioCaptureClient> capture;
|
||||
ComPtr<IAudioRenderClient> render;
|
||||
ComPtr<IAudioRenderClient> render;
|
||||
|
||||
obs_source_t *source;
|
||||
string device_id;
|
||||
string device_name;
|
||||
bool isInputDevice;
|
||||
bool useDeviceTiming = false;
|
||||
bool isDefaultDevice = false;
|
||||
obs_source_t *source;
|
||||
string device_id;
|
||||
string device_name;
|
||||
bool isInputDevice;
|
||||
bool useDeviceTiming = false;
|
||||
bool isDefaultDevice = false;
|
||||
|
||||
bool reconnecting = false;
|
||||
bool previouslyFailed = false;
|
||||
WinHandle reconnectThread;
|
||||
bool reconnecting = false;
|
||||
bool previouslyFailed = false;
|
||||
WinHandle reconnectThread;
|
||||
|
||||
bool active = false;
|
||||
WinHandle captureThread;
|
||||
bool active = false;
|
||||
WinHandle captureThread;
|
||||
|
||||
WinHandle stopSignal;
|
||||
WinHandle receiveSignal;
|
||||
WinHandle stopSignal;
|
||||
WinHandle receiveSignal;
|
||||
|
||||
speaker_layout speakers;
|
||||
audio_format format;
|
||||
uint32_t sampleRate;
|
||||
speaker_layout speakers;
|
||||
audio_format format;
|
||||
uint32_t sampleRate;
|
||||
|
||||
static DWORD WINAPI ReconnectThread(LPVOID param);
|
||||
static DWORD WINAPI CaptureThread(LPVOID param);
|
||||
@@ -75,9 +75,8 @@ public:
|
||||
};
|
||||
|
||||
WASAPISource::WASAPISource(obs_data_t *settings, obs_source_t *source_,
|
||||
bool input)
|
||||
: source (source_),
|
||||
isInputDevice (input)
|
||||
bool input)
|
||||
: source(source_), isInputDevice(input)
|
||||
{
|
||||
UpdateSettings(settings);
|
||||
|
||||
@@ -95,9 +94,10 @@ WASAPISource::WASAPISource(obs_data_t *settings, obs_source_t *source_,
|
||||
inline void WASAPISource::Start()
|
||||
{
|
||||
if (!TryInitialize()) {
|
||||
blog(LOG_INFO, "[WASAPISource::WASAPISource] "
|
||||
"Device '%s' not found. Waiting for device",
|
||||
device_id.c_str());
|
||||
blog(LOG_INFO,
|
||||
"[WASAPISource::WASAPISource] "
|
||||
"Device '%s' not found. Waiting for device",
|
||||
device_id.c_str());
|
||||
Reconnect();
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ inline void WASAPISource::Stop()
|
||||
|
||||
if (active) {
|
||||
blog(LOG_INFO, "WASAPI: Device '%s' Terminated",
|
||||
device_name.c_str());
|
||||
device_name.c_str());
|
||||
WaitForSingleObject(captureThread, INFINITE);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ inline WASAPISource::~WASAPISource()
|
||||
|
||||
void WASAPISource::UpdateSettings(obs_data_t *settings)
|
||||
{
|
||||
device_id = obs_data_get_string(settings, OPT_DEVICE_ID);
|
||||
device_id = obs_data_get_string(settings, OPT_DEVICE_ID);
|
||||
useDeviceTiming = obs_data_get_bool(settings, OPT_USE_DEVICE_TIMING);
|
||||
isDefaultDevice = _strcmpi(device_id.c_str(), "default") == 0;
|
||||
}
|
||||
@@ -150,9 +150,9 @@ bool WASAPISource::InitDevice(IMMDeviceEnumerator *enumerator)
|
||||
|
||||
if (isDefaultDevice) {
|
||||
res = enumerator->GetDefaultAudioEndpoint(
|
||||
isInputDevice ? eCapture : eRender,
|
||||
isInputDevice ? eCommunications : eConsole,
|
||||
device.Assign());
|
||||
isInputDevice ? eCapture : eRender,
|
||||
isInputDevice ? eCommunications : eConsole,
|
||||
device.Assign());
|
||||
} else {
|
||||
wchar_t *w_id;
|
||||
os_utf8_to_wcs_ptr(device_id.c_str(), device_id.size(), &w_id);
|
||||
@@ -165,16 +165,16 @@ bool WASAPISource::InitDevice(IMMDeviceEnumerator *enumerator)
|
||||
return SUCCEEDED(res);
|
||||
}
|
||||
|
||||
#define BUFFER_TIME_100NS (5*10000000)
|
||||
#define BUFFER_TIME_100NS (5 * 10000000)
|
||||
|
||||
void WASAPISource::InitClient()
|
||||
{
|
||||
CoTaskMemPtr<WAVEFORMATEX> wfex;
|
||||
HRESULT res;
|
||||
DWORD flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
|
||||
HRESULT res;
|
||||
DWORD flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
|
||||
|
||||
res = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL,
|
||||
nullptr, (void**)client.Assign());
|
||||
res = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr,
|
||||
(void **)client.Assign());
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to activate client context", res);
|
||||
|
||||
@@ -187,9 +187,8 @@ void WASAPISource::InitClient()
|
||||
if (!isInputDevice)
|
||||
flags |= AUDCLNT_STREAMFLAGS_LOOPBACK;
|
||||
|
||||
res = client->Initialize(
|
||||
AUDCLNT_SHAREMODE_SHARED, flags,
|
||||
BUFFER_TIME_100NS, 0, wfex, nullptr);
|
||||
res = client->Initialize(AUDCLNT_SHAREMODE_SHARED, flags,
|
||||
BUFFER_TIME_100NS, 0, wfex, nullptr);
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to get initialize audio client", res);
|
||||
}
|
||||
@@ -197,13 +196,13 @@ void WASAPISource::InitClient()
|
||||
void WASAPISource::InitRender()
|
||||
{
|
||||
CoTaskMemPtr<WAVEFORMATEX> wfex;
|
||||
HRESULT res;
|
||||
LPBYTE buffer;
|
||||
UINT32 frames;
|
||||
ComPtr<IAudioClient> client;
|
||||
HRESULT res;
|
||||
LPBYTE buffer;
|
||||
UINT32 frames;
|
||||
ComPtr<IAudioClient> client;
|
||||
|
||||
res = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL,
|
||||
nullptr, (void**)client.Assign());
|
||||
res = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr,
|
||||
(void **)client.Assign());
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to activate client context", res);
|
||||
|
||||
@@ -211,9 +210,8 @@ void WASAPISource::InitRender()
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to get mix format", res);
|
||||
|
||||
res = client->Initialize(
|
||||
AUDCLNT_SHAREMODE_SHARED, 0,
|
||||
BUFFER_TIME_100NS, 0, wfex, nullptr);
|
||||
res = client->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, BUFFER_TIME_100NS,
|
||||
0, wfex, nullptr);
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to get initialize audio client", res);
|
||||
|
||||
@@ -226,7 +224,7 @@ void WASAPISource::InitRender()
|
||||
throw HRError("Failed to get buffer size", res);
|
||||
|
||||
res = client->GetService(__uuidof(IAudioRenderClient),
|
||||
(void**)render.Assign());
|
||||
(void **)render.Assign());
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to get render client", res);
|
||||
|
||||
@@ -234,7 +232,7 @@ void WASAPISource::InitRender()
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to get buffer", res);
|
||||
|
||||
memset(buffer, 0, frames*wfex->nBlockAlign);
|
||||
memset(buffer, 0, frames * wfex->nBlockAlign);
|
||||
|
||||
render->ReleaseBuffer(frames, 0);
|
||||
}
|
||||
@@ -242,11 +240,16 @@ void WASAPISource::InitRender()
|
||||
static speaker_layout ConvertSpeakerLayout(DWORD layout, WORD channels)
|
||||
{
|
||||
switch (layout) {
|
||||
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
|
||||
case KSAUDIO_SPEAKER_SURROUND: return SPEAKERS_4POINT0;
|
||||
case OBS_KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
|
||||
case KSAUDIO_SPEAKER_5POINT1_SURROUND: return SPEAKERS_5POINT1;
|
||||
case KSAUDIO_SPEAKER_7POINT1_SURROUND: return SPEAKERS_7POINT1;
|
||||
case KSAUDIO_SPEAKER_2POINT1:
|
||||
return SPEAKERS_2POINT1;
|
||||
case KSAUDIO_SPEAKER_SURROUND:
|
||||
return SPEAKERS_4POINT0;
|
||||
case OBS_KSAUDIO_SPEAKER_4POINT1:
|
||||
return SPEAKERS_4POINT1;
|
||||
case KSAUDIO_SPEAKER_5POINT1_SURROUND:
|
||||
return SPEAKERS_5POINT1;
|
||||
case KSAUDIO_SPEAKER_7POINT1_SURROUND:
|
||||
return SPEAKERS_7POINT1;
|
||||
}
|
||||
|
||||
return (speaker_layout)channels;
|
||||
@@ -257,20 +260,20 @@ void WASAPISource::InitFormat(WAVEFORMATEX *wfex)
|
||||
DWORD layout = 0;
|
||||
|
||||
if (wfex->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
|
||||
WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE*)wfex;
|
||||
WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE *)wfex;
|
||||
layout = ext->dwChannelMask;
|
||||
}
|
||||
|
||||
/* WASAPI is always float */
|
||||
sampleRate = wfex->nSamplesPerSec;
|
||||
format = AUDIO_FORMAT_FLOAT;
|
||||
speakers = ConvertSpeakerLayout(layout, wfex->nChannels);
|
||||
format = AUDIO_FORMAT_FLOAT;
|
||||
speakers = ConvertSpeakerLayout(layout, wfex->nChannels);
|
||||
}
|
||||
|
||||
void WASAPISource::InitCapture()
|
||||
{
|
||||
HRESULT res = client->GetService(__uuidof(IAudioCaptureClient),
|
||||
(void**)capture.Assign());
|
||||
(void **)capture.Assign());
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to create capture context", res);
|
||||
|
||||
@@ -278,9 +281,8 @@ void WASAPISource::InitCapture()
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to set event handle", res);
|
||||
|
||||
captureThread = CreateThread(nullptr, 0,
|
||||
WASAPISource::CaptureThread, this,
|
||||
0, nullptr);
|
||||
captureThread = CreateThread(nullptr, 0, WASAPISource::CaptureThread,
|
||||
this, 0, nullptr);
|
||||
if (!captureThread.Valid())
|
||||
throw "Failed to create capture thread";
|
||||
|
||||
@@ -295,10 +297,9 @@ void WASAPISource::Initialize()
|
||||
ComPtr<IMMDeviceEnumerator> enumerator;
|
||||
HRESULT res;
|
||||
|
||||
res = CoCreateInstance(__uuidof(MMDeviceEnumerator),
|
||||
nullptr, CLSCTX_ALL,
|
||||
__uuidof(IMMDeviceEnumerator),
|
||||
(void**)enumerator.Assign());
|
||||
res = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr,
|
||||
CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),
|
||||
(void **)enumerator.Assign());
|
||||
if (FAILED(res))
|
||||
throw HRError("Failed to create enumerator", res);
|
||||
|
||||
@@ -308,7 +309,8 @@ void WASAPISource::Initialize()
|
||||
device_name = GetDeviceName(device);
|
||||
|
||||
InitClient();
|
||||
if (!isInputDevice) InitRender();
|
||||
if (!isInputDevice)
|
||||
InitRender();
|
||||
InitCapture();
|
||||
}
|
||||
|
||||
@@ -322,18 +324,18 @@ bool WASAPISource::TryInitialize()
|
||||
return active;
|
||||
|
||||
blog(LOG_WARNING, "[WASAPISource::TryInitialize]:[%s] %s: %lX",
|
||||
device_name.empty() ?
|
||||
device_id.c_str() : device_name.c_str(),
|
||||
error.str, error.hr);
|
||||
device_name.empty() ? device_id.c_str()
|
||||
: device_name.c_str(),
|
||||
error.str, error.hr);
|
||||
|
||||
} catch (const char *error) {
|
||||
if (previouslyFailed)
|
||||
return active;
|
||||
|
||||
blog(LOG_WARNING, "[WASAPISource::TryInitialize]:[%s] %s",
|
||||
device_name.empty() ?
|
||||
device_id.c_str() : device_name.c_str(),
|
||||
error);
|
||||
device_name.empty() ? device_id.c_str()
|
||||
: device_name.c_str(),
|
||||
error);
|
||||
}
|
||||
|
||||
previouslyFailed = !active;
|
||||
@@ -343,14 +345,14 @@ bool WASAPISource::TryInitialize()
|
||||
void WASAPISource::Reconnect()
|
||||
{
|
||||
reconnecting = true;
|
||||
reconnectThread = CreateThread(nullptr, 0,
|
||||
WASAPISource::ReconnectThread, this,
|
||||
0, nullptr);
|
||||
reconnectThread = CreateThread(
|
||||
nullptr, 0, WASAPISource::ReconnectThread, this, 0, nullptr);
|
||||
|
||||
if (!reconnectThread.Valid())
|
||||
blog(LOG_WARNING, "[WASAPISource::Reconnect] "
|
||||
"Failed to initialize reconnect thread: %lu",
|
||||
GetLastError());
|
||||
blog(LOG_WARNING,
|
||||
"[WASAPISource::Reconnect] "
|
||||
"Failed to initialize reconnect thread: %lu",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
static inline bool WaitForSignal(HANDLE handle, DWORD time)
|
||||
@@ -362,14 +364,16 @@ static inline bool WaitForSignal(HANDLE handle, DWORD time)
|
||||
|
||||
DWORD WINAPI WASAPISource::ReconnectThread(LPVOID param)
|
||||
{
|
||||
WASAPISource *source = (WASAPISource*)param;
|
||||
WASAPISource *source = (WASAPISource *)param;
|
||||
|
||||
os_set_thread_name("win-wasapi: reconnect thread");
|
||||
|
||||
CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
|
||||
obs_monitoring_type type = obs_source_get_monitoring_type(source->source);
|
||||
obs_source_set_monitoring_type(source->source, OBS_MONITORING_TYPE_NONE);
|
||||
obs_monitoring_type type =
|
||||
obs_source_get_monitoring_type(source->source);
|
||||
obs_source_set_monitoring_type(source->source,
|
||||
OBS_MONITORING_TYPE_NONE);
|
||||
|
||||
while (!WaitForSignal(source->stopSignal, RECONNECT_INTERVAL)) {
|
||||
if (source->TryInitialize())
|
||||
@@ -386,11 +390,11 @@ DWORD WINAPI WASAPISource::ReconnectThread(LPVOID param)
|
||||
bool WASAPISource::ProcessCaptureData()
|
||||
{
|
||||
HRESULT res;
|
||||
LPBYTE buffer;
|
||||
UINT32 frames;
|
||||
DWORD flags;
|
||||
UINT64 pos, ts;
|
||||
UINT captureSize = 0;
|
||||
LPBYTE buffer;
|
||||
UINT32 frames;
|
||||
DWORD flags;
|
||||
UINT64 pos, ts;
|
||||
UINT captureSize = 0;
|
||||
|
||||
while (true) {
|
||||
res = capture->GetNextPacketSize(&captureSize);
|
||||
@@ -398,9 +402,10 @@ bool WASAPISource::ProcessCaptureData()
|
||||
if (FAILED(res)) {
|
||||
if (res != AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
blog(LOG_WARNING,
|
||||
"[WASAPISource::GetCaptureData]"
|
||||
" capture->GetNextPacketSize"
|
||||
" failed: %lX", res);
|
||||
"[WASAPISource::GetCaptureData]"
|
||||
" capture->GetNextPacketSize"
|
||||
" failed: %lX",
|
||||
res);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -411,24 +416,24 @@ bool WASAPISource::ProcessCaptureData()
|
||||
if (FAILED(res)) {
|
||||
if (res != AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
blog(LOG_WARNING,
|
||||
"[WASAPISource::GetCaptureData]"
|
||||
" capture->GetBuffer"
|
||||
" failed: %lX", res);
|
||||
"[WASAPISource::GetCaptureData]"
|
||||
" capture->GetBuffer"
|
||||
" failed: %lX",
|
||||
res);
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_source_audio data = {};
|
||||
data.data[0] = (const uint8_t*)buffer;
|
||||
data.frames = (uint32_t)frames;
|
||||
data.speakers = speakers;
|
||||
data.samples_per_sec = sampleRate;
|
||||
data.format = format;
|
||||
data.timestamp = useDeviceTiming ?
|
||||
ts*100 : os_gettime_ns();
|
||||
data.data[0] = (const uint8_t *)buffer;
|
||||
data.frames = (uint32_t)frames;
|
||||
data.speakers = speakers;
|
||||
data.samples_per_sec = sampleRate;
|
||||
data.format = format;
|
||||
data.timestamp = useDeviceTiming ? ts * 100 : os_gettime_ns();
|
||||
|
||||
if (!useDeviceTiming)
|
||||
data.timestamp -= (uint64_t)frames * 1000000000ULL /
|
||||
(uint64_t)sampleRate;
|
||||
(uint64_t)sampleRate;
|
||||
|
||||
obs_source_output_audio(source, &data);
|
||||
|
||||
@@ -439,7 +444,7 @@ bool WASAPISource::ProcessCaptureData()
|
||||
}
|
||||
|
||||
static inline bool WaitForCaptureSignal(DWORD numSignals, const HANDLE *signals,
|
||||
DWORD duration)
|
||||
DWORD duration)
|
||||
{
|
||||
DWORD ret;
|
||||
ret = WaitForMultipleObjects(numSignals, signals, false, duration);
|
||||
@@ -449,16 +454,13 @@ static inline bool WaitForCaptureSignal(DWORD numSignals, const HANDLE *signals,
|
||||
|
||||
DWORD WINAPI WASAPISource::CaptureThread(LPVOID param)
|
||||
{
|
||||
WASAPISource *source = (WASAPISource*)param;
|
||||
bool reconnect = false;
|
||||
WASAPISource *source = (WASAPISource *)param;
|
||||
bool reconnect = false;
|
||||
|
||||
/* Output devices don't signal, so just make it check every 10 ms */
|
||||
DWORD dur = source->isInputDevice ? RECONNECT_INTERVAL : 10;
|
||||
DWORD dur = source->isInputDevice ? RECONNECT_INTERVAL : 10;
|
||||
|
||||
HANDLE sigs[2] = {
|
||||
source->receiveSignal,
|
||||
source->stopSignal
|
||||
};
|
||||
HANDLE sigs[2] = {source->receiveSignal, source->stopSignal};
|
||||
|
||||
os_set_thread_name("win-wasapi: capture thread");
|
||||
|
||||
@@ -472,11 +474,11 @@ DWORD WINAPI WASAPISource::CaptureThread(LPVOID param)
|
||||
source->client->Stop();
|
||||
|
||||
source->captureThread = nullptr;
|
||||
source->active = false;
|
||||
source->active = false;
|
||||
|
||||
if (reconnect) {
|
||||
blog(LOG_INFO, "Device '%s' invalidated. Retrying",
|
||||
source->device_name.c_str());
|
||||
source->device_name.c_str());
|
||||
source->Reconnect();
|
||||
}
|
||||
|
||||
@@ -485,12 +487,12 @@ DWORD WINAPI WASAPISource::CaptureThread(LPVOID param)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const char *GetWASAPIInputName(void*)
|
||||
static const char *GetWASAPIInputName(void *)
|
||||
{
|
||||
return obs_module_text("AudioInput");
|
||||
}
|
||||
|
||||
static const char *GetWASAPIOutputName(void*)
|
||||
static const char *GetWASAPIOutputName(void *)
|
||||
{
|
||||
return obs_module_text("AudioOutput");
|
||||
}
|
||||
@@ -508,7 +510,7 @@ static void GetWASAPIDefaultsOutput(obs_data_t *settings)
|
||||
}
|
||||
|
||||
static void *CreateWASAPISource(obs_data_t *settings, obs_source_t *source,
|
||||
bool input)
|
||||
bool input)
|
||||
{
|
||||
try {
|
||||
return new WASAPISource(settings, source, input);
|
||||
@@ -531,12 +533,12 @@ static void *CreateWASAPIOutput(obs_data_t *settings, obs_source_t *source)
|
||||
|
||||
static void DestroyWASAPISource(void *obj)
|
||||
{
|
||||
delete static_cast<WASAPISource*>(obj);
|
||||
delete static_cast<WASAPISource *>(obj);
|
||||
}
|
||||
|
||||
static void UpdateWASAPISource(void *obj, obs_data_t *settings)
|
||||
{
|
||||
static_cast<WASAPISource*>(obj)->Update(settings);
|
||||
static_cast<WASAPISource *>(obj)->Update(settings);
|
||||
}
|
||||
|
||||
static obs_properties_t *GetWASAPIProperties(bool input)
|
||||
@@ -544,24 +546,24 @@ static obs_properties_t *GetWASAPIProperties(bool input)
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
vector<AudioDeviceInfo> devices;
|
||||
|
||||
obs_property_t *device_prop = obs_properties_add_list(props,
|
||||
OPT_DEVICE_ID, obs_module_text("Device"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_t *device_prop = obs_properties_add_list(
|
||||
props, OPT_DEVICE_ID, obs_module_text("Device"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
|
||||
GetWASAPIAudioDevices(devices, input);
|
||||
|
||||
if (devices.size())
|
||||
obs_property_list_add_string(device_prop,
|
||||
obs_module_text("Default"), "default");
|
||||
obs_property_list_add_string(
|
||||
device_prop, obs_module_text("Default"), "default");
|
||||
|
||||
for (size_t i = 0; i < devices.size(); i++) {
|
||||
AudioDeviceInfo &device = devices[i];
|
||||
obs_property_list_add_string(device_prop,
|
||||
device.name.c_str(), device.id.c_str());
|
||||
obs_property_list_add_string(device_prop, device.name.c_str(),
|
||||
device.id.c_str());
|
||||
}
|
||||
|
||||
obs_properties_add_bool(props, OPT_USE_DEVICE_TIMING,
|
||||
obs_module_text("UseDeviceTiming"));
|
||||
obs_module_text("UseDeviceTiming"));
|
||||
|
||||
return props;
|
||||
}
|
||||
@@ -579,32 +581,30 @@ static obs_properties_t *GetWASAPIPropertiesOutput(void *)
|
||||
void RegisterWASAPIInput()
|
||||
{
|
||||
obs_source_info info = {};
|
||||
info.id = "wasapi_input_capture";
|
||||
info.type = OBS_SOURCE_TYPE_INPUT;
|
||||
info.output_flags = OBS_SOURCE_AUDIO |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE;
|
||||
info.get_name = GetWASAPIInputName;
|
||||
info.create = CreateWASAPIInput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.get_defaults = GetWASAPIDefaultsInput;
|
||||
info.get_properties = GetWASAPIPropertiesInput;
|
||||
info.id = "wasapi_input_capture";
|
||||
info.type = OBS_SOURCE_TYPE_INPUT;
|
||||
info.output_flags = OBS_SOURCE_AUDIO | OBS_SOURCE_DO_NOT_DUPLICATE;
|
||||
info.get_name = GetWASAPIInputName;
|
||||
info.create = CreateWASAPIInput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.get_defaults = GetWASAPIDefaultsInput;
|
||||
info.get_properties = GetWASAPIPropertiesInput;
|
||||
obs_register_source(&info);
|
||||
}
|
||||
|
||||
void RegisterWASAPIOutput()
|
||||
{
|
||||
obs_source_info info = {};
|
||||
info.id = "wasapi_output_capture";
|
||||
info.type = OBS_SOURCE_TYPE_INPUT;
|
||||
info.output_flags = OBS_SOURCE_AUDIO |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE |
|
||||
OBS_SOURCE_DO_NOT_SELF_MONITOR;
|
||||
info.get_name = GetWASAPIOutputName;
|
||||
info.create = CreateWASAPIOutput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.get_defaults = GetWASAPIDefaultsOutput;
|
||||
info.get_properties = GetWASAPIPropertiesOutput;
|
||||
info.id = "wasapi_output_capture";
|
||||
info.type = OBS_SOURCE_TYPE_INPUT;
|
||||
info.output_flags = OBS_SOURCE_AUDIO | OBS_SOURCE_DO_NOT_DUPLICATE |
|
||||
OBS_SOURCE_DO_NOT_SELF_MONITOR;
|
||||
info.get_name = GetWASAPIOutputName;
|
||||
info.create = CreateWASAPIOutput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.get_defaults = GetWASAPIDefaultsOutput;
|
||||
info.get_properties = GetWASAPIPropertiesOutput;
|
||||
obs_register_source(&info);
|
||||
}
|
||||
|
Reference in New Issue
Block a user