fixed crash if no audio devices were found
This commit is contained in:
+3
-2
@@ -98,8 +98,9 @@ void Viewer::reset_all_audio() {
|
||||
}
|
||||
|
||||
void Viewer::assert_audio_device() {
|
||||
if (audio_output->format().sampleRate() != seq->audio_frequency
|
||||
|| audio_output->format().channelCount() != av_get_channel_layout_nb_channels(seq->audio_layout)) {
|
||||
if (is_audio_device_set() &&
|
||||
(audio_output->format().sampleRate() != seq->audio_frequency
|
||||
|| audio_output->format().channelCount() != av_get_channel_layout_nb_channels(seq->audio_layout))) {
|
||||
closeActiveClips(seq, true);
|
||||
init_audio(seq);
|
||||
}
|
||||
|
||||
+14
-6
@@ -36,6 +36,10 @@ double audio_ibuffer_timecode = 0;
|
||||
|
||||
AudioSenderThread* audio_thread = NULL;
|
||||
|
||||
bool is_audio_device_set() {
|
||||
return audio_device_set;
|
||||
}
|
||||
|
||||
void init_audio(Sequence* s) {
|
||||
stop_audio();
|
||||
|
||||
@@ -59,14 +63,18 @@ void init_audio(Sequence* s) {
|
||||
|
||||
// connect
|
||||
audio_io_device = audio_output->start();
|
||||
audio_device_set = true;
|
||||
if (audio_io_device == NULL) {
|
||||
dout << "[WARNING] Received NULL audio device. No compatible audio output was found.";
|
||||
} else {
|
||||
audio_device_set = true;
|
||||
|
||||
// start sender thread
|
||||
audio_thread = new AudioSenderThread();
|
||||
QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver()));
|
||||
audio_thread->start(QThread::TimeCriticalPriority);
|
||||
// start sender thread
|
||||
audio_thread = new AudioSenderThread();
|
||||
QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver()));
|
||||
audio_thread->start(QThread::TimeCriticalPriority);
|
||||
|
||||
clear_audio_ibuffer();
|
||||
clear_audio_ibuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ extern double audio_ibuffer_timecode;
|
||||
extern bool audio_scrub;
|
||||
void clear_audio_ibuffer();
|
||||
|
||||
bool is_audio_device_set();
|
||||
|
||||
void init_audio(Sequence *s);
|
||||
void stop_audio();
|
||||
int get_buffer_offset_from_frame(double framerate, long frame);
|
||||
|
||||
+1
-1
@@ -399,7 +399,7 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
Media* m = static_cast<Media*>(c->media);
|
||||
if (!m->invalid) {
|
||||
if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) {
|
||||
if (m->ready) {
|
||||
MediaStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream);
|
||||
if (ms != NULL && is_clip_active(c, playhead)) {
|
||||
|
||||
Reference in New Issue
Block a user