Skip to content
Snippets Groups Projects
Commit d794eac3 authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by Steve Lhomme
Browse files

test: input: decoder: check decoder destruction

Check that the decoder is correctly destroyed, even if it is being
running a decoder_UpdateVideoOutput at the point of destruction.

Refs #27532
parent 3007bc4a
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,11 @@ static void DecoderFlush(decoder_t *dec)
static void CloseDecoder(vlc_object_t *obj)
{
struct input_decoder_scenario *scenario = &input_decoder_scenarios[current_scenario];
decoder_t *dec = (decoder_t*)obj;
if (scenario->decoder_destroy != NULL)
scenario->decoder_destroy(dec);
struct vlc_video_context *vctx = dec->p_sys;
if (vctx)
vlc_video_context_Release(vctx);
......
......@@ -32,6 +32,7 @@ struct input_decoder_scenario {
const char *source;
const char *sout;
void (*decoder_setup)(decoder_t *);
void (*decoder_destroy)(decoder_t *);
int (*decoder_decode)(decoder_t *, picture_t *);
void (*decoder_flush)(decoder_t *);
void (*display_prepare)(vout_display_t *vd, picture_t *pic);
......
......@@ -65,6 +65,12 @@ static void decoder_fixed_size(decoder_t *dec, vlc_fourcc_t chroma,
static void decoder_i420_800_600(decoder_t *dec)
{ decoder_fixed_size(dec, VLC_CODEC_I420, 800, 600); }
static void decoder_i420_800_600_stop(decoder_t *dec)
{
decoder_i420_800_600(dec);
vlc_sem_post(&scenario_data.wait_stop);
}
static int decoder_decode_check_cc(decoder_t *dec, picture_t *pic)
{
vlc_tick_t date = pic->date;
......@@ -204,6 +210,23 @@ static void decoder_flush_signal(decoder_t *dec)
vlc_sem_post(&scenario_data.wait_stop);
}
static void* SendUpdateOutput(void *opaque)
{
decoder_t *dec = opaque;
decoder_UpdateVideoOutput(dec, NULL);
return NULL;
}
static void decoder_destroy_trigger_update(decoder_t *dec)
{
/* Use another thread to ensure we don't double-lock, but
* at most deadlock instead. */
vlc_thread_t thread;
int ret = vlc_clone(&thread, SendUpdateOutput, dec);
assert(ret == VLC_SUCCESS);
vlc_join(thread, NULL);
}
static void display_prepare_signal(vout_display_t *vd, picture_t *pic)
{
(void)vd;
......@@ -311,6 +334,14 @@ struct input_decoder_scenario input_decoder_scenarios[] =
.sout_filter_send = sout_filter_send,
.sout_filter_flush = sout_filter_flush,
.interface_setup = interface_setup_check_flush,
},
{
/* Check that releasing a decoder while it is triggering an update
* of the video output format doesn't lead to a crash. Non-regression
* test from issue #27532. */
.source = source_800_600,
.decoder_setup = decoder_i420_800_600_stop,
.decoder_destroy = decoder_destroy_trigger_update,
}};
size_t input_decoder_scenarios_count = ARRAY_SIZE(input_decoder_scenarios);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment