Skip to content

Commit

Permalink
remove unused filters
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Feb 18, 2019
1 parent 5dcac4f commit e909262
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 60 deletions.
4 changes: 3 additions & 1 deletion replay-filter-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static void *replay_filter_create(obs_data_t *settings, obs_source_t *source)
struct replay_filter *context = bzalloc(sizeof(struct replay_filter));
context->src = source;
pthread_mutex_init(&context->mutex, NULL);
context->last_check = obs_get_video_frame_time();

replay_filter_update(context, settings);

Expand Down Expand Up @@ -80,7 +81,7 @@ static struct obs_source_frame *replay_filter_video(void *data,
uint64_t last_timestamp = 0;

obs_source_t* target = filter->internal_frames ? obs_filter_get_parent(filter->src) : NULL;
const uint64_t os_time = os_gettime_ns();
const uint64_t os_time = obs_get_video_frame_time();
struct obs_source_frame *new_frame = NULL;

pthread_mutex_lock(&filter->mutex);
Expand Down Expand Up @@ -162,6 +163,7 @@ static struct obs_source_frame *replay_filter_video(void *data,
}
}
pthread_mutex_unlock(&filter->mutex);
replay_filter_check(filter);
return frame;
}

Expand Down
2 changes: 2 additions & 0 deletions replay-filter-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static void replay_filter_update(void *data, obs_data_t *settings)
filter->duration = new_duration;
const double db = obs_data_get_double(settings, SETTING_AUDIO_THRESHOLD);
filter->threshold = db_to_mul((float)db);

}


Expand All @@ -38,6 +39,7 @@ static void *replay_filter_create(obs_data_t *settings, obs_source_t *source)
struct replay_filter *context = bzalloc(sizeof(struct replay_filter));
context->src = source;
pthread_mutex_init(&context->mutex, NULL);
context->last_check = obs_get_video_frame_time();

replay_filter_update(context, settings);

Expand Down
20 changes: 19 additions & 1 deletion replay-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void replay_filter_offscreen_render(void* data, uint32_t cx, uint32_t cy)

struct video_frame output_frame;
if (filter->video_output && video_output_lock_frame(filter->video_output,
&output_frame, 1, os_gettime_ns()))
&output_frame, 1, obs_get_video_frame_time()))
{
if (filter->video_data) {
gs_stagesurface_unmap(filter->stagesurface);
Expand Down Expand Up @@ -179,6 +179,22 @@ static void replay_filter_update(void *data, obs_data_t *settings)
filter->duration = new_duration;

obs_add_main_render_callback(replay_filter_offscreen_render, filter);

replay_filter_check(filter);

obs_source_t * s = obs_get_source_by_name(obs_source_get_name(filter->src));
if(s)
{
if(obs_data_get_bool(settings, SETTING_SOUND_TRIGGER) && !filter->trigger_threshold)
{
filter->threshold_data = (struct replay_source*)s->context.data;
filter->trigger_threshold = replay_trigger_threshold;
}
obs_source_release(s);
}else
{
obs_source_filter_remove(obs_filter_get_parent(filter->src),filter->src);
}
}


Expand All @@ -194,6 +210,7 @@ static void *replay_filter_create(obs_data_t *settings, obs_source_t *source)
context->video_data = NULL;
obs_get_video_info(&context->ovi);
obs_get_audio_info(&context->oai);
context->last_check = obs_get_video_frame_time();


replay_filter_update(context, settings);
Expand Down Expand Up @@ -249,6 +266,7 @@ void replay_filter_tick(void* data, float seconds)
{
struct replay_filter *filter = data;
obs_get_video_info(&filter->ovi);
replay_filter_check(filter);
}

void replay_filter_video_render(void* data, gs_effect_t* effect)
Expand Down
Loading

0 comments on commit e909262

Please sign in to comment.