Skip to content

Commit

Permalink
Remove recapture rate option
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbez committed Oct 31, 2021
1 parent a09baa9 commit 01f0551
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 75 deletions.
8 changes: 1 addition & 7 deletions data/locale/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,4 @@ Window.Priority.Exe="Match title, otherwise find window of same executable"
Hotkey.Start="Capture foreground window"
Hotkey.Stop="Deactivate capture"

ExcludeProcessTree="Capture all audio EXCEPT the selected window"

RecaptureRate="Recapture Rate"
RecaptureRate.Slow="Slow"
RecaptureRate.Normal="Normal (recommended)"
RecaptureRate.Fast="Fast"
RecaptureRate.Fastest="Fastest"
ExcludeProcessTree="Capture all audio EXCEPT the selected window"
36 changes: 3 additions & 33 deletions src/audio-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@ VOID CALLBACK set_update(PVOID lpParam, BOOLEAN TimerOrWaitFired)
SetEvent(ctx->events[EVENT_UPDATE]);
}

void set_update_timer(audio_capture_context_t *ctx, float interval)
void set_update_timer(audio_capture_context_t *ctx)
{
EnterCriticalSection(&ctx->timer_section);

EnterCriticalSection(&ctx->config_section);
DWORD time_millis =
(DWORD)(ctx->config.retry_interval * interval * 1000.0);
LeaveCriticalSection(&ctx->config_section);

if (ctx->timer != NULL) {
DeleteTimerQueueTimer(ctx->timer_queue, ctx->timer,
INVALID_HANDLE_VALUE);
ctx->timer = NULL;
}

// debug("setting timer for %ld millis", time_millis);
CreateTimerQueueTimer(&ctx->timer, ctx->timer_queue, set_update, ctx,
time_millis, 0, WT_EXECUTEINTIMERTHREAD);
2000, 0, WT_EXECUTEINTIMERTHREAD);

LeaveCriticalSection(&ctx->timer_section);
}
Expand Down Expand Up @@ -106,7 +100,7 @@ static void audio_capture_worker_recapture(audio_capture_context_t *ctx)
if (ctx->process_id != 0)
start_capture(ctx);
else if (ctx->window_selected)
set_update_timer(ctx, RECAPTURE_INTERVAL_DEFAULT);
set_update_timer(ctx);
}

static void audio_capture_worker_update(audio_capture_context_t *ctx)
Expand Down Expand Up @@ -254,9 +248,6 @@ static void audio_capture_update(void *data, obs_data_t *settings)
settings, SETTING_WINDOW_PRIORITY),
.exclude_process_tree = obs_data_get_bool(
settings, SETTING_EXCLUDE_PROCESS_TREE),
.retry_interval = recapture_rate_to_float(
(recapture_rate)obs_data_get_int(
settings, SETTING_RECAPTURE_RATE)),
};

const char *window = obs_data_get_string(settings, SETTING_WINDOW);
Expand Down Expand Up @@ -294,11 +285,6 @@ static void audio_capture_update(void *data, obs_data_t *settings)
need_update = true;
}

if (ctx->config.retry_interval != new_config.retry_interval) {
ctx->config.retry_interval = new_config.retry_interval;
need_update = true;
}

LeaveCriticalSection(&ctx->config_section);

if (need_update)
Expand Down Expand Up @@ -552,20 +538,6 @@ static obs_properties_t *audio_capture_properties(void *data)
p = obs_properties_add_bool(ps, SETTING_EXCLUDE_PROCESS_TREE,
TEXT_EXCLUDE_PROCESS_TREE);

// Recapture rate setting
p = obs_properties_add_list(ps, SETTING_RECAPTURE_RATE,
TEXT_RECAPTURE_RATE, OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);

obs_property_list_add_int(p, TEXT_RECAPTURE_RATE_SLOW,
RECAPTURE_RATE_SLOW);
obs_property_list_add_int(p, TEXT_RECAPTURE_RATE_NORMAL,
RECAPTURE_RATE_NORMAL);
obs_property_list_add_int(p, TEXT_RECAPTURE_RATE_FAST,
RECAPTURE_RATE_FAST);
obs_property_list_add_int(p, TEXT_RECAPTURE_RATE_FASTEST,
RECAPTURE_RATE_FASTEST);

return ps;
}

Expand All @@ -577,8 +549,6 @@ static void audio_capture_defaults(obs_data_t *settings)
WINDOW_PRIORITY_EXE);
obs_data_set_default_bool(settings, SETTING_EXCLUDE_PROCESS_TREE,
false);
obs_data_set_default_int(settings, SETTING_RECAPTURE_RATE,
RECAPTURE_RATE_NORMAL);
}

static const char *audio_capture_get_name(void *type_data)
Expand Down
35 changes: 0 additions & 35 deletions src/audio-capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#define SETTING_EXCLUDE_PROCESS_TREE "exclude_process_tree"

#define SETTING_RECAPTURE_RATE "recapture_rate"

#define TEXT_NAME obs_module_text("Name")

#define TEXT_MODE obs_module_text("Mode")
Expand All @@ -40,45 +38,13 @@

#define TEXT_EXCLUDE_PROCESS_TREE obs_module_text("ExcludeProcessTree")

#define TEXT_RECAPTURE_RATE obs_module_text("RecaptureRate")
#define TEXT_RECAPTURE_RATE_SLOW obs_module_text("RecaptureRate.Slow")
#define TEXT_RECAPTURE_RATE_NORMAL obs_module_text("RecaptureRate.Normal")
#define TEXT_RECAPTURE_RATE_FAST obs_module_text("RecaptureRate.Fast")
#define TEXT_RECAPTURE_RATE_FASTEST obs_module_text("RecaptureRate.Fastest")

#define HOTKEY_START "hotkey_start"
#define HOTKEY_STOP "hotkey_stop"

#define RECAPTURE_INTERVAL_DEFAULT 2.0f
#define RECAPTURE_INTERVAL_ERROR 4.0f

/* clang-format on */

enum mode { MODE_WINDOW, MODE_HOTKEY };

enum recapture_rate {
RECAPTURE_RATE_SLOW,
RECAPTURE_RATE_NORMAL,
RECAPTURE_RATE_FAST,
RECAPTURE_RATE_FASTEST
};

static inline float recapture_rate_to_float(enum recapture_rate rate)
{
switch (rate) {
case RECAPTURE_RATE_SLOW:
return 2.0f;
case RECAPTURE_RATE_FAST:
return 0.5f;
case RECAPTURE_RATE_FASTEST:
return 0.1f;
case RECAPTURE_RATE_NORMAL:
/* FALLTHROUGH */
default:
return 1.0f;
}
}

struct audio_capture_config_t {
enum mode mode;
HWND hotkey_window;
Expand All @@ -87,7 +53,6 @@ struct audio_capture_config_t {
enum window_priority priority;

bool exclude_process_tree;
float retry_interval;
};

struct audio_capture_context_t {
Expand Down

0 comments on commit 01f0551

Please sign in to comment.