@@ -73,6 +73,9 @@ using std::atomic;
7373namespace {
7474struct state_video_compress_jpegxs ;
7575
76+ int jxs_poison_pill_obj = 0 ;
77+ #define JXS_POISON_PILL ((void *) &jxs_poison_pill_obj)
78+
7679struct state_video_compress_jpegxs {
7780 state_video_compress_jpegxs (struct module *parent, const char *opts);
7881
@@ -95,7 +98,6 @@ struct state_video_compress_jpegxs {
9598
9699 bool configured = 0 ;
97100 bool reconfiguring = 0 ;
98- bool stop = 0 ;
99101
100102 video_desc saved_desc;
101103
@@ -159,9 +161,9 @@ while (true) {
159161 s->out_queue .push (frame);
160162 {
161163 unique_lock<mutex> lock (s->mtx );
162- s->stop = true ;
163164 svt_jpeg_xs_frame_t enc_input;
164165 svt_jpeg_xs_frame_pool_get (s->frame_pool , &enc_input, /* blocking*/ 1 );
166+ enc_input.user_prv_ctx_ptr = JXS_POISON_PILL;
165167 svt_jpeg_xs_encoder_send_picture (&s->encoder , &enc_input, /* blocking*/ 1 );
166168 s->frames_sent ++;
167169 }
@@ -221,20 +223,17 @@ static void jpegxs_worker_get(state_video_compress_jpegxs *s) {
221223{
222224 unique_lock<mutex> lock (s->mtx );
223225 s->cv_configured .wait (lock, [&]{
224- return s->configured || s-> stop ;
226+ return s->configured ;
225227 });
226228
227- if (!s->configured && s-> stop ) {
229+ if (!s->configured ) {
228230 return ;
229231 }
230232}
231233while (true ) {
232234{
233235 unique_lock<mutex> lock (s->mtx );
234236 if (s->frames_received == s->frames_sent ) {
235- if (s->stop ) {
236- return ;
237- }
238237 if (s->reconfiguring ) {
239238 s->cv_drained .notify_one ();
240239 s->cv_reconfiguring .wait (lock, [&]{
@@ -250,6 +249,9 @@ while (true) {
250249 log_msg (LOG_LEVEL_ERROR, MOD_NAME " Failed to get encoded packet, error code: %x\n " , err);
251250 continue ;
252251 }
252+ if (enc_output.user_prv_ctx_ptr == JXS_POISON_PILL) {
253+ break ;
254+ }
253255 s->frames_received ++;
254256
255257 shared_ptr<video_frame> out_frame = s->pool .get_frame ();
0 commit comments