Anonymous avatar Anonymous committed ddc33da

Fixed video and sound issues...however video is very fast after
unpausing. This is likely related to last_showtime..

Comments (0)

Files changed (3)

             /* if video is slave, we try to correct big delays by
                duplicating or deleting a frame */
             ref_clock = get_master_clock(movie);
-            //GRABGIL
-			//PySys_WriteStdout("Audio Clock: %f\n", ref_clock);
+            GRABGIL
+			PySys_WriteStdout("Audio Clock: %f\n", ref_clock);
             diff = movie->video_current_pts - ref_clock;
-            //PySys_WriteStdout("diff at call %i: %f\n", movie->diff_co, diff);
-            //RELEASEGIL
+            PySys_WriteStdout("diff at call %i: %f\n", movie->diff_co, diff);
+            RELEASEGIL
             /* skip or repeat frame. We take into account the
                delay to compute the threshold. I still don't know
                if it is the best guess */
             actual_delay = 0.010;
         }
         GRABGIL
-        //PySys_WriteStdout("frame_timer: %f\ndelay: %f\n",movie->frame_timer, delay);
+        PySys_WriteStdout("frame_timer: %f\ndelay: %f\n",movie->frame_timer, delay);
         movie->timing = (actual_delay*1000.0)+0.5;
         RELEASEGIL
     }
 /* get the current audio clock value */
 double get_audio_clock(PyMovie *movie)
 {
-    double pts= getAudioClock();
-    return pts;
+    return getAudioClock();
 }
 
 /* get the current video clock value */
         }
 		if(filled)
         {
-            //GRABGIL
-            //PySys_WriteStdout("movie->audio_pts: %i\n", (int)movie->audio_pts);
-            //RELEASEGIL
+            GRABGIL
+            PySys_WriteStdout("movie->audio_pts: %i\n", (int)movie->audio_pts);
+            RELEASEGIL
             /* Buffer is filled up with a new frame, we spin lock/wait for a signal, where we then call playBuffer */
             SDL_LockMutex(movie->audio_mutex);
             //SDL_CondWait(movie->audio_sig, movie->audio_mutex);
             if(now >= showtime)
             {
                 double temp = movie->timing;
+                double temp_showtime = movie->last_showtime;
                 movie->timing =0;
                 if(!video_display(movie))
                 {
                     movie->timing=temp;
+                    movie->last_showtime=temp_showtime;
                 }
-                movie->last_showtime = av_gettime()/1000.0;
-
+                else
+                {
+                	movie->last_showtime = av_gettime()/1000.0;
+                }
             }
         }
-        /*
-        if(movie->video_clock >=4.5)
-    {
-        	GRABGIL
-        	PySys_WriteStdout("PTS: %f\n", movie->video_clock);
-        	RELEASEGIL
-    }*/
     }
 
     ret = 0;
     return 1;
 }
 
-int getAudioClock(void)
+double getAudioClock(void)
 {
     SDL_mutexP(ainfo.mutex);//lock
     int bytes_per_sec = ainfo.channels*ainfo.sample_rate*2;
-    int pts = ainfo.audio_clock;
-    /*if(ainfo.current_frame_size!=1)
-{
-    	pts -= (double) ainfo.current_frame_size/bytes_per_sec;
-}*/
+    double pts = ainfo.audio_clock;
+    //if(ainfo.current_frame_size!=1)
+	//{
+    	pts -= (double) ainfo.current_frame_size/(double) bytes_per_sec;
+	//}
     SDL_mutexV(ainfo.mutex);
     return pts;
 }
 int stopBuffer    (int channel);
 int pauseBuffer   (int channel);
 int getPaused     (int channel);
-int getAudioClock (void);
+double getAudioClock (void);
 int seekBuffer    (uint8_t *buf, uint32_t len, int channel );
 int setCallback   (void (*callback) (int channel));
 int resetAudioInfo(void);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.