diff --git a/src/hd-rum-translator/hd-rum-decompress.cpp b/src/hd-rum-translator/hd-rum-decompress.cpp index f5148c462..9de5d97f6 100644 --- a/src/hd-rum-translator/hd-rum-decompress.cpp +++ b/src/hd-rum-translator/hd-rum-decompress.cpp @@ -264,3 +264,17 @@ void hd_rum_decompress_append_port(void *state, void *recompress_state) s->frame_consumed_cv.wait(l, [s]{ return s->received_frame.size() == 0; }); } +int hd_rum_decompress_get_num_active_ports(void *state) +{ + struct state_transcoder_decompress *s = (struct state_transcoder_decompress *) state; + + int ret = 0; + for (auto && port : s->output_ports) { + if (port.active) { + ret += 1; + } + } + + return ret; +} + diff --git a/src/hd-rum-translator/hd-rum-decompress.h b/src/hd-rum-translator/hd-rum-decompress.h index 37a10e8a9..2a092153f 100644 --- a/src/hd-rum-translator/hd-rum-decompress.h +++ b/src/hd-rum-translator/hd-rum-decompress.h @@ -10,6 +10,7 @@ void hd_rum_decompress_done(void *state); void hd_rum_decompress_set_active(void *decompress_state, void *recompress_state, bool active); void hd_rum_decompress_remove_port(void *decompress_state, int index); void hd_rum_decompress_append_port(void *decompress_state, void *recompress_state); +int hd_rum_decompress_get_num_active_ports(void *decompress_state); #ifdef __cplusplus } diff --git a/src/hd-rum-translator/hd-rum-translator.cpp b/src/hd-rum-translator/hd-rum-translator.cpp index 8de4a246a..25d2003b7 100644 --- a/src/hd-rum-translator/hd-rum-translator.cpp +++ b/src/hd-rum-translator/hd-rum-translator.cpp @@ -326,9 +326,11 @@ static void *writer(void *arg) } } - ssize_t ret = hd_rum_decompress_write(s->decompress, s->qhead->buf, s->qhead->size); - if (ret < 0) { - perror("hd_rum_decompress_write"); + if (hd_rum_decompress_get_num_active_ports(s->decompress) > 0) { + ssize_t ret = hd_rum_decompress_write(s->decompress, s->qhead->buf, s->qhead->size); + if (ret < 0) { + perror("hd_rum_decompress_write"); + } } s->qhead = s->qhead->next;