video_display: handle err if audio req but notavail

If video_display doesn't provide callbacks for audio, but user still
requests something like:

    uv -t testcard -s testcard -d gl -r embedded

UltraGrid crashed on NULL pointer dereferencing. That mistake can quite
easily happen, so display rather user-friendly message than just
crashing.
This commit is contained in:
Martin Pulec
2023-04-24 12:37:16 +02:00
parent 33a96f0a70
commit d231cd06e6

View File

@@ -574,6 +574,11 @@ void display_put_audio_frame(struct display *d, const struct audio_frame *frame)
int display_reconfigure_audio(struct display *d, int quant_samples, int channels, int sample_rate)
{
assert(d->magic == DISPLAY_MAGIC);
if (!d->funcs->reconfigure_audio) {
log_msg(LOG_LEVEL_FATAL, MOD_NAME "Selected display '%s' doesn't support audio!\n", d->display_name);
exit_uv(EXIT_FAIL_USAGE);
return FALSE;
}
return d->funcs->reconfigure_audio(d->state, quant_samples, channels, sample_rate);
}