Commits

Anonymous committed 4d1dca5

Worked on proper looping construct(a wrapper around decoder), to
minimize memory leaks.

Memory leak is still continuing.

  • Participants
  • Parent commits 6f006ef
  • Branches tylerthemovie

Comments (0)

Files changed (3)

File src/_gmovie.c

 	RELEASEGIL
 }
 
+int decoder_wrapper(void *arg)
+{
+	PyMovie *movie = arg;
+	DECLAREGIL
+	GRABGIL	
+	Py_INCREF(movie);
+	RELEASEGIL
+	int state=0;
+	movie->loops--;
+	while((movie->loops!=-1) && state==0)
+	{
+		GRABGIL
+		PySys_WriteStdout("Loops: %i\n", movie->loops);
+		RELEASEGIL
+		movie->loops--;
+		movie=stream_open(movie, movie->filename, NULL);
+		movie->paused=0;
+		state =decoder(movie);	
+	}	
+	return state;
+}
 
 /* this thread gets the stream from the disk or the network */
  int decoder(void *arg)
 	}
 	is->pictq_size=is->pictq_rindex=is->pictq_windex=0;
 	packet_queue_flush(&is->videoq);
-	is->loops--;
-	if(is->loops<=-2 || is->loops>-1)
-	{
-		//is=stream_open(is, is->filename, NULL);
-		is->paused=0;
-		GRABGIL
-		Py_DECREF(is);
-		RELEASEGIL
-		return decoder(is);	
-	}
+	
 	GRABGIL		
     Py_DECREF( is);
     RELEASEGIL
+    if(is->abort_request)
+    {	return -1;}
     return 0;
 }
 

File src/_gmovie.h

 void stream_pause(PyMovie *is);
 int stream_component_open(PyMovie *is, int stream_index); //TODO: break down into separate functions
 void stream_component_close(PyMovie *is, int stream_index);
-int decode_thread(void *arg);
 int decoder(void *arg);
 PyMovie *stream_open(PyMovie *is, const char *filename, AVInputFormat *iformat);
 void stream_close(PyMovie *is);
 void stream_cycle_channel(PyMovie *is, int codec_type);
+int decoder_wrapper(void *arg);
 
 /* 		Clock Management */
 double get_audio_clock(PyMovie *is);

File src/gmovie.c

     movie->paused = 0;
     movie->playing = 1;
     SDL_UnlockMutex(movie->dest_mutex);
- 	int state;
-	movie->parse_tid = SDL_CreateThread(decoder, movie);
+	movie->parse_tid = SDL_CreateThread(decoder_wrapper, movie);
     GRABGIL
     Py_DECREF(movie);
     RELEASEGIL