1. pygame
  2. Untitled project
  3. pygame

Commits

zeroth  committed be87bb3

Fixed unpausing issue. No more drift!

  • Participants
  • Parent commits ed630dc
  • Branches tylerthemovie

Comments (0)

Files changed (3)

File src/_gmovie.c

View file
             /* 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
     }
         }
 		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);
         {
             movie->last_paused = movie->paused;
             if (movie->paused)
+            {
                 av_read_pause(ic);
+            }
             else
+            {
+            	movie->last_showtime=av_gettime()/1000.0;
                 av_read_play(ic);
+            }
         }
         if(movie->paused)
         {
             else if (pkt->stream_index == movie->video_stream)
             {
                 packet_queue_put(&movie->videoq, pkt);
-                //} else if (pkt->stream_index == movie->subtitle_stream) {
-                //    packet_queue_put(&movie->subtitleq, pkt);
             }
             else if(pkt)
             {

File src/_gsound.c

View file
         len=128;
         allocated =1;
     }
+    
     //regardless of 1st call, or a callback, we load the data from buf into a newly allocated block.
     mix= (Mix_Chunk *)PyMem_Malloc(sizeof(Mix_Chunk));
     mix->allocated=0;
     mix->alen = (Uint32 )len;
     mix->volume = 127;
     ainfo.playing = 1;
-    int bytes_per_sec = ainfo.channels*ainfo.sample_rate*2;
-    ainfo.audio_clock+= (double) len/(double) bytes_per_sec;
+ 	if(!ainfo.paused)
+	{
+    	int bytes_per_sec = ainfo.channels*ainfo.sample_rate*2;
+    	ainfo.audio_clock+= (double) len/(double) bytes_per_sec;
+	}
     ainfo.current_frame_size =len;
     int ret = Mix_PlayChannel(ainfo.channel, mix, 0);
     ainfo.channel = ret;
     int paused = Mix_Paused(channel);
     if(paused)
     {
+    	ainfo.paused=0;
         Mix_Resume(-1);
     }
     else
     {
+    	ainfo.paused=1;
         Mix_Pause(-1);
     }
     return 0;

File src/_gsound.h

View file
     int         playing;            //if we've started playing any buffers
     int         channel;            //what channel the last buffer played on
     int         ended;              //whether or not we've "ended", so we know to output silence.
+	int			paused;
     double      time_base;          //the base 1/frames per second value
     BufferQueue queue;              //queue of our buffers
     SDL_mutex   *mutex;
-    //temporary
-    PyThreadState *_tstate;
+
 }
 AudioInfo;