4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "edlsession.h"
26 #include "localsession.h"
27 #include "mainclock.h"
28 #include "meterpanel.h"
30 #include "renderengine.h"
31 #include "mainclock.h"
32 #include "vplayback.h"
35 #include "vtracking.h"
37 #include "vwindowgui.h"
40 VTracking::VTracking(MWindow *mwindow, VWindow *vwindow)
43 this->vwindow = vwindow;
46 VTracking::~VTracking()
50 PlaybackEngine* VTracking::get_playback_engine()
52 return vwindow->playback_engine;
55 void VTracking::update_tracker(double position)
57 if( !vwindow->get_edl() ) return;
58 vwindow->gui->lock_window("VTracking::update_tracker");
59 vwindow->get_edl()->local_session->set_selectionstart(position);
60 vwindow->get_edl()->local_session->set_selectionend(position);
62 Asset *asset = vwindow->get_edl()->assets->first;
63 if( asset && asset->tcstart ) {
64 double rate = asset->video_data ? asset->frame_rate :
65 asset->audio_data ? asset->sample_rate : 0;
67 position += asset->tcstart / rate;
69 vwindow->gui->clock->update(position);
71 // This is going to boost the latency but we need to update the timebar
72 vwindow->gui->timebar->update(1);
74 vwindow->gui->unlock_window();
76 update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
79 int VTracking::start_playback(double new_position)
82 return Tracking::start_playback(new_position);
85 void VTracking::update_meters(int64_t position)
87 double output_levels[MAXCHANNELS];
89 int do_audio = get_playback_engine()->get_output_levels(output_levels,
93 vwindow->gui->lock_window("VTracking::update_meters");
94 vwindow->gui->meters->update(output_levels);
95 vwindow->gui->unlock_window();
99 void VTracking::stop_meters()
101 vwindow->gui->lock_window("VTracking::stop_meters");
102 vwindow->gui->meters->stop_meters();
103 vwindow->gui->unlock_window();
106 void VTracking::draw()