// EXRIStream exr_stream(buffer, size);
// Imf::InputFile file(exr_stream);
-
+ if( access(path, R_OK) ) return 1;
Imf::InputFile file(path);
Imath::Box2i dw = file.header().dataWindow();
init_meters();
}
-void PlaybackEngine::stop_tracking()
+void PlaybackEngine::stop_tracking(double position)
{
+ tracking_position = position;
tracking_active = 0;
stop_cursor();
tracking_done->unlock();
int single_frame = TransportCommand::single_frame(command);
int next_audio = next_command->toggle_audio ? !single_frame : single_frame;
float next_speed = next_command->speed;
- int cmd = -1;
// Dispatch command
switch( command ) {
case STOP:
break;
}
next_command->realtime = 1;
- cmd = command;
+ transport_command(command, CHANGE_NONE, edl, use_inout);
break;
case REWIND:
case GOTO_END:
transport_stop(1);
next_command->realtime = 1;
- cmd = command;
+ transport_command(command, CHANGE_NONE, edl, use_inout);
+ stop_tracking(this->command->playbackstart);
break;
}
- if( cmd >= 0 )
- transport_command(cmd, CHANGE_NONE, edl, use_inout);
}
int PlaybackEngine::put_command(TransportCommand *command, int reset)
virtual int brender_available(long position);
// For normal playback tracking and the cursor are started
virtual void init_tracking();
- virtual void stop_tracking();
+ virtual void stop_tracking(double position);
virtual void init_meters();
// The playback cursor calls this to calculate the current tracking position
virtual double get_tracking_position();
close_output();
if( playback_engine ) {
- double position = command->command == CURRENT_FRAME ? command->playbackstart :
+ double position = command->command == CURRENT_FRAME ||
+ command->command == LAST_FRAME ? command->playbackstart :
playback_engine->is_playing_back && !interrupted ?
( command->get_direction() == PLAY_FORWARD ?
command->end_position : command->start_position ) :
playback_engine->get_tracking_position() ;
- if( command->displacement ) {
- position -= 1./command->get_edl()->session->frame_rate;
- if( position < 0 ) position = 0;
- }
+ position -= command->displacement;
+ if( position < 0 ) position = 0;
playback_engine->is_playing_back = 0;
- playback_engine->tracking_position = position;
- playback_engine->stop_tracking();
+ playback_engine->stop_tracking(position);
}
render_active->unlock();
// Not working in NPTL for some reason
// Thread::cancel();
Thread::join();
-
- mwindow->stop_mixers();
-// Final position is updated continuously during playback
-// Get final position
- double position = get_tracking_position();
-// Update cursor
- update_tracker(position);
-
stop_meters();
+ stop_mixers();
+// tracking_position is updated continuously during playback
+// and when render ends, update cursor with final position
+ update_tracker(get_tracking_position());
}
return 0;
}
mwindow->lwindow->gui->unlock_window();
}
-
+void Tracking::stop_mixers()
+{
+ mwindow->stop_mixers();
+}
void Tracking::update_tracker(double position)
// Update meters
virtual void update_meters(int64_t position);
virtual void stop_meters();
+ virtual void stop_mixers();
// int get_pixel(double position);
// Erase cursor if it's visible. Called by start_playback
end_position = use_inout && edl->local_session->outpoint_valid() ?
edl->local_session->get_outpoint() :
!loop_play ? edl->local_session->get_selectionend(1) : length;
+ if( start_position >= length )
+ length = edl->tracks->total_length();
- if( !use_inout && EQUIV(start_position, end_position) ) {
+ if( command == REWIND ) {
+ start_position = end_position = 0;
+ command = CURRENT_FRAME;
+ }
+ else if( command == GOTO_END ) {
+ start_position = end_position = length;
+ command = LAST_FRAME;
+ }
+ else if( !use_inout && EQUIV(start_position, end_position) ) {
// starting play at or past end_position, play to end_position of media (for mixers)
- if( start_position >= length )
- length = edl->tracks->total_length();
switch( command ) {
case SLOW_FWD:
case FAST_FWD:
start_position > edl->local_session->loop_end ) {
start_position = edl->local_session->loop_start;
}
+ displacement = realtime && do_displacement ? frame_period : 0;
break; }
case SLOW_REWIND:
}
break;
- case REWIND:
- start_position = 0;
+ case SINGLE_FRAME_FWD:
+ displacement = realtime && do_displacement ? frame_period : 0;
case CURRENT_FRAME:
case LAST_FRAME:
- case SINGLE_FRAME_FWD:
end_position = start_position + frame_period;
break;
- case GOTO_END:
- end_position = length;
case SINGLE_FRAME_REWIND:
start_position = end_position - frame_period;
break;
}
-
- if( realtime && do_displacement ) {
- if( (command != CURRENT_FRAME && get_direction() == PLAY_FORWARD ) ||
- (command != LAST_FRAME && get_direction() == PLAY_REVERSE ) ) {
- start_position += frame_period;
- end_position += frame_period;
- displacement = 1;
- }
- }
+ start_position += displacement;
+ end_position += displacement;
}
-
// if( start_position < 0 )
// start_position = 0;
// if( end_position > length )
int infinite;
// Position used when starting playback
double playbackstart;
-// start at this=0/next=1 frame
- int displacement;
+// playback offset for always show next frame pref
+ double displacement;
// Send output to device
int realtime;
// command must execute
idx = -1;
edl = 0;
highlighted = 0;
+ playable = 1;
title[0] = 0;
zgui = 0;
zoom = 0;
void ZWindow::handle_mixer(int command, int wait_tracking,
int use_inout, int toggle_audio, int loop_play, float speed)
{
+ if( !playable ) return;
PlaybackEngine *engine = zgui->playback_engine;
engine->next_command->toggle_audio = toggle_audio;
engine->next_command->loop_play = loop_play;
EDL* edl;
int idx;
- int highlighted;
+ int highlighted, playable;
char title[BCTEXTLEN];
float zoom;
};
canvas = 0;
playback_engine = 0;
highlighted = 0;
+ playable = zwindow->playable;
}
ZWindowGUI::~ZWindowGUI()
{
BC_WindowBase *cvs = canvas->get_canvas();
if( !cvs || cvs->get_video_on() ) return 0;
- if( highlighted != zwindow->highlighted ) {
- highlighted = zwindow->highlighted;
- cvs->set_color(WHITE);
- cvs->set_inverse();
- cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h());
- cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2);
- cvs->set_opaque();
- }
+ set_highlighted(zwindow->highlighted);
+ if( !playable ) set_playable(-1);
return 1;
}
+void ZWindowGUI::set_highlighted(int v)
+{
+ if( highlighted == v ) return;
+ highlighted = v;
+ BC_WindowBase *cvs = canvas->get_canvas();
+ cvs->set_color(WHITE);
+ cvs->set_inverse();
+ cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h());
+ cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2);
+ cvs->set_opaque();
+}
+
+void ZWindowGUI::set_playable(int v)
+{
+ if( playable == v ) return;
+ playable = v>0 ? 1 : 0;
+ zwindow->playable = playable;
+ BC_WindowBase *cvs = canvas->get_canvas();
+ cvs->set_color(WHITE);
+ cvs->set_inverse();
+ int dx = cvs->get_w()/16+1, dy = cvs->get_h()/16+1;
+ int x = xS(5), y = yS(5), lw = (dx + dy)/16+1;
+ cvs->set_line_width(lw);
+ cvs->draw_line(x, y, x+dx, y+dy);
+ cvs->draw_line(x, y+dy, x+dx, y);
+ cvs->set_opaque();
+ cvs->set_line_width(1);
+}
+
ZWindowCanvasTileMixers::ZWindowCanvasTileMixers(ZWindowCanvas *canvas)
: BC_MenuItem(_("Tile Mixers"))
return 1;
}
+ZWindowCanvasPlayable::ZWindowCanvasPlayable(ZWindowCanvas *canvas)
+ : BC_MenuItem(_("Playable"))
+{
+ this->canvas = canvas;
+ set_checked(canvas->gui->zwindow->playable);
+}
+int ZWindowCanvasPlayable::handle_event()
+{
+ int v = !get_checked() ? 1 : 0;
+ set_checked(v);
+ canvas->gui->set_playable(v);
+ canvas->get_canvas()->flash(1);
+ return 1;
+}
+
ZWindowCanvas::ZWindowCanvas(MWindow *mwindow, ZWindowGUI *gui,
int x, int y, int w, int h)
: Canvas(mwindow, gui, x,y, w,h, 0,0,0)
{
Canvas::create_objects(edl);
canvas_menu->add_item(new ZWindowCanvasTileMixers(this));
+ canvas_menu->add_item(new ZWindowCanvasPlayable(this));
}
void ZWindowCanvas::close_source()
if( gui->draw_overlays() )
dirty = 1;
-
if( dirty )
cvs->flash(flush);
}
gui->resize_window(new_w, new_h);
gui->resize_event(new_w, new_h);
}
+
int cursor_motion_event();
int select_window(int n);
int draw_overlays();
+ void set_highlighted(int v);
+ void set_playable(int v);
MWindow *mwindow;
ZWindow *zwindow;
ZWindowCanvas *canvas;
PlaybackEngine *playback_engine;
- int highlighted;
+ int highlighted, playable;
};
class ZWindowCanvasTileMixers : public BC_MenuItem
ZWindowCanvas *canvas;
};
+class ZWindowCanvasPlayable : public BC_MenuItem
+{
+public:
+ ZWindowCanvasPlayable(ZWindowCanvas *canvas);
+ int handle_event();
+ ZWindowCanvas *canvas;
+};
+
+
class ZWindowCanvas : public Canvas
{
public: