Browse Source

paranoid locking

David Rose 14 years ago
parent
commit
5b7c19ee73
1 changed files with 4 additions and 2 deletions
  1. 4 2
      panda/src/movies/ffmpegVideoCursor.cxx

+ 4 - 2
panda/src/movies/ffmpegVideoCursor.cxx

@@ -952,6 +952,10 @@ seek(int frame, bool backward) {
   static PStatCollector seek_pcollector("*:FFMPEG Video Decoding:Seek");
   static PStatCollector seek_pcollector("*:FFMPEG Video Decoding:Seek");
   PStatTimer timer(seek_pcollector);
   PStatTimer timer(seek_pcollector);
 
 
+  // Protect the call to av_seek_frame() in a global lock, just to be
+  // paranoid.
+  ReMutexHolder av_holder(_av_lock);
+
   PN_int64 target_ts = (PN_int64)frame;
   PN_int64 target_ts = (PN_int64)frame;
   if (target_ts < (PN_int64)(_initial_dts)) {
   if (target_ts < (PN_int64)(_initial_dts)) {
     // Attempts to seek before the first packet will fail.
     // Attempts to seek before the first packet will fail.
@@ -992,8 +996,6 @@ seek(int frame, bool backward) {
     // it, and don't do this.
     // it, and don't do this.
 
 
     /*
     /*
-    ReMutexHolder av_holder(_av_lock);
-
     avcodec_close(_video_ctx);
     avcodec_close(_video_ctx);
     AVCodec *pVideoCodec = avcodec_find_decoder(_video_ctx->codec_id);
     AVCodec *pVideoCodec = avcodec_find_decoder(_video_ctx->codec_id);
     if (pVideoCodec == 0) {
     if (pVideoCodec == 0) {