Skip to content

Commit fd0a79b

Browse files
committed
Fix: Prevent double notification for frame done in ST20P TX v2
1 parent 14ec9b6 commit fd0a79b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lib/src/st2110/pipeline/st20_pipeline_tx.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,10 @@ static int tx_st20p_frame_done(void* priv, uint16_t frame_idx,
130130
frame->epoch = meta->epoch;
131131
frame->rtp_timestamp = meta->rtp_timestamp;
132132

133-
if (ctx->ops.notify_frame_done) { /* notify app which frame done */
134-
/*
135-
** Skip notify if ext_frame is used and derive is false (input_fmt != transport_fmt).
136-
** In this case, the frame done notification is not needed since the notification is
137-
** already done after convert callback.
138-
** This is to avoid double notification for the same frame.
139-
*/
140-
if (!(ctx->ops.flags & ST20P_TX_FLAG_EXT_FRAME && !ctx->derive)) {
141-
ctx->ops.notify_frame_done(ctx->ops.priv, frame);
142-
}
133+
if (ctx->ops.notify_frame_done &&
134+
!framebuff->frame_done_cb_called) { /* notify app which frame done */
135+
ctx->ops.notify_frame_done(ctx->ops.priv, frame);
136+
framebuff->frame_done_cb_called = true;
143137
}
144138

145139
/* notify app can get frame */
@@ -610,6 +604,7 @@ struct st_frame* st20p_tx_get_frame(st20p_tx_handle handle) {
610604
}
611605

612606
framebuff->stat = ST20P_TX_FRAME_IN_USER;
607+
framebuff->frame_done_cb_called = false;
613608
/* point to next */
614609
ctx->framebuff_producer_idx = tx_st20p_next_idx(ctx, framebuff->idx);
615610
mt_pthread_mutex_unlock(&ctx->lock);
@@ -756,8 +751,10 @@ int st20p_tx_put_ext_frame(st20p_tx_handle handle, struct st_frame* frame,
756751
if (ctx->internal_converter) { /* convert internal */
757752
ctx->internal_converter->convert_func(&framebuff->src, &framebuff->dst);
758753
framebuff->stat = ST20P_TX_FRAME_CONVERTED;
759-
if (ctx->ops.notify_frame_done)
754+
if (ctx->ops.notify_frame_done && !framebuff->frame_done_cb_called) {
760755
ctx->ops.notify_frame_done(ctx->ops.priv, &framebuff->src);
756+
framebuff->frame_done_cb_called = true;
757+
}
761758
} else {
762759
framebuff->stat = ST20P_TX_FRAME_READY;
763760
st20_convert_notify_frame_ready(ctx->convert_impl);

lib/src/st2110/pipeline/st20_pipeline_tx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct st20p_tx_frame {
2727
void* user_meta; /* the meta data from user */
2828
size_t user_meta_buffer_size;
2929
size_t user_meta_data_size;
30+
bool frame_done_cb_called; /* frame done callback called */
3031
};
3132

3233
struct st20p_tx_ctx {

0 commit comments

Comments
 (0)