mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
source-mirror: Release source and fix compiler warnings
This commit is contained in:
parent
a307283349
commit
734ea577b8
2 changed files with 11 additions and 8 deletions
|
@ -113,13 +113,13 @@ bool Source::MirrorAddon::modified_properties(obs_properties_t *pr, obs_property
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateSourceListCB(void *ptr, obs_source_t* src) {
|
static bool UpdateSourceListCB(void *ptr, obs_source_t* src) {
|
||||||
obs_property_t* p = (obs_property_t*)ptr;
|
obs_property_t* p = (obs_property_t*)ptr;
|
||||||
obs_property_list_add_string(p, obs_source_get_name(src), obs_source_get_name(src));
|
obs_property_list_add_string(p, obs_source_get_name(src), obs_source_get_name(src));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSourceList(obs_property_t* p) {
|
static void UpdateSourceList(obs_property_t* p) {
|
||||||
obs_property_list_clear(p);
|
obs_property_list_clear(p);
|
||||||
obs_enum_sources(UpdateSourceListCB, p);
|
obs_enum_sources(UpdateSourceListCB, p);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,8 @@ Source::Mirror::Mirror(obs_data_t* data, obs_source_t* src) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Source::Mirror::~Mirror() {
|
Source::Mirror::~Mirror() {
|
||||||
|
if (m_target)
|
||||||
|
obs_source_release(m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Source::Mirror::get_width() {
|
uint32_t Source::Mirror::get_width() {
|
||||||
|
@ -235,6 +236,8 @@ uint32_t Source::Mirror::get_height() {
|
||||||
void Source::Mirror::update(obs_data_t* data) {
|
void Source::Mirror::update(obs_data_t* data) {
|
||||||
// Update selected source.
|
// Update selected source.
|
||||||
const char* source = obs_data_get_string(data, P_SOURCE);
|
const char* source = obs_data_get_string(data, P_SOURCE);
|
||||||
|
if (m_target)
|
||||||
|
obs_source_release(m_target);
|
||||||
m_target = obs_get_source_by_name(source);
|
m_target = obs_get_source_by_name(source);
|
||||||
m_targetName = source;
|
m_targetName = source;
|
||||||
|
|
||||||
|
@ -324,7 +327,7 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
||||||
try {
|
try {
|
||||||
vec4 black; vec4_zero(&black);
|
vec4 black; vec4_zero(&black);
|
||||||
auto op = m_renderTarget->Render(sw, sh);
|
auto op = m_renderTarget->Render(sw, sh);
|
||||||
gs_ortho(0, sw, 0, sh, 0, 1);
|
gs_ortho(0, (float_t)sw, 0, (float_t)sh, 0, 1);
|
||||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||||
|
|
||||||
obs_source_video_render(m_target);
|
obs_source_video_render(m_target);
|
||||||
|
@ -345,7 +348,7 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
||||||
{
|
{
|
||||||
vec4 black; vec4_zero(&black);
|
vec4 black; vec4_zero(&black);
|
||||||
auto op = m_renderTargetScale->Render(m_width, m_height);
|
auto op = m_renderTargetScale->Render(m_width, m_height);
|
||||||
gs_ortho(0, m_width, 0, m_height, 0, 1);
|
gs_ortho(0, (float_t)m_width, 0, (float_t)m_height, 0, 1);
|
||||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||||
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
||||||
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
|
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
|
||||||
|
|
|
@ -66,8 +66,8 @@ namespace Source {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_active;
|
bool m_active;
|
||||||
obs_source_t* m_source;
|
obs_source_t* m_source = nullptr;
|
||||||
obs_source_t* m_target;
|
obs_source_t* m_target = nullptr;
|
||||||
std::string m_targetName;
|
std::string m_targetName;
|
||||||
|
|
||||||
bool m_rescale = false;
|
bool m_rescale = false;
|
||||||
|
@ -76,6 +76,6 @@ namespace Source {
|
||||||
std::unique_ptr<GS::RenderTarget> m_renderTarget;
|
std::unique_ptr<GS::RenderTarget> m_renderTarget;
|
||||||
std::unique_ptr<GS::RenderTarget> m_renderTargetScale;
|
std::unique_ptr<GS::RenderTarget> m_renderTargetScale;
|
||||||
std::shared_ptr<GS::Sampler> m_sampler;
|
std::shared_ptr<GS::Sampler> m_sampler;
|
||||||
gs_effect_t* m_scalingEffect;
|
gs_effect_t* m_scalingEffect = nullptr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue