Skip to content

Commit

Permalink
Merge branch 'streamlabs' into do_29_sq3
Browse files Browse the repository at this point in the history
  • Loading branch information
summeroff authored Nov 1, 2023
2 parents 0499c98 + 91126a4 commit 3cdce1a
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main-streamlabs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
shell: powershell
- name: Install specific version of AWS CLI
run: |
$version = "2.12.4"
$version = "2.13.24"
$zipfile = "AWSCLIV2.zip"
Invoke-WebRequest -OutFile $zipfile "https://awscli.amazonaws.com/AWSCLIV2-$version.msi"
Start-Process msiexec.exe -Wait -ArgumentList "/i $zipfile /qn"
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
[submodule "plugins/obs-vst"]
path = plugins/sl-vst
url = https://github.com/stream-labs/obs-vst.git
[submodule "plugins/win-spout"]
path = plugins/win-spout
url = https://github.com/stream-labs/obs-spout2-plugin.git
6 changes: 4 additions & 2 deletions CI/check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

if [ ${#} -eq 1 ]; then
VERBOSITY="--verbose"
Expand Down Expand Up @@ -50,7 +51,8 @@ find . -type d \( \
-path ./plugins/sl-vst -o \
-path ./plugins/mac-syphon/syphon-framework -o \
-path ./plugins/obs-outputs/ftl-sdk -o \
-path ./plugins/obs-websocket/deps \
-path ./plugins/obs-websocket/deps -o \
-path ./plugins/win-spout/deps \
\) -prune -false -type f -o \
-name '*.h' -or \
-name '*.hpp' -or \
Expand All @@ -60,4 +62,4 @@ find . -type d \( \
-name '*.cpp' \
| xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none

git diff
git diff
Binary file added dependencies/win-spout.dll.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion libobs/audio-monitoring/win32/wasapi-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct audio_monitor {
SRWLOCK playback_mutex;
};

/* #define DEBUG_AUDIO */
#define DEBUG_AUDIO

static bool process_audio_delay(struct audio_monitor *monitor, float **data,
uint32_t *frames, uint64_t ts, uint32_t pad)
Expand Down
4 changes: 2 additions & 2 deletions libobs/obs-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct ts_info {
uint64_t end;
};

#define DEBUG_AUDIO 0
#define DEBUG_LAGGED_AUDIO 0
#define DEBUG_AUDIO 1
#define DEBUG_LAGGED_AUDIO 1

// Cached state of multiple rendering so each run of in audio-io thread work with same state
static bool audio_multiple_rendering = false;
Expand Down
49 changes: 49 additions & 0 deletions libobs/obs-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const char *obs_encoder_get_display_name(const char *id)
static bool init_encoder(struct obs_encoder *encoder, const char *name,
obs_data_t *settings, obs_data_t *hotkey_data)
{
blog(LOG_INFO, "init_encoder - begin '%s' (%s) (0x%I64X)", name,
obs_encoder_get_id(encoder), encoder);

pthread_mutex_init_value(&encoder->init_mutex);
pthread_mutex_init_value(&encoder->callbacks_mutex);
pthread_mutex_init_value(&encoder->outputs_mutex);
Expand All @@ -71,6 +74,9 @@ static bool init_encoder(struct obs_encoder *encoder, const char *name,
encoder->orig_info.type_data);
}

blog(LOG_INFO, "init_encoder - end '%s' (%s) (0x%I64X)", name,
obs_encoder_get_id(encoder), encoder);

return true;
}

Expand Down Expand Up @@ -188,6 +194,9 @@ static inline bool gpu_encode_available(const struct obs_encoder *encoder)

static void add_connection(struct obs_encoder *encoder)
{
blog(LOG_INFO, "add_connection '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);
if (encoder->info.type == OBS_ENCODER_AUDIO) {
struct audio_convert_info audio_info = {0};
get_audio_info(encoder, &audio_info);
Expand All @@ -211,6 +220,10 @@ static void add_connection(struct obs_encoder *encoder)

static void remove_connection(struct obs_encoder *encoder, bool shutdown)
{
blog(LOG_INFO, "remove_connection - shutdown: %d '%s' (%s) (0x%I64X)",
shutdown, obs_encoder_get_name(encoder),
obs_encoder_get_id(encoder), encoder);

if (encoder->info.type == OBS_ENCODER_AUDIO) {
audio_output_disconnect(encoder->media, encoder->mixer_idx,
receive_audio, encoder);
Expand Down Expand Up @@ -244,6 +257,10 @@ static inline void free_audio_buffers(struct obs_encoder *encoder)
static void obs_encoder_actually_destroy(obs_encoder_t *encoder)
{
if (encoder) {
blog(LOG_INFO,
"obs_encoder_actually_destroy '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);
pthread_mutex_lock(&encoder->outputs_mutex);
for (size_t i = 0; i < encoder->outputs.num; i++) {
struct obs_output *output = encoder->outputs.array[i];
Expand Down Expand Up @@ -278,6 +295,10 @@ static void obs_encoder_actually_destroy(obs_encoder_t *encoder)
void obs_encoder_destroy(obs_encoder_t *encoder)
{
if (encoder) {
blog(LOG_INFO, "obs_encoder_destroy '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);

bool destroy;
set_encoder_active(encoder, false);
obs_context_data_remove(&encoder->context);
Expand Down Expand Up @@ -457,6 +478,10 @@ static inline bool obs_encoder_initialize_internal(obs_encoder_t *encoder)
if (encoder->initialized)
return true;

blog(LOG_INFO, "obs_encoder_initialize_internal '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);

encoder->destroy_on_stop = false;

obs_encoder_shutdown(encoder);
Expand Down Expand Up @@ -519,6 +544,24 @@ bool obs_encoder_initialize(obs_encoder_t *encoder)

void obs_encoder_shutdown(obs_encoder_t *encoder)
{
blog(LOG_INFO, "obs_encoder_shutdown '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);

// Unpairing encoders, if any
if (encoder->paired_encoder) {
pthread_mutex_lock(&encoder->paired_encoder->init_mutex);

blog(LOG_INFO,
"obs_encoder_shutdown - unpair '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder->paired_encoder),
obs_encoder_get_id(encoder->paired_encoder),
encoder->paired_encoder);

encoder->paired_encoder->paired_encoder = NULL;
pthread_mutex_unlock(&encoder->paired_encoder->init_mutex);
}

pthread_mutex_lock(&encoder->init_mutex);
if (encoder->context.data) {
encoder->info.destroy(encoder->context.data);
Expand Down Expand Up @@ -562,6 +605,9 @@ static inline void obs_encoder_start_internal(
void (*new_packet)(void *param, struct encoder_packet *packet),
void *param)
{
blog(LOG_INFO, "obs_encoder_start_internal '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);
struct encoder_callback cb = {false, new_packet, param};
bool first = false;

Expand Down Expand Up @@ -607,6 +653,9 @@ static inline bool obs_encoder_stop_internal(
void (*new_packet)(void *param, struct encoder_packet *packet),
void *param)
{
blog(LOG_INFO, "obs_encoder_stop_internal '%s' (%s) (0x%I64X)",
obs_encoder_get_name(encoder), obs_encoder_get_id(encoder),
encoder);
bool last = false;
size_t idx;

Expand Down
1 change: 1 addition & 0 deletions libobs/obs-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ struct obs_core_data {
struct obs_view main_view;
struct obs_view stream_view;
struct obs_view record_view;
struct obs_view backstage_view;

long long unnamed_index;

Expand Down
16 changes: 11 additions & 5 deletions libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,19 @@ obs_source_create_internal(const char *id, const char *name,
if (!private)
obs_source_init_audio_hotkeys(source);

/* allow the source to be created even if creation fails so that the
* user's data doesn't become lost */
if (info && info->create)
if (info && info->create) {
// The |info->create| function description is "Creates the source data for the source".
// So if the function returns nullptr, we consider that the function fails.
// If a source does not need to create any data, the function either should be nullptr itself or
// return the |source| pointer as its data.
source->context.data =
info->create(source->context.settings, source);
if ((!info || info->create) && !source->context.data)
blog(LOG_ERROR, "Failed to create source '%s'!", name);
if (!source->context.data) {
// We cannot ignore the error because it causes crashes later.
blog(LOG_ERROR, "Failed to create data for the source '%s'!", name);
goto fail;
}
}

blog(LOG_DEBUG, "%ssource '%s' (%s) created", private ? "private " : "",
name, id);
Expand Down
8 changes: 8 additions & 0 deletions libobs/obs-video-gpu-encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

static void *gpu_encode_thread(struct obs_core_video_mix *video)
{
blog(LOG_INFO, "gpu_encode_thread (0x%I64X)", video);
uint64_t interval = video_output_get_frame_time(video->video);
DARRAY(obs_encoder_t *) encoders;
int wait_frames = NUM_ENCODE_TEXTURE_FRAMES_TO_WAIT;
Expand Down Expand Up @@ -150,6 +151,7 @@ static void *gpu_encode_thread(struct obs_core_video_mix *video)

bool init_gpu_encoding(struct obs_core_video_mix *video)
{
blog(LOG_INFO, "init_gpu_encoding - begin (0x%I64X)", video);
#ifdef _WIN32
const struct video_output_info *info =
video_output_get_info(video->video);
Expand Down Expand Up @@ -205,15 +207,20 @@ bool init_gpu_encoding(struct obs_core_video_mix *video)
void stop_gpu_encoding_thread(struct obs_core_video_mix *video)
{
if (video->gpu_encode_thread_initialized) {
blog(LOG_INFO, "stop_gpu_encoding_thread - begin (0x%I64X)",
video);
os_atomic_set_bool(&video->gpu_encode_stop, true);
os_sem_post(video->gpu_encode_semaphore);
pthread_join(video->gpu_encode_thread, NULL);
video->gpu_encode_thread_initialized = false;
blog(LOG_INFO, "stop_gpu_encoding_thread - end (0x%I64X)",
video);
}
}

void free_gpu_encoding(struct obs_core_video_mix *video)
{
blog(LOG_INFO, "free_gpu_encoding - begin (0x%I64X)", video);
if (video->gpu_encode_semaphore) {
os_sem_destroy(video->gpu_encode_semaphore);
video->gpu_encode_semaphore = NULL;
Expand All @@ -237,4 +244,5 @@ void free_gpu_encoding(struct obs_core_video_mix *video)
free_circlebuf(video->gpu_encoder_queue);
free_circlebuf(video->gpu_encoder_avail_queue);
#undef free_circlebuf
blog(LOG_INFO, "free_gpu_encoding - end (0x%I64X)", video);
}
Loading

0 comments on commit 3cdce1a

Please sign in to comment.