libobs: Fix texture-based encoder decklock
Ensures that there are no textures being encoded before attempting to shut down a texture-based encoder.
This commit is contained in:
parent
c284d26163
commit
b029453d30
@ -271,6 +271,7 @@ struct obs_core_video {
|
|||||||
struct circlebuf gpu_encoder_avail_queue;
|
struct circlebuf gpu_encoder_avail_queue;
|
||||||
DARRAY(obs_encoder_t *) gpu_encoders;
|
DARRAY(obs_encoder_t *) gpu_encoders;
|
||||||
os_sem_t *gpu_encode_semaphore;
|
os_sem_t *gpu_encode_semaphore;
|
||||||
|
os_event_t *gpu_encode_inactive;
|
||||||
pthread_t gpu_encode_thread;
|
pthread_t gpu_encode_thread;
|
||||||
bool gpu_encode_thread_initialized;
|
bool gpu_encode_thread_initialized;
|
||||||
volatile bool gpu_encode_stop;
|
volatile bool gpu_encode_stop;
|
||||||
|
@ -44,6 +44,8 @@ static void *gpu_encode_thread(void *unused)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os_event_reset(video->gpu_encode_inactive);
|
||||||
|
|
||||||
/* -------------- */
|
/* -------------- */
|
||||||
|
|
||||||
pthread_mutex_lock(&video->gpu_encoder_mutex);
|
pthread_mutex_lock(&video->gpu_encoder_mutex);
|
||||||
@ -128,6 +130,8 @@ static void *gpu_encode_thread(void *unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&video->gpu_encoder_mutex);
|
pthread_mutex_unlock(&video->gpu_encoder_mutex);
|
||||||
|
|
||||||
|
os_event_signal(video->gpu_encode_inactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
da_free(encoders);
|
da_free(encoders);
|
||||||
@ -168,10 +172,14 @@ bool init_gpu_encoding(struct obs_core_video *video)
|
|||||||
|
|
||||||
if (os_sem_init(&video->gpu_encode_semaphore, 0) != 0)
|
if (os_sem_init(&video->gpu_encode_semaphore, 0) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
if (os_event_init(&video->gpu_encode_inactive, OS_EVENT_TYPE_MANUAL) != 0)
|
||||||
|
return false;
|
||||||
if (pthread_create(&video->gpu_encode_thread, NULL,
|
if (pthread_create(&video->gpu_encode_thread, NULL,
|
||||||
gpu_encode_thread, NULL) != 0)
|
gpu_encode_thread, NULL) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
os_event_signal(video->gpu_encode_inactive);
|
||||||
|
|
||||||
video->gpu_encode_thread_initialized = true;
|
video->gpu_encode_thread_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@ -196,6 +204,10 @@ void free_gpu_encoding(struct obs_core_video *video)
|
|||||||
os_sem_destroy(video->gpu_encode_semaphore);
|
os_sem_destroy(video->gpu_encode_semaphore);
|
||||||
video->gpu_encode_semaphore = NULL;
|
video->gpu_encode_semaphore = NULL;
|
||||||
}
|
}
|
||||||
|
if (video->gpu_encode_inactive) {
|
||||||
|
os_event_destroy(video->gpu_encode_inactive);
|
||||||
|
video->gpu_encode_inactive = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#define free_circlebuf(x) \
|
#define free_circlebuf(x) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -2365,6 +2365,8 @@ void stop_gpu_encode(obs_encoder_t *encoder)
|
|||||||
call_free = true;
|
call_free = true;
|
||||||
pthread_mutex_unlock(&video->gpu_encoder_mutex);
|
pthread_mutex_unlock(&video->gpu_encoder_mutex);
|
||||||
|
|
||||||
|
os_event_wait(video->gpu_encode_inactive);
|
||||||
|
|
||||||
if (call_free) {
|
if (call_free) {
|
||||||
stop_gpu_encoding_thread(video);
|
stop_gpu_encoding_thread(video);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user