#include "clip_list.h"
#include "disk_space_estimator.h"
#include "flags.h"
+#include "frame_on_disk.h"
#include "player.h"
#include "post_to_main_thread.h"
#include "timebase.h"
static PlayList *playlist_clips;
extern int64_t current_pts;
-extern mutex frame_mu;
-extern vector<int64_t> frames[MAX_STREAMS];
MainWindow::MainWindow()
: ui(new Ui::MainWindow),
void MainWindow::preview_clicked()
{
+ if (ui->playlist->hasFocus()) {
+ // Allow the playlist as preview iff it has focus and something is selected.
+ QItemSelectionModel *selected = ui->playlist->selectionModel();
+ if (selected->hasSelection()) {
+ QModelIndex index = selected->currentIndex();
+ const Clip &clip = *playlist_clips->clip(index.row());
+ preview_player->play_clip(clip, index.row(), clip.stream_idx);
+ return;
+ }
+ }
+
if (cliplist_clips->empty())
return;
lock_guard<mutex> lock(frame_mu);
if (frames[stream_idx].empty())
return;
- auto it = lower_bound(frames[stream_idx].begin(), frames[stream_idx].end(), pts);
+ auto it = lower_bound(frames[stream_idx].begin(), frames[stream_idx].end(), pts,
+ [](const FrameOnDisk &frame, int64_t pts) { return frame.pts < pts; });
if (it != frames[stream_idx].end()) {
- pts = *it;
+ pts = it->pts;
}
} else {
assert(rounding == FIRST_AT_OR_AFTER);
lock_guard<mutex> lock(frame_mu);
if (frames[stream_idx].empty())
return;
- auto it = upper_bound(frames[stream_idx].begin(), frames[stream_idx].end(), pts - 1);
+ auto it = upper_bound(frames[stream_idx].begin(), frames[stream_idx].end(), pts - 1,
+ [](int64_t pts, const FrameOnDisk &frame) { return pts < frame.pts; });
if (it != frames[stream_idx].end()) {
- pts = *it;
+ pts = it->pts;
}
}