Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / packagedispatcher.C
index dccec03a2896c3f8676a0f66b44f589b285bc090..b6aa9675a6fe818ea12ca07fb5779edab2d5f7ad 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -279,9 +280,11 @@ RenderPackage* PackageDispatcher::get_package(double frames_per_second,
                        result->video_start = video_position;
                        result->audio_end = result->audio_start +
                                Units::to_int64(scaled_len * default_asset->sample_rate);
+                       if( result->audio_end > audio_end ) result->audio_end = audio_end;
                        result->video_end = result->video_start +
                                Units::to_int64(scaled_len * default_asset->frame_rate);
-                       if(result->video_end == result->video_start) result->video_end++;
+                       if( result->video_end > video_end ) result->video_end = video_end;
+                       if( result->video_end == result->video_start ) result->video_end++;
                        audio_position = result->audio_end;
                        video_position = result->video_end;
                        result->audio_do = default_asset->audio_data;