From 61cfdbaccba2aaef410def9a392bfff877102333 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 12 Nov 2014 01:35:51 -0800 Subject: [PATCH] Qt: Disallow opening the context twice --- src/platform/ffmpeg/ffmpeg-encoder.c | 4 ++++ src/platform/ffmpeg/ffmpeg-encoder.h | 1 + src/platform/qt/VideoView.cpp | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platform/ffmpeg/ffmpeg-encoder.c b/src/platform/ffmpeg/ffmpeg-encoder.c index 4d84653b5..9510c4e0a 100644 --- a/src/platform/ffmpeg/ffmpeg-encoder.c +++ b/src/platform/ffmpeg/ffmpeg-encoder.c @@ -282,6 +282,10 @@ void FFmpegEncoderClose(struct FFmpegEncoder* encoder) { encoder->context = 0; } +bool FFmpegEncoderIsOpen(struct FFmpegEncoder* encoder) { + return !!encoder->context; +} + void _ffmpegPostAudioFrame(struct GBAAVStream* stream, int32_t left, int32_t right) { struct FFmpegEncoder* encoder = (struct FFmpegEncoder*) stream; if (!encoder->context) { diff --git a/src/platform/ffmpeg/ffmpeg-encoder.h b/src/platform/ffmpeg/ffmpeg-encoder.h index 59639086e..668e373fc 100644 --- a/src/platform/ffmpeg/ffmpeg-encoder.h +++ b/src/platform/ffmpeg/ffmpeg-encoder.h @@ -50,5 +50,6 @@ void FFmpegEncoderSetDimensions(struct FFmpegEncoder*, int width, int height); bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder*); bool FFmpegEncoderOpen(struct FFmpegEncoder*, const char* outfile); void FFmpegEncoderClose(struct FFmpegEncoder*); +bool FFmpegEncoderIsOpen(struct FFmpegEncoder*); #endif diff --git a/src/platform/qt/VideoView.cpp b/src/platform/qt/VideoView.cpp index 122c61b3c..e2e89b676 100644 --- a/src/platform/qt/VideoView.cpp +++ b/src/platform/qt/VideoView.cpp @@ -274,7 +274,7 @@ void VideoView::showAdvanced(bool show) { } bool VideoView::validateSettings() { - bool valid = true; + bool valid = !m_filename.isNull() && !FFmpegEncoderIsOpen(&m_encoder); if (!m_audioCodecCstr) { valid = false; m_ui.audio->setStyleSheet("QComboBox { color: red; }"); @@ -302,7 +302,7 @@ bool VideoView::validateSettings() { valid = false; } - m_ui.start->setEnabled(valid && !m_filename.isNull()); + m_ui.start->setEnabled(valid); return valid; }