libobs: Allow sending NULL to obs_encoder_set_video/audio()

There is currently no way to clear a video_t or audio_t object from an
encoder once applied. `audio_t`/`video_t` objects can be destructed at
any time, and it is dangerous to prevent these object references from
even being cleared.

This does not fix the issue where destroying an audio/video object does
not clear the reference from all subscribed encoders.
This commit is contained in:
tt2468
2023-01-15 20:17:21 -08:00
committed by John R. Bradley
parent dfc20bbb31
commit eb0d9dc5d2
+19 -14
View File
@@ -800,14 +800,16 @@ void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
return;
}
if (!video)
return;
voi = video_output_get_info(video);
encoder->media = video;
encoder->timebase_num = voi->fps_den;
encoder->timebase_den = voi->fps_num;
if (video) {
voi = video_output_get_info(video);
encoder->media = video;
encoder->timebase_num = voi->fps_den;
encoder->timebase_den = voi->fps_num;
} else {
encoder->media = NULL;
encoder->timebase_num = 0;
encoder->timebase_den = 0;
}
}
void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio)
@@ -829,12 +831,15 @@ void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio)
return;
}
if (!audio)
return;
encoder->media = audio;
encoder->timebase_num = 1;
encoder->timebase_den = audio_output_get_sample_rate(audio);
if (audio) {
encoder->media = audio;
encoder->timebase_num = 1;
encoder->timebase_den = audio_output_get_sample_rate(audio);
} else {
encoder->media = NULL;
encoder->timebase_num = 0;
encoder->timebase_den = 0;
}
}
video_t *obs_encoder_video(const obs_encoder_t *encoder)