mildly better threading and fixed redo bug

This commit is contained in:
itsmattkc
2018-07-26 16:40:08 +01:00
parent 2cf3ecffc4
commit 5ea746a053
5 changed files with 21 additions and 19 deletions
+3 -1
View File
@@ -253,12 +253,14 @@ void MainWindow::editMenu_About_To_Be_Shown() {
void MainWindow::on_action_Undo_triggered()
{
undo_stack.undo();
editMenu_About_To_Be_Shown();
panel_timeline->redraw_all_clips(true);
}
void MainWindow::on_action_Redo_triggered()
{
undo_stack.redo();
editMenu_About_To_Be_Shown();
panel_timeline->redraw_all_clips(true);
}
@@ -478,7 +480,7 @@ void MainWindow::on_actionGo_to_Next_Cut_triggered()
void MainWindow::on_actionPreferences_triggered()
{
PreferencesDialog pd(this);
pd.setup_kbd_shortcuts(this->menuBar());
pd.setup_kbd_shortcuts(menuBar());
pd.exec();
}
+2 -2
View File
@@ -24,7 +24,7 @@
<x>0</x>
<y>0</y>
<width>653</width>
<height>29</height>
<height>17</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@@ -223,7 +223,7 @@
<string>&amp;Redo</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Z, Ctrl+Y</string>
<string>Ctrl+Shift+Z</string>
</property>
</action>
<action name="actionCu_t">
+6 -5
View File
@@ -77,17 +77,18 @@ void Clip::reset() {
codecCtx = NULL;
texture = NULL;
cache_A.frames = NULL;
cache_B.frames = NULL;
cache_B.frames = NULL;
}
Clip::~Clip() {
if (open) {
close_clip(this);
}
// make sure clip has closed before clip is destroyed
open_lock.lock();
open_lock.unlock();
// make sure clip has closed before clip is destroyed
if (multithreaded) {
cacher->wait();
}
}
if (opening_transition != NULL) delete opening_transition;
if (closing_transition != NULL) delete closing_transition;
+10 -10
View File
@@ -30,7 +30,6 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent) {
setFormat(format);
// start audio sending thread
connect(&audio_sender_thread, SIGNAL(finished()), &audio_sender_thread, SLOT(deleteLater()));
audio_sender_thread.start();
// error handler - retries after 250ms if we couldn't get the entire image
@@ -41,8 +40,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent) {
ViewerWidget::~ViewerWidget() {
audio_sender_thread.close = true;
audio_sender_thread.cond.wakeAll();
audio_sender_thread.lock.lock();
audio_sender_thread.lock.unlock();
audio_sender_thread.wait();
}
void ViewerWidget::deleteFunction() {
@@ -234,27 +232,29 @@ void ViewerWidget::paintGL() {
}
AudioSenderThread::AudioSenderThread() : close(false) {
lock.lock();
}
AudioSenderThread::~AudioSenderThread() {
lock.unlock();
connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
}
void AudioSenderThread::run() {
lock.lock();
while (true) {
cond.wait(&lock);
if (close) {
break;
} else {
int written_bytes = 0;
int adjusted_read_index = audio_ibuffer_read%audio_ibuffer_size;
int max_write = audio_ibuffer_size - adjusted_read_index;
if (send_audio_to_output(adjusted_read_index, max_write) == max_write) {
int actual_write = send_audio_to_output(adjusted_read_index, max_write);
written_bytes += actual_write;
if (actual_write == max_write) {
// got all the bytes, write again
send_audio_to_output(0, audio_ibuffer_size);
written_bytes += send_audio_to_output(0, audio_ibuffer_size);
}
}
}
lock.unlock();
}
int AudioSenderThread::send_audio_to_output(int offset, int max) {
-1
View File
@@ -16,7 +16,6 @@ struct Sequence;
class AudioSenderThread : public QThread {
public:
AudioSenderThread();
~AudioSenderThread();
void run();
QWaitCondition cond;
bool close;