Revert "win-dshow: Save and restore video device config props"

This reverts commit a36b5bee99a03a22af50c1c5ed0d8f321d9c129c.

After this commit was merged, apparently devices were not functioning
correctly for some people. Especially regarding their internal settings.
Just revert it for now.
master
jp9000 2022-09-02 17:33:47 -07:00
parent 2f8d28f7fa
commit bfa2053b08
1 changed files with 0 additions and 123 deletions

View File

@ -177,7 +177,6 @@ enum class Action {
ConfigAudio, ConfigAudio,
ConfigCrossbar1, ConfigCrossbar1,
ConfigCrossbar2, ConfigCrossbar2,
SaveSettings,
}; };
static DWORD CALLBACK DShowThread(LPVOID ptr); static DWORD CALLBACK DShowThread(LPVOID ptr);
@ -205,7 +204,6 @@ struct DShowInput {
WinHandle semaphore; WinHandle semaphore;
WinHandle activated_event; WinHandle activated_event;
WinHandle saved_event;
WinHandle thread; WinHandle thread;
CriticalSection mutex; CriticalSection mutex;
vector<Action> actions; vector<Action> actions;
@ -245,10 +243,6 @@ struct DShowInput {
if (!activated_event) if (!activated_event)
throw "Failed to create activated_event"; throw "Failed to create activated_event";
saved_event = CreateEvent(nullptr, false, false, nullptr);
if (!saved_event)
throw "Failed to create saved_event";
thread = thread =
CreateThread(nullptr, 0, DShowThread, this, 0, nullptr); CreateThread(nullptr, 0, DShowThread, this, 0, nullptr);
if (!thread) if (!thread)
@ -293,8 +287,6 @@ struct DShowInput {
bool UpdateVideoConfig(obs_data_t *settings); bool UpdateVideoConfig(obs_data_t *settings);
bool UpdateAudioConfig(obs_data_t *settings); bool UpdateAudioConfig(obs_data_t *settings);
bool UpdateVideoProperties(obs_data_t *settings);
void SaveVideoProperties();
void SetActive(bool active); void SetActive(bool active);
inline enum video_colorspace GetColorSpace(obs_data_t *settings) const; inline enum video_colorspace GetColorSpace(obs_data_t *settings) const;
inline enum video_range_type GetColorRange(obs_data_t *settings) const; inline enum video_range_type GetColorRange(obs_data_t *settings) const;
@ -389,9 +381,6 @@ void DShowInput::DShowLoop()
device.OpenDialog(nullptr, DialogType::ConfigCrossbar2); device.OpenDialog(nullptr, DialogType::ConfigCrossbar2);
break; break;
case Action::SaveSettings:
SaveVideoProperties();
break;
case Action::None:; case Action::None:;
} }
} }
@ -1029,102 +1018,6 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
return true; return true;
} }
bool DShowInput::UpdateVideoProperties(obs_data_t *settings)
{
OBSDataArrayAutoRelease cca =
obs_data_get_array(settings, "CameraControl");
if (cca) {
std::vector<VideoDeviceProperty> properties;
const auto count = obs_data_array_count(cca);
for (size_t i = 0; i < count; i++) {
OBSDataAutoRelease item = obs_data_array_item(cca, i);
if (!item)
continue;
VideoDeviceProperty prop{};
prop.property =
(long)obs_data_get_int(item, "property");
prop.flags = (long)obs_data_get_int(item, "flags");
prop.val = (long)obs_data_get_int(item, "val");
properties.push_back(prop);
}
if (!properties.empty()) {
device.SetCameraControlProperties(&properties);
}
}
OBSDataArrayAutoRelease vpaa =
obs_data_get_array(settings, "VideoProcAmp");
if (vpaa) {
std::vector<VideoDeviceProperty> properties;
const auto count = obs_data_array_count(vpaa);
for (size_t i = 0; i < count; i++) {
OBSDataAutoRelease item = obs_data_array_item(vpaa, i);
if (!item)
continue;
VideoDeviceProperty prop{};
prop.property =
(long)obs_data_get_int(item, "property");
prop.flags = (long)obs_data_get_int(item, "flags");
prop.val = (long)obs_data_get_int(item, "val");
properties.push_back(prop);
}
if (!properties.empty()) {
device.SetVideoProcAmpProperties(&properties);
}
}
return true;
}
void DShowInput::SaveVideoProperties()
{
OBSDataAutoRelease settings = obs_source_get_settings(source);
if (!settings) {
SetEvent(saved_event);
return;
}
std::vector<VideoDeviceProperty> properties;
OBSDataArrayAutoRelease ccp = obs_data_array_create();
if (device.GetCameraControlProperties(properties)) {
for (const auto property : properties) {
OBSDataAutoRelease obj = obs_data_create();
obs_data_set_int(obj, "property", property.property);
obs_data_set_int(obj, "flags", property.flags);
obs_data_set_int(obj, "val", property.val);
obs_data_array_push_back(ccp, obj);
}
}
obs_data_set_array(settings, "CameraControl", ccp);
properties.clear();
OBSDataArrayAutoRelease vpap = obs_data_array_create();
if (device.GetVideoProcAmpProperties(properties)) {
for (const auto property : properties) {
OBSDataAutoRelease obj = obs_data_create();
obs_data_set_int(obj, "property", property.property);
obs_data_set_int(obj, "flags", property.flags);
obs_data_set_int(obj, "val", property.val);
obs_data_array_push_back(vpap, obj);
}
}
obs_data_set_array(settings, "VideoProcAmp", vpap);
SetEvent(saved_event);
}
bool DShowInput::UpdateAudioConfig(obs_data_t *settings) bool DShowInput::UpdateAudioConfig(obs_data_t *settings)
{ {
string audio_device_id = obs_data_get_string(settings, AUDIO_DEVICE_ID); string audio_device_id = obs_data_get_string(settings, AUDIO_DEVICE_ID);
@ -1262,11 +1155,6 @@ inline bool DShowInput::Activate(obs_data_t *settings)
if (device.Start() != Result::Success) if (device.Start() != Result::Success)
return false; return false;
if (!UpdateVideoProperties(settings)) {
blog(LOG_WARNING, "%s: Setting video device properties failed",
obs_source_get_name(source));
}
const enum video_colorspace cs = GetColorSpace(settings); const enum video_colorspace cs = GetColorSpace(settings);
const enum video_range_type range = GetColorRange(settings); const enum video_range_type range = GetColorRange(settings);
@ -1351,16 +1239,6 @@ static void UpdateDShowInput(void *data, obs_data_t *settings)
input->QueueActivate(settings); input->QueueActivate(settings);
} }
static void SaveDShowInput(void *data, obs_data_t *settings)
{
DShowInput *input = reinterpret_cast<DShowInput *>(data);
if (!input->active)
return;
input->QueueAction(Action::SaveSettings);
WaitForSingleObject(input->saved_event, INFINITE);
}
static void GetDShowDefaults(obs_data_t *settings) static void GetDShowDefaults(obs_data_t *settings)
{ {
obs_data_set_default_int(settings, FRAME_INTERVAL, FPS_MATCHING); obs_data_set_default_int(settings, FRAME_INTERVAL, FPS_MATCHING);
@ -2223,7 +2101,6 @@ void RegisterDShowSource()
info.update = UpdateDShowInput; info.update = UpdateDShowInput;
info.get_defaults = GetDShowDefaults; info.get_defaults = GetDShowDefaults;
info.get_properties = GetDShowProperties; info.get_properties = GetDShowProperties;
info.save = SaveDShowInput;
info.icon_type = OBS_ICON_TYPE_CAMERA; info.icon_type = OBS_ICON_TYPE_CAMERA;
obs_register_source(&info); obs_register_source(&info);
} }