Skip to content

Commit

Permalink
support both circlebuf and deque
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Feb 3, 2024
1 parent 93a003d commit 6590fde
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ else()
cmake_minimum_required(VERSION 3.18)
endif()

project(replay-source VERSION 1.6.14)
project(replay-source VERSION 1.7.0)
set(PROJECT_FULL_NAME "Replay Source")

# Set new UUIDs when you start to create a new plugin.
Expand Down
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@
}
},
"name": "replay-source",
"version": "1.6.14"
"version": "1.7.0"
}
7 changes: 3 additions & 4 deletions replay-filter-async.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <obs-module.h>
#include <util/circlebuf.h>
#include <util/threading.h>
#include "replay.h"
#include "media-io/audio-math.h"
#include "replay.h"

static const char *replay_filter_get_name(void *unused)
{
Expand Down Expand Up @@ -113,11 +112,11 @@ replay_filter_video(void *data, struct obs_source_frame *frame)
pthread_mutex_t *async_mutex =
(pthread_mutex_t *)((uint8_t *)target +
filter->target_offset +
sizeof(struct darray)*2);
sizeof(struct darray) * 2);
pthread_mutex_lock(async_mutex);
for (size_t i = 0; i < async_cache->num; i++) {
struct obs_source_frame *extra_frame =
((struct async_frame*)async_cache->array)[i]
((struct async_frame *)async_cache->array)[i]
.frame;
if (extra_frame->timestamp + filter->timing_adjust >
last_timestamp) {
Expand Down
4 changes: 2 additions & 2 deletions replay-filter-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <media-io/video-frame.h>
#include <media-io/audio-math.h>
#include <media-io/audio-resampler.h>
#include <util/circlebuf.h>
#include "replay.h"

static const char *replay_filter_get_name(void *unused)
Expand Down Expand Up @@ -85,7 +84,8 @@ static obs_properties_t *replay_filter_properties(void *unused)
return props;
}

static void replay_filter_tick(void *data, float seconds){
static void replay_filter_tick(void *data, float seconds)
{
UNUSED_PARAMETER(seconds);
replay_filter_check(data);
}
Expand Down
1 change: 0 additions & 1 deletion replay-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <media-io/video-io.h>
#include <media-io/video-frame.h>
#include <media-io/audio-resampler.h>
#include <util/circlebuf.h>
#include "replay.h"

#define TEXFORMAT GS_BGRA
Expand Down
6 changes: 5 additions & 1 deletion replay-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ struct replay_source {

int replay_position;
int replay_max;
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 1, 0)
struct deque replays;
#else
struct circlebuf replays;
#endif
struct replay current_replay;
struct replay saving_replay;

Expand Down Expand Up @@ -1721,7 +1725,7 @@ void replay_step_frames(void *data, bool pressed, bool forward,
c->pause_timestamp += time_diff;
}
}

c->video_frame_position = next_pos;
}

Expand Down
2 changes: 1 addition & 1 deletion replay.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "replay.h"
#include "version.h"
#include <math.h>
#include "replay.h"

void free_audio_data(struct replay_filter *filter)
{
Expand Down
24 changes: 23 additions & 1 deletion replay.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
#pragma once
#include <obs-module.h>
#include <util/circlebuf.h>
#include <util/threading.h>

#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 1, 0)
#include <util/deque.h>
#define circlebuf_peek_front deque_peek_front
#define circlebuf_peek_back deque_peek_back
#define circlebuf_push_front deque_push_front
#define circlebuf_push_back deque_push_back
#define circlebuf_pop_front deque_pop_front
#define circlebuf_pop_back deque_pop_back
#define circlebuf_init deque_init
#define circlebuf_free deque_free
#define circlebuf_data deque_data
#else
#include <util/circlebuf.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct replay_filter {

#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 1, 0)
/* contains struct obs_source_frame* */
struct deque video_frames;

/* stores the audio data */
struct deque audio_frames;
#else
/* contains struct obs_source_frame* */
struct circlebuf video_frames;

/* stores the audio data */
struct circlebuf audio_frames;
#endif

struct obs_video_info ovi;
struct audio_convert_info oai;
Expand Down
3 changes: 2 additions & 1 deletion win-dshow-replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ struct DShowReplayInput {
}

inline DShowReplayInput(obs_source_t *source_, obs_data_t *settings)
: source(source_), device(InitGraph::False)
: source(source_),
device(InitGraph::False)
{
memset(&audio, 0, sizeof(audio));
memset(&frame, 0, sizeof(frame));
Expand Down

0 comments on commit 6590fde

Please sign in to comment.