vedl->set_inpoint(start);
vedl->set_outpoint(end);
vedl->local_session->set_selectionstart(start);
- vedl->local_session->set_selectionend(end);
+ vedl->local_session->set_selectionend(start);
vwindow->gui->lock_window("AssetViewPopup::button_press_event");
vwindow->update_position();
vwindow->gui->unlock_window();
void PlaybackEngine::delete_render_engine()
{
renderengine_lock->lock("PlaybackEngine::delete_render_engine");
- delete render_engine;
- render_engine = 0;
+ delete render_engine; render_engine = 0;
renderengine_lock->unlock();
}
void PlaybackEngine::arm_render_engine()
{
- if(render_engine)
+ if( render_engine )
render_engine->arm_command(command);
}
void PlaybackEngine::start_render_engine()
{
- if(render_engine) render_engine->start_command();
+ if( render_engine )
+ render_engine->start_command();
}
void PlaybackEngine::wait_render_engine()
{
- if(command->realtime && render_engine)
- {
+ if( command->realtime && render_engine ) {
render_engine->join();
}
}
{
// TODO: lock out render engine from keyframe deletions
command->get_edl()->synchronize_params(edl);
- if(render_engine) render_engine->get_edl()->synchronize_params(edl);
+ if( render_engine )
+ render_engine->get_edl()->synchronize_params(edl);
}
-
void PlaybackEngine::interrupt_playback(int wait_tracking)
{
renderengine_lock->lock("PlaybackEngine::interrupt_playback");
- if(render_engine)
+ if( render_engine )
render_engine->interrupt_playback();
renderengine_lock->unlock();
pause_lock->unlock();
// Wait for tracking to finish if it is running
- if(wait_tracking)
- {
+ if( wait_tracking ) {
tracking_done->lock("PlaybackEngine::interrupt_playback");
tracking_done->unlock();
}
}
-
// Return 1 if levels exist
int PlaybackEngine::get_output_levels(double *levels, long position)
{
int result = 0;
- if(render_engine && render_engine->do_audio)
- {
- result = 1;
+ if( render_engine && render_engine->do_audio ) {
render_engine->get_output_levels(levels, position);
+ result = 1;
}
return result;
}
int PlaybackEngine::get_module_levels(ArrayList<double> *module_levels, long position)
{
int result = 0;
- if(render_engine && render_engine->do_audio)
- {
- result = 1;
+ if( render_engine && render_engine->do_audio ) {
render_engine->get_module_levels(module_levels, position);
+ result = 1;
}
return result;
}
// Don't interpolate when every frame is played.
- if(command->get_edl()->session->video_every_frame &&
- render_engine &&
- render_engine->do_video)
- {
+ if( command->get_edl()->session->video_every_frame &&
+ render_engine && render_engine->do_video ) {
result = tracking_position;
}
else
{
transport_stop(wait_tracking);
renderengine_lock->lock("PlaybackEngine::stop_playback");
- if(render_engine)
+ if( render_engine )
render_engine->wait_done();
renderengine_lock->unlock();
}
}
}
-int PlaybackEngine::transport_stop(int wait_tracking)
+int PlaybackEngine::put_command(TransportCommand *command, int reset)
{
- interrupt_playback(0);
- input_lock->lock("PlaybackEngine::transport_stop");
- sent_command->copy_from(stop_command);
+// commands can deadlock updating tracking,meters,clock...
+ int mlocked = mwindow->gui->break_lock();
+ input_lock->lock("PlaybackEngine::put_command");
+ sent_command->copy_from(command);
+ if( reset )
+ command->reset();
output_lock->unlock();
+ if( mlocked )
+ mwindow->gui->lock_window("PlaybackEngine::put_command");
+ return 0;
+}
+
+int PlaybackEngine::transport_stop(int wait_tracking)
+{
+ put_command(stop_command, 0);
if( wait_tracking ) {
tracking_done->lock("PlaybackEngine::transport_stop");
tracking_done->unlock();
next_command->set_playback_range(new_edl, use_inout,
preferences->forward_render_displacement);
}
-
- interrupt_playback(0);
- input_lock->lock("PlaybackEngine::transport_command");
- sent_command->copy_from(next_command);
- next_command->reset();
- output_lock->unlock();
-
+ put_command(next_command, 1);
//static const char *types[] = { "NONE",
// "FRAME_FWD", "NORMAL_FWD", "FAST_FWD", "FRAME_REV", "NORMAL_REV", "FAST_REV",
// "STOP", "PAUSE", "SLOW_FWD", "SLOW_REV", "REWIND", "GOTO_END", "CURRENT_FRAME",
// Copy of main preferences
Preferences *preferences;
+ int put_command(TransportCommand *command, int reset);
int transport_stop(int wait_tracking);
int transport_command(int command, int change_type=CHANGE_NONE,
EDL *new_edl=0, int use_inout=0);
// Use audio device
// No danger of race conditions because the output devices are closed after all
// threads join.
- if(do_audio)
- {
+ if( do_audio )
return audio->current_position();
- }
-
- if(do_video)
- {
+ if( do_video ) {
int64_t result = timer.get_scaled_difference(
get_edl()->session->sample_rate);
return result;
int RenderEngine::start_command()
{
- if(command->realtime && !is_nested)
- {
+ if( command->realtime && !is_nested ) {
interrupt_lock->lock("RenderEngine::start_command");
start_lock->lock("RenderEngine::start_command 1");
Thread::start();
void RenderEngine::arm_render_threads()
{
- if(do_audio)
- {
- arender->arm_command();
- }
-
- if(do_video)
- {
- vrender->arm_command();
- }
+ if( do_audio ) arender->arm_command();
+ if( do_video ) vrender->arm_command();
}
// Synchronization timer. Gets reset once again after the first video frame.
timer.update();
- if(do_audio)
- {
- arender->start_command();
- }
+ if( do_audio ) arender->start_command();
+ if( do_video ) vrender->start_command();
- if(do_video)
- {
- vrender->start_command();
- }
+ start_lock->unlock();
}
void RenderEngine::update_framerate(float framerate)
void RenderEngine::wait_render_threads()
{
- if(do_audio)
- {
- arender->Thread::join();
- }
-
- if(do_video)
- {
- vrender->Thread::join();
- }
+ if( do_audio ) arender->Thread::join();
+ if( do_video ) vrender->Thread::join();
}
void RenderEngine::interrupt_playback()
{
+ if( interrupted ) return;
interrupt_lock->lock("RenderEngine::interrupt_playback");
- interrupted = 1;
- if(do_audio && arender)
- {
- arender->interrupt_playback();
- }
-
- if(do_video && vrender)
- {
- vrender->interrupt_playback();
+ if( !interrupted ) {
+ interrupted = 1;
+ if( do_audio && arender ) arender->interrupt_playback();
+ if( do_video && vrender ) vrender->interrupt_playback();
}
interrupt_lock->unlock();
}
int RenderEngine::close_output()
{
// Nested engines share devices
- if(!is_nested)
- {
- if(audio)
- {
- audio->close_all();
- delete audio;
- audio = 0;
- }
-
-
-
- if(video)
- {
- video->close_all();
- delete video;
- video = 0;
- }
+ if( is_nested ) return 0;
+ if( audio ) {
+ audio->close_all();
+ delete audio; audio = 0;
+ }
+ if( video ) {
+ video->close_all();
+ delete video; video = 0;
}
-
return 0;
}
void RenderEngine::run()
{
render_active->lock("RenderEngine::run");
- start_render_threads();
- start_lock->unlock();
- interrupt_lock->unlock();
+ interrupt_lock->unlock();
+ start_render_threads();
wait_render_threads();
-
- interrupt_lock->lock("RenderEngine::run");
-
-
- if(interrupted)
- {
- playback_engine->tracking_position = playback_engine->get_tracking_position();
- }
+ interrupt_lock->lock("RenderEngine::wait_render_threads");
close_output();
-// Fix the tracking position
- if(playback_engine)
- {
- if(command->command == CURRENT_FRAME || command->command == LAST_FRAME)
- {
-//printf("RenderEngine::run 4.1 %d\n", playback_engine->tracking_position);
- playback_engine->tracking_position = command->playbackstart;
- }
- else
- {
-// Make sure transport doesn't issue a pause command next
-//printf("RenderEngine::run 4.1 %d\n", playback_engine->tracking_position);
- if(!interrupted)
- {
- playback_engine->tracking_position =
- command->get_direction() == PLAY_FORWARD ?
- command->end_position : command->start_position;
- }
-
- if( playback_engine->is_playing_back && command->displacement ) {
- double position = playback_engine->tracking_position -
- 1./command->get_edl()->session->frame_rate;
- playback_engine->tracking_position = position >= 0 ? position : 0;
- }
-
- if( !interrupted )
- playback_engine->command->command = STOP;
- playback_engine->stop_tracking();
-
+ if( playback_engine && playback_engine->is_playing_back ) {
+ double position = interrupted ?
+ playback_engine->get_tracking_position() :
+ command->get_direction() == PLAY_FORWARD ?
+ command->end_position :
+ command->start_position;
+ playback_engine->command->command = STOP;
+ if( playback_engine->is_playing_back && command->displacement ) {
+ position -= 1./command->get_edl()->session->frame_rate;
+ if( position < 0 ) position = 0;
}
playback_engine->is_playing_back = 0;
+ playback_engine->tracking_position = position;
+ playback_engine->stop_tracking();
}
- input_lock->unlock();
- interrupt_lock->unlock();
render_active->unlock();
+ interrupt_lock->unlock();
+ input_lock->unlock();
}
void RenderEngine::wait_done()
while( !done ) {
int len = 0;
static const int IN_ENDPOINT = 0x81;
- unsigned char dat[64];
+ unsigned char dat[5];
int ret = libusb_interrupt_transfer(devsh,
IN_ENDPOINT, dat, sizeof(dat), &len, 100);
if( ret != 0 ) {
while( devsh && !done ) {
int len = 0;
static const int IN_ENDPOINT = 0x81;
- unsigned char dat[BCSTRLEN];
+ unsigned char dat[5];
int ret = libusb_interrupt_transfer(devsh,
IN_ENDPOINT, dat, sizeof(dat), &len, 100);
if( ret != 0 ) {
// Snap to nearby values
old_value = current->get_value();
if(shift_down()) {
- double value1, value2, distance1, distance2;
+ double value1, value2, distance1=-1, distance2=-1;
if(current->previous) {
int autogrouptype = current->previous->autos->autogrouptype;
void BC_ScrollBar::calculate_dimensions(int &w, int &h)
{
- switch(orientation)
- {
+ w = h = pixels;
+ switch( orientation ) {
case SCROLL_HORIZ:
- w = pixels;
h = data[SCROLL_HANDLE_UP]->get_h();
break;
case SCROLL_VERT:
w = data[SCROLL_HANDLE_UP]->get_w();
- h = pixels;
break;
}
}
return 0;
}
+int BC_WindowBase::break_lock()
+{
+ if( !top_level ) return 0;
+ if( top_level != this ) return top_level->break_lock();
+ if( top_level->display_lock_owner != pthread_self() ) return 0;
+ if( top_level->window_lock != 1 ) return 0;
+ UNSET_LOCK(this);
+ window_lock = 0;
+ display_lock_owner = 0;
+#ifdef SINGLE_THREAD
+ BC_Display::unlock_display();
+#else
+ XUnlockDisplay(display);
+#endif
+ return 1;
+}
+
void BC_WindowBase::set_done(int return_value)
{
if(done_set) return;
int lock_window(const char *location = 0);
int unlock_window();
int get_window_lock();
+ int break_lock();
BC_MenuBar* add_menubar(BC_MenuBar *menu_bar);
BC_WindowBase* add_subwindow(BC_WindowBase *subwindow);
/* max 39 for short[13][3] mode, mixed: 38, long: 22 */
int scalefacs[2][39];
l3_sideinfo_t sideinfo;
- int ms_stereo, i_stereo;
+ int ms_stereo=0, i_stereo=0;
int sfreq = sampling_frequency_code;
int stereo1, granules;
int output_offset = 0;
ptr = bsbuf + ssize - prev_len;
memcpy(ptr, prev, prev_len);
past_framesize += prev_framesize;
- }
-//}
+// }
+ }
if( ptr && past_framesize >= prev_len ) {
stream->use_ptr(ptr);
for( gr=0; gr<granules; ++gr ) {
# uncomment to enable diagnostics
#DEBUG
-# uncomment to use direct usb
+# recommend uncommenting USB_DIRECT and avoid problems
#USB_DIRECT
# redefine default, use
K8 XK_KP_3 # Play, or if playing Stop
K9 XK_End # End
- K10 "[" # Toggle in if no K14
- K11 "]" # Toggle in if no K15
+ K10 Shift-Ctrl-XK_KP_3 # Loop play between In and Out pointers
+ K11 "l" # Add label at position
K12 Ctrl-XK_Left # Go to previous label
K13 Ctrl-XK_Right # Go to next label
K14 "[" # Toggle in