mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 12:25:11 +00:00
source-mirror: Don't render scene items with 0 size
libOBS will simply forget to unlock a mutex if you set the boundary size to zero, resulting in the filters dialog for that source simply getting stuck. Why video rendering can affect the audio filter dialogs is a question for another time, but it's best to just accept it and move on.
This commit is contained in:
parent
5738e51e73
commit
4fc25cfd8d
1 changed files with 43 additions and 42 deletions
|
@ -347,7 +347,7 @@ void source::mirror::mirror_instance::acquire_input(std::string source_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If everything worked fine, we now set everything up.
|
// If everything worked fine, we now set everything up.
|
||||||
this->m_source = std::move(new_source);
|
this->m_source = new_source;
|
||||||
this->m_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this,
|
this->m_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this,
|
||||||
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_AUDIO) != 0) {
|
if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_AUDIO) != 0) {
|
||||||
|
@ -395,25 +395,26 @@ source::mirror::mirror_instance::~mirror_instance()
|
||||||
|
|
||||||
uint32_t source::mirror::mirror_instance::get_width()
|
uint32_t source::mirror::mirror_instance::get_width()
|
||||||
{
|
{
|
||||||
|
if (m_source) {
|
||||||
if (this->m_rescale_enabled && this->m_rescale_width > 0 && !this->m_rescale_keep_orig_size) {
|
if (this->m_rescale_enabled && this->m_rescale_width > 0 && !this->m_rescale_keep_orig_size) {
|
||||||
return this->m_rescale_width;
|
return this->m_rescale_width;
|
||||||
|
} else {
|
||||||
|
return m_source->width();
|
||||||
}
|
}
|
||||||
obs_source_t* source = obs_sceneitem_get_source(this->m_source_item);
|
|
||||||
if (source) {
|
|
||||||
return obs_source_get_width(source);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t source::mirror::mirror_instance::get_height()
|
uint32_t source::mirror::mirror_instance::get_height()
|
||||||
{
|
{
|
||||||
if (this->m_rescale_enabled && this->m_rescale_height > 0 && !this->m_rescale_keep_orig_size)
|
if (m_source) {
|
||||||
|
if (this->m_rescale_enabled && this->m_rescale_height > 0 && !this->m_rescale_keep_orig_size) {
|
||||||
return this->m_rescale_height;
|
return this->m_rescale_height;
|
||||||
obs_source_t* source = obs_sceneitem_get_source(this->m_source_item);
|
} else {
|
||||||
if (source) {
|
return m_source->height();
|
||||||
return obs_source_get_height(source);
|
|
||||||
}
|
}
|
||||||
return 1;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void source::mirror::mirror_instance::update(obs_data_t* data)
|
void source::mirror::mirror_instance::update(obs_data_t* data)
|
||||||
|
@ -471,7 +472,7 @@ void source::mirror::mirror_instance::activate()
|
||||||
this->m_active = true;
|
this->m_active = true;
|
||||||
|
|
||||||
// No source, delayed acquire.
|
// No source, delayed acquire.
|
||||||
if (!this->m_source_item) {
|
if (!this->m_source_item && this->m_source_name.length() > 0) {
|
||||||
this->acquire_input(this->m_source_name.c_str());
|
this->acquire_input(this->m_source_name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,33 +499,30 @@ void source::mirror::mirror_instance::video_tick(float time)
|
||||||
this->m_tick -= 0.1f;
|
this->m_tick -= 0.1f;
|
||||||
|
|
||||||
// No source, delayed acquire.
|
// No source, delayed acquire.
|
||||||
if (!this->m_source_item) {
|
if (!this->m_source_item && this->m_source_name.length() > 0) {
|
||||||
this->acquire_input(this->m_source_name.c_str());
|
this->acquire_input(this->m_source_name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Scene Item Boundaries
|
// Update Scene Item Boundaries
|
||||||
if (this->m_source_item) {
|
if ((this->m_source_item && this->m_source)
|
||||||
|
&& ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_VIDEO) != 0)) {
|
||||||
obs_transform_info info;
|
obs_transform_info info;
|
||||||
obs_sceneitem_get_info(this->m_source_item, &info);
|
|
||||||
|
|
||||||
info.pos.x = 0;
|
info.pos.x = 0;
|
||||||
info.pos.y = 0;
|
info.pos.y = 0;
|
||||||
info.rot = 0;
|
info.rot = 0;
|
||||||
info.scale.x = 1.f;
|
info.scale.x = 1.f;
|
||||||
info.scale.y = 1.f;
|
info.scale.y = 1.f;
|
||||||
info.bounds.x = float_t(this->m_source->width());
|
info.alignment = 4;
|
||||||
info.bounds.y = float_t(this->m_source->height());
|
info.bounds.x = this->get_width();
|
||||||
|
info.bounds.y = this->get_height();
|
||||||
|
info.bounds_alignment = 4;
|
||||||
info.bounds_type = obs_bounds_type::OBS_BOUNDS_STRETCH;
|
info.bounds_type = obs_bounds_type::OBS_BOUNDS_STRETCH;
|
||||||
|
|
||||||
if (this->m_rescale_enabled) {
|
if (this->m_rescale_enabled) {
|
||||||
info.bounds.x = float_t(this->m_rescale_width);
|
|
||||||
info.bounds.y = float_t(this->m_rescale_height);
|
|
||||||
info.bounds_type = this->m_rescale_bounds;
|
info.bounds_type = this->m_rescale_bounds;
|
||||||
}
|
}
|
||||||
obs_sceneitem_set_info(this->m_source_item, &info);
|
obs_sceneitem_set_info(this->m_source_item, &info);
|
||||||
obs_sceneitem_force_update_transform(this->m_source_item);
|
obs_sceneitem_force_update_transform(this->m_source_item);
|
||||||
|
|
||||||
obs_sceneitem_set_scale_filter(this->m_source_item, this->m_rescale_enabled ? this->m_rescale_type
|
obs_sceneitem_set_scale_filter(this->m_source_item, this->m_rescale_enabled ? this->m_rescale_type
|
||||||
: obs_scale_type::OBS_SCALE_POINT);
|
: obs_scale_type::OBS_SCALE_POINT);
|
||||||
}
|
}
|
||||||
|
@ -535,7 +533,7 @@ void source::mirror::mirror_instance::video_tick(float time)
|
||||||
void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
||||||
{
|
{
|
||||||
if ((this->m_rescale_width == 0) || (this->m_rescale_height == 0) || !this->m_source_item
|
if ((this->m_rescale_width == 0) || (this->m_rescale_height == 0) || !this->m_source_item
|
||||||
|| !this->m_scene_texture_renderer) {
|
|| !this->m_scene_texture_renderer || !this->m_source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,6 +561,7 @@ void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_scene_texture) {
|
||||||
// Use default effect unless we are provided a different effect.
|
// Use default effect unless we are provided a different effect.
|
||||||
if (!effect) {
|
if (!effect) {
|
||||||
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
|
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
|
||||||
|
@ -574,6 +573,7 @@ void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
||||||
gs_draw_sprite(m_scene_texture->get_object(), 0, this->get_width(), this->get_height());
|
gs_draw_sprite(m_scene_texture->get_object(), 0, this->get_width(), this->get_height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void source::mirror::mirror_instance::audio_output_cb()
|
void source::mirror::mirror_instance::audio_output_cb()
|
||||||
{
|
{
|
||||||
|
@ -602,9 +602,10 @@ void source::mirror::mirror_instance::load(obs_data_t* data)
|
||||||
|
|
||||||
void source::mirror::mirror_instance::save(obs_data_t* data)
|
void source::mirror::mirror_instance::save(obs_data_t* data)
|
||||||
{
|
{
|
||||||
if (this->m_source_item) {
|
if (!this->m_source_item || !this->m_source) {
|
||||||
obs_data_set_string(data, P_SOURCE, obs_source_get_name(m_source->get()));
|
return;
|
||||||
}
|
}
|
||||||
|
obs_data_set_string(data, P_SOURCE, obs_source_get_name(m_source->get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string)
|
void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string)
|
||||||
|
|
Loading…
Reference in a new issue