Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginset.C
index 575f04651ce78c10fc33d24958b618ecb4c65ac4..833ab47364430555f99fd8134c5616ecdba0f69b 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 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
@@ -164,11 +165,20 @@ KeyFrame *PluginSet::nearest_keyframe(int64_t pos, int dir)
                pos = first->startproject;
        else if( last && pos > last->startproject+last->length )
                pos = last->startproject+last->length;
+       KeyFrame *keyframe = 0;
        Plugin *plugin = (Plugin*)editof(pos, dir, 0);
-       if( !plugin ) return 0;
-       KeyFrame *keyframe = (KeyFrame *)(dir == PLAY_FORWARD ?
-               plugin->keyframes->nearest_after(pos) :
-               plugin->keyframes->nearest_before(pos));
+       if( dir == PLAY_FORWARD ) {
+               for( ; !keyframe && plugin; plugin=(Plugin*)plugin->next ) {
+                       if( plugin->plugin_type == PLUGIN_NONE ) continue;
+                       keyframe = (KeyFrame *)plugin->keyframes->nearest_after(pos);
+               }
+       }
+       else {
+               for( ; !keyframe && plugin; plugin=(Plugin*)plugin->previous ) {
+                       if( plugin->plugin_type == PLUGIN_NONE ) continue;
+                       keyframe = (KeyFrame *)plugin->keyframes->nearest_before(pos);
+               }
+       }
        return keyframe;
 }