mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
libobs: Shut down encoder when not in use
This prevents encoders (hardware encoders in particular) from being continually active when all outputs disconnect from an encoder. This is mostly just a temporary measure; the encoding interface may need a bit of a redesign. It will also definitely needs to be able to flush at some point. Currently when an output is stopped, the pending data is discarded, which needs to be fixed.
This commit is contained in:
parent
af310fb556
commit
fa7286f84c
@ -197,6 +197,7 @@ static void remove_connection(struct obs_encoder *encoder)
|
||||
video_output_disconnect(encoder->media, receive_video,
|
||||
encoder);
|
||||
|
||||
obs_encoder_shutdown(encoder);
|
||||
encoder->active = false;
|
||||
}
|
||||
|
||||
@ -368,9 +369,8 @@ bool obs_encoder_initialize(obs_encoder_t *encoder)
|
||||
|
||||
if (encoder->active)
|
||||
return true;
|
||||
|
||||
if (encoder->context.data)
|
||||
encoder->info.destroy(encoder->context.data);
|
||||
return false;
|
||||
|
||||
if (encoder->info.create)
|
||||
encoder->context.data = encoder->info.create(
|
||||
@ -387,6 +387,14 @@ bool obs_encoder_initialize(obs_encoder_t *encoder)
|
||||
return true;
|
||||
}
|
||||
|
||||
void obs_encoder_shutdown(obs_encoder_t *encoder)
|
||||
{
|
||||
if (encoder->context.data) {
|
||||
encoder->info.destroy(encoder->context.data);
|
||||
encoder->context.data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline size_t get_callback_idx(
|
||||
const struct obs_encoder *encoder,
|
||||
void (*new_packet)(void *param, struct encoder_packet *packet),
|
||||
|
@ -770,6 +770,7 @@ struct obs_encoder {
|
||||
extern struct obs_encoder_info *find_encoder(const char *id);
|
||||
|
||||
extern bool obs_encoder_initialize(obs_encoder_t *encoder);
|
||||
extern void obs_encoder_shutdown(obs_encoder_t *encoder);
|
||||
|
||||
extern void obs_encoder_start(obs_encoder_t *encoder,
|
||||
void (*new_packet)(void *param, struct encoder_packet *packet),
|
||||
|
Loading…
Reference in New Issue
Block a user