Skip to content

Commit 32ffb2a

Browse files
committed
hd-rum-decompress: handle nullptr ASAP
1. capture filter may return nullptr - handle it immediately 2. we may receive nullptr as input video_frame - return immediately (as hd-rum decompress doesn't handle audio, either)
1 parent cc3c992 commit 32ffb2a

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/hd-rum-translator/hd-rum-decompress.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,22 @@ void state_transcoder_decompress::frame_arrived(void *state, struct video_frame
103103
{
104104
PROFILE_FUNC;
105105
auto *s = (struct state_transcoder_decompress *) state;
106+
if (f == nullptr) { // skip poison pill from vdisp/pipe
107+
return;
108+
}
106109
if (a) {
107110
LOG(LOG_LEVEL_WARNING) << "Unexpectedly receiving audio!\n";
108111
AUDIO_FRAME_DISPOSE(a);
109112
}
110113
auto deleter = vf_free;
111114
// apply capture filter
112-
if (f) {
113-
f = capture_filter(s->capture_filter_state, f);
115+
f = capture_filter(s->capture_filter_state, f);
116+
if (f == nullptr) {
117+
return;
114118
}
115-
if (f && f->callbacks.dispose) {
119+
if (f->callbacks.dispose != nullptr) {
116120
deleter = f->callbacks.dispose;
117121
}
118-
if (!f) {
119-
return;
120-
}
121122

122123
unique_lock<mutex> l(s->lock);
123124
if (s->received_frame.size() >= MAX_QUEUE_SIZE) {

src/video_display/pipe.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,23 @@
4141
struct audio_frame;
4242
struct video_frame;
4343

44-
typedef void pipe_frame_arrived_t(void *state, struct video_frame *,
45-
struct audio_frame *);
44+
/**
45+
* callback called when A/V frame was received
46+
*
47+
* @note
48+
* Current implementation passes always `v != nullptr`, `a` can be nullptr or
49+
* not depending if audio is received (audio frame attached always to
50+
* video_frame). `v == nullptr` means a poison pill (last frame signalizing an
51+
* end).
52+
*/
53+
typedef void pipe_frame_arrived_t(void *state, struct video_frame *v,
54+
struct audio_frame *a);
4655

56+
/**
57+
* passed as a pointer to vcap/pipe
58+
*/
4759
struct pipe_frame_recv_delegate {
48-
void *state;
60+
void *state; //< pointer passed as first argument to frame_arrived
4961
/**
5062
* Implementing method must release both audio and video frame received
5163
* as parameters with AUDIO_FRAME_DISPOSE() and VIDEO_FRAME_DISPOSE().

0 commit comments

Comments
 (0)