1. pygame
  2. pygame
  3. pygame

Commits

zeroth  committed cc50f85

Looping works once through, check further looping...
-Tyler

  • Participants
  • Parent commits 1776533
  • Branches tylerthemovie

Comments (0)

Files changed (2)

File src/_gmovie.c

View file
  • Ignore whitespace
 /* packet queue handling */
  void packet_queue_init(PacketQueue *q)
 {
-    q=(PacketQueue *)PyMem_Malloc(sizeof(PacketQueue));
-    q->mutex = SDL_CreateMutex();
+    if(!q)
+    	q=(PacketQueue *)PyMem_Malloc(sizeof(PacketQueue));
+    if(!q->mutex)
+	    q->mutex = SDL_CreateMutex();
+    if(!q->cond)
     q->cond = SDL_CreateCond();
+    q->abort_request=0;
+
 }
 
 
 {
     AVPacketList *pkt, *pkt1;
 
-    SDL_LockMutex(q->mutex);
     for(pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
         pkt1 = pkt->next;
         av_free_packet(&pkt->pkt);
     q->first_pkt = NULL;
     q->nb_packets = 0;
     q->size = 0;
-    SDL_UnlockMutex(q->mutex);
 }
 
  void packet_queue_end(PacketQueue *q)
     pkt1->pkt = *pkt;
     pkt1->next = NULL;
 
-    SDL_LockMutex(q->mutex);
 
     if (!q->last_pkt)
 
     q->nb_packets++;
     q->size += pkt1->pkt.size;
     /* XXX: should duplicate packet data in DV case */
-    SDL_CondSignal(q->cond);
 
-    SDL_UnlockMutex(q->mutex);
     return 0;
 }
 
  void packet_queue_abort(PacketQueue *q)
 {
-    SDL_LockMutex(q->mutex);
-
     q->abort_request = 1;
-
-    SDL_CondSignal(q->cond);
-
-    SDL_UnlockMutex(q->mutex);
 }
 
 /* return < 0 if aborted, 0 if no packet and > 0 if packet.  */
     AVPacketList *pkt1;
     int ret;
 
-    SDL_LockMutex(q->mutex);
 
     for(;;) {
         if (q->abort_request) {
             ret = 0;
             break;
         } else {
-            SDL_CondWait(q->cond, q->mutex);
+            ret=0;
+            break;
         }
     }
-    SDL_UnlockMutex(q->mutex);
     return ret;
 }
 
 	        /* XXX: should skip picture */
 	        actual_delay = 0.010;
 	    }	
-		movie->timing = (actual_delay*1000.0)+0.5;
+		movie->timing = (actual_delay*500.0)+0.5;
     }
     Py_DECREF(movie);
 }
     
     is->paused = 1;
     is->av_sync_type = AV_SYNC_VIDEO_MASTER;
-    if(!THREADFREE)
+    /*if(!THREADFREE)
 	{
 	    is->parse_tid = SDL_CreateThread(decode_thread, is);
 	}
         PyErr_SetString(PyExc_MemoryError, "Could not spawn a new thread.");
         Py_DECREF( is);
         return NULL;
-    }
+    }*/
     
 	Py_DECREF(is);
-    if(THREADFREE)
+    /*if(THREADFREE)
     {
     	is->paused=0;
     	decoder(is);
-    }
+    }*/
     return is;
 }
 
     PyGILState_Release(gstate);
     for(;;) {
     	gstate=PyGILState_Ensure();
-		PySys_WriteStdout("decoder: loop %i.\n", co);
+		//PySys_WriteStdout("decoder: loop %i.\n", co);
 		co++;
 		
         //SDL_LockMutex(is->_mutex);        
         video_render(is);
         if(co<2)
         	video_refresh_timer(is);
-        if(co>=3605.0)
-			PySys_WriteStdout("co=3606\n");
         if(is->timing>0) {
         	double showtime = is->timing+is->last_showtime;
             double now = av_gettime()/1000.0;
 	{
 		//throw python error
 	}
-/*    if(is->loops<0)
-    {
-        is->parse_tid = SDL_CreateThread(decode_thread, is);
-    }
-    else if (is->loops>0)
-    {   
-        is->loops--;
-        is->parse_tid = SDL_CreateThread(decode_thread, is);
-    }*/
+	is->pictq_size=is->pictq_rindex=is->pictq_windex=0;
+	packet_queue_flush(&is->videoq);
+		
     Py_DECREF( is);
     return 0;
 }

File src/gmovie.c

View file
  • Ignore whitespace
         Py_DECREF(self);
         Py_RETURN_NONE;
     }	
-	PySys_WriteStdout("Movie->filename: %s\n", (PyMovie *)self->filename);
+	PySys_WriteStdout("Movie->filename: %s\n", self->filename);
 	Py_DECREF(self);
 	return self;
 }
         //Py_RETURN_NONE;
     	return -1;
     }	
-	self = _movie_init_internal((PyMovie *)self, c, NULL);
+	self = _movie_init_internal(self, c, NULL);
 	PyGILState_STATE gstate;
 	gstate = PyGILState_Ensure();
 	PyObject *er;
     }
     SDL_LockMutex(movie->dest_mutex);
     movie->loops =loops;
-    movie->paused = ~movie->paused;
+    movie->paused = 0;
     movie->playing = 1;
     SDL_UnlockMutex(movie->dest_mutex);
+    while(loops>-1)
+    {
+    	decoder(movie);
+    	PySys_WriteStdout("Loops: %i\n", loops);
+    	loops--;
+    	movie=stream_open(movie, movie->filename, NULL);
+    	movie->paused=0;
+    }
     Py_DECREF(movie);
     Py_RETURN_NONE;
 }