diff --git a/io/config.cpp b/io/config.cpp index 5771f1916..97e1bf88c 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -45,10 +45,9 @@ Config::Config() upcoming_queue_size(0.5), upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), loop(true), - pause_at_out_point(true), seek_also_selects(false), - effect_textbox_lines(3), - use_software_fallback(false) + effect_textbox_lines(3), + use_software_fallback(false) {} void Config::load(QString path) { @@ -158,9 +157,6 @@ void Config::load(QString path) { } else if (stream.name() == "Loop") { stream.readNext(); loop = (stream.text() == "1"); - } else if (stream.name() == "PauseAtOutPoint") { - stream.readNext(); - pause_at_out_point = (stream.text() == "1"); } else if (stream.name() == "SeekAlsoSelects") { stream.readNext(); seek_also_selects = (stream.text() == "1"); @@ -170,10 +166,10 @@ void Config::load(QString path) { } else if (stream.name() == "EffectTextboxLines") { stream.readNext(); effect_textbox_lines = stream.text().toInt(); - } else if (stream.name() == "UseSoftwareFallback") { - stream.readNext(); - use_software_fallback = (stream.text() == "1"); - } + } else if (stream.name() == "UseSoftwareFallback") { + stream.readNext(); + use_software_fallback = (stream.text() == "1"); + } } } if (stream.hasError()) { @@ -230,11 +226,10 @@ void Config::save(QString path) { stream.writeTextElement("UpcomingFrameQueueSize", QString::number(upcoming_queue_size)); stream.writeTextElement("UpcomingFrameQueueType", QString::number(upcoming_queue_type)); stream.writeTextElement("Loop", QString::number(loop)); - stream.writeTextElement("PauseAtOutPoint", QString::number(pause_at_out_point)); stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); stream.writeTextElement("CSSPath", css_path); - stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); - stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); + stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); + stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 6ab3078bc..67b728b21 100644 --- a/io/config.h +++ b/io/config.h @@ -59,7 +59,6 @@ struct Config { double upcoming_queue_size; int upcoming_queue_type; bool loop; - bool pause_at_out_point; bool seek_also_selects; QString css_path; int effect_textbox_lines; diff --git a/mainwindow.cpp b/mainwindow.cpp index 7bb6fc90e..05c5ff829 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -735,6 +735,7 @@ void MainWindow::setup_menus() { playback_menu->addAction(tr("Go to Start"), this, SLOT(go_to_start()), QKeySequence("Home"))->setProperty("id", "gotostart"); playback_menu->addAction(tr("Previous Frame"), this, SLOT(prev_frame()), QKeySequence("Left"))->setProperty("id", "prevframe"); playback_menu->addAction(tr("Play/Pause"), this, SLOT(playpause()), QKeySequence("Space"))->setProperty("id", "playpause"); + playback_menu->addAction(tr("Play In to Out"), this, SLOT(play_in_to_out()), QKeySequence("Shift+Space"))->setProperty("id", "playintoout"); playback_menu->addAction(tr("Next Frame"), this, SLOT(next_frame()), QKeySequence("Right"))->setProperty("id", "nextframe"); playback_menu->addAction(tr("Go to End"), this, SLOT(go_to_end()), QKeySequence("End"))->setProperty("id", "gotoend"); playback_menu->addSeparator(); @@ -747,6 +748,7 @@ void MainWindow::setup_menus() { playback_menu->addAction(tr("Decrease Speed"), this, SLOT(decrease_speed()), QKeySequence("J"))->setProperty("id", "decspeed"); playback_menu->addAction(tr("Pause"), this, SLOT(pause()), QKeySequence("K"))->setProperty("id", "pause"); playback_menu->addAction(tr("Increase Speed"), this, SLOT(increase_speed()), QKeySequence("L"))->setProperty("id", "incspeed"); + playback_menu->addSeparator(); loop_action = playback_menu->addAction(tr("Loop"), this, SLOT(toggle_bool_action())); loop_action->setProperty("id", "loop"); @@ -911,11 +913,6 @@ void MainWindow::setup_menus() { set_name_and_marker->setCheckable(true); set_name_and_marker->setData(reinterpret_cast(&config.set_name_with_marker)); - pause_at_out_point_action = tools_menu->addAction(tr("Pause At Out Point"), this, SLOT(toggle_bool_action())); - pause_at_out_point_action->setProperty("id", "pauseoutpoint"); - pause_at_out_point_action->setCheckable(true); - pause_at_out_point_action->setData(reinterpret_cast(&config.pause_at_out_point)); - tools_menu->addSeparator(); no_autoscroll = tools_menu->addAction(tr("No Auto-Scroll"), this, SLOT(set_autoscroll())); @@ -1109,6 +1106,15 @@ void MainWindow::prev_frame() { } } +void MainWindow::play_in_to_out() { + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->play(true); + } else { + panel_sequence_viewer->play(true); + } +} + void MainWindow::next_frame() { QDockWidget* focused_panel = get_focused_panel(); if (focused_panel == panel_footage_viewer) { diff --git a/mainwindow.h b/mainwindow.h index 85b49635b..4cd448896 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -66,6 +66,7 @@ private slots: void go_to_out(); void go_to_start(); void prev_frame(); + void play_in_to_out(); void playpause(); void pause(); void increase_speed(); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 39360cc6b..ea4daa56d 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -248,7 +248,11 @@ bool frame_rate_is_droppable(float rate) { void Viewer::seek(long p) { pause(); - seq->playhead = p; + if (main_sequence) { + seq->playhead = p; + } else { + seq->playhead = qMin(seq->getEndFrame(), qMax(0L, p)); + } bool update_fx = false; if (main_sequence) { panel_timeline->scroll_to_frame(p); @@ -346,15 +350,24 @@ void Viewer::decrease_speed() { set_playback_speed(new_speed); } -void Viewer::play() { +void Viewer::play(bool in_to_out) { if (panel_sequence_viewer->playing) panel_sequence_viewer->pause(); if (panel_footage_viewer->playing) panel_footage_viewer->pause(); + playing_in_to_out = in_to_out; + if (seq != nullptr) { + + if (playing_in_to_out) { + uncue_recording(); + } + + bool seek_to_in = (seq->using_workarea && config.loop); if (!is_recording_cued() - && seq->playhead >= get_seq_out() - && (config.loop || !main_sequence)) { - seek(get_seq_in()); + && (playing_in_to_out + || seq->playhead >= seq->getEndFrame() + || (seek_to_in && seq->playhead >= seq->workarea_out))) { + seek(seek_to_in ? seq->workarea_in : 0); } if (playback_speed == 0) { @@ -371,6 +384,9 @@ void Viewer::play() { just_played = true; set_playpause_icon(false); start_msecs = QDateTime::currentMSecsSinceEpoch(); + + qDebug() << "play called"; + timer_update(); } } @@ -559,13 +575,13 @@ void Viewer::set_playback_speed(int s) { } long Viewer::get_seq_in() { - return (seq->using_workarea && seq->enable_workarea) + return ((config.loop || playing_in_to_out) && seq->using_workarea && seq->enable_workarea) ? seq->workarea_in : 0; } long Viewer::get_seq_out() { - return (seq->using_workarea && seq->enable_workarea && previous_playhead < seq->workarea_out) + return ((config.loop || playing_in_to_out) && seq->using_workarea && seq->enable_workarea && previous_playhead < seq->workarea_out) ? seq->workarea_out : seq->getEndFrame(); } @@ -756,19 +772,24 @@ void Viewer::timer_update() { if (config.seek_also_selects) panel_timeline->select_from_playhead(); update_parents(config.seek_also_selects); - long end_frame = get_seq_out(); - if (!recording - && playing - && seq->playhead >= end_frame - && previous_playhead < end_frame) { - if (!config.pause_at_out_point && config.loop) { - seek(get_seq_in()); - play(); - } else if (config.pause_at_out_point || !main_sequence) { - pause(); + if (playing) { + if (recording) { + if (recording_start != recording_end && seq->playhead >= recording_end) { + pause(); + } + } else { + if (seq->playhead >= seq->getEndFrame()) { + pause(); + } + if (seq->using_workarea && seq->playhead >= seq->workarea_out) { + if (config.loop) { + // loop + play(); + } else if (playing_in_to_out) { + pause(); + } + } } - } else if (recording && recording_start != recording_end && seq->playhead >= recording_end) { - pause(); } } diff --git a/panels/viewer.h b/panels/viewer.h index 690695247..7181d426d 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -49,7 +49,7 @@ public: // playback functions void seek(long p); - void play(); + void play(bool in_to_out = false); void pause(); bool playing; long playhead_start; @@ -104,6 +104,7 @@ private: long cached_end_frame; QString panel_name; double minimum_zoom; + bool playing_in_to_out; void set_zoom_value(double d); void set_sb_max(); void set_playback_speed(int s); diff --git a/playback/cacher.cpp b/playback/cacher.cpp index e44a451f2..f1b1d7b0b 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -436,6 +436,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests, int play } } + qDebug() << "hello?"; QMetaObject::invokeMethod(panel_footage_viewer, "play_wake", Qt::QueuedConnection); QMetaObject::invokeMethod(panel_sequence_viewer, "play_wake", Qt::QueuedConnection); } @@ -961,11 +962,13 @@ void Cacher::run() { clip->open = true; caching = true; interrupt = false; + queued = false; open_clip_worker(clip); while (caching) { - clip->can_cache.wait(&clip->lock); + if (!queued) clip->can_cache.wait(&clip->lock); + queued = false; if (!caching) { break; } else { diff --git a/playback/cacher.h b/playback/cacher.h index 4c3a985f2..e06939c72 100644 --- a/playback/cacher.h +++ b/playback/cacher.h @@ -20,6 +20,7 @@ public: bool reset; bool scrubbing; bool interrupt; + bool queued; int playback_speed; QVector nests; diff --git a/playback/playback.cpp b/playback/playback.cpp index 62fcc9454..9eb56fcfc 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -113,6 +113,7 @@ void cache_clip(Clip* clip, long playhead, bool reset, bool scrubbing, QVectorcacher->nests = nests; clip->cacher->scrubbing = scrubbing; clip->cacher->playback_speed = playback_speed; + clip->cacher->queued = true; if (reset && clip->queue.size() > 0) clip->cacher->interrupt = true; clip->can_cache.wakeAll(); diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp index bbab2bd2b..4b6e7da84 100644 --- a/ui/renderfunctions.cpp +++ b/ui/renderfunctions.cpp @@ -438,6 +438,8 @@ GLuint compose_sequence(Viewer* viewer, motion_blur_prog++;*/ } } else { + qDebug() << "ra loc"; + if (render_audio || (config.enable_audio_scrubbing && audio_scrub && seq->playhead > c->timeline_in)) { if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { nests.append(c); @@ -486,6 +488,7 @@ GLuint compose_sequence(Viewer* viewer, } void compose_audio(Viewer* viewer, Sequence* seq, bool render_audio, int playback_speed) { + qDebug() << "ca called"; QVector nests; bool texture_failed; compose_sequence(viewer, nullptr, seq, nests, false, render_audio, nullptr, texture_failed, audio_rendering, playback_speed); diff --git a/ui/renderthread.cpp b/ui/renderthread.cpp index 0ec8d4c46..a4ee4da23 100644 --- a/ui/renderthread.cpp +++ b/ui/renderthread.cpp @@ -160,6 +160,7 @@ void RenderThread::start_render(QOpenGLContext *share, Sequence *s, const QStrin pixel_buffer = pixels; queued = true; + waitCond.wakeAll(); } diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 196968d58..2b03d3f18 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -218,6 +218,7 @@ void ViewerWidget::initializeGL() { } void ViewerWidget::frame_update() { + qDebug() << "frame update called"; if (viewer->seq != nullptr) { bool render_audio = (viewer->playing || audio_rendering);