# HG changeset patch # User chainsaw # Date 1132258864 28800 # Node ID 094ef8a0a9fd7acfba06cb5f3d41db2172bdb5b5 # Parent 0a2ad94e860775f724c238f9b442f441e9352491 [svn] GThreadify plugin. Adds a return statement and removes a pragma statement to please GCC. diff -r 0a2ad94e8607 -r 094ef8a0a9fd Plugins/Input/aac/include/faad.h --- a/Plugins/Input/aac/include/faad.h Wed Nov 16 16:21:11 2005 -0800 +++ b/Plugins/Input/aac/include/faad.h Thu Nov 17 12:21:04 2005 -0800 @@ -25,8 +25,5 @@ ** $Id: faad.h,v 1.47 2004/04/03 19:08:37 menno Exp $ **/ -/* warn people for update */ -#pragma message("please update faad2 include filename and function names!") - /* Backwards compatible link */ #include "neaacdec.h" diff -r 0a2ad94e8607 -r 094ef8a0a9fd Plugins/Input/aac/src/libmp4.c --- a/Plugins/Input/aac/src/libmp4.c Wed Nov 16 16:21:11 2005 -0800 +++ b/Plugins/Input/aac/src/libmp4.c Thu Nov 17 12:21:04 2005 -0800 @@ -11,7 +11,6 @@ * libid3 (3.8.x - www.id3.org) */ -#include #include #include "faad.h" #include "mp4.h" @@ -76,8 +75,8 @@ static Mp4Config mp4cfg; static gboolean bPlaying = FALSE; -static pthread_t decodeThread; -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static GThread *decodeThread; +GStaticMutex mutex = G_STATIC_MUTEX_INIT; static int seekPosition = -1; void getMP4info(char*); @@ -91,7 +90,6 @@ static void mp4_init(void) { - memset(&decodeThread, 0, sizeof(pthread_t)); mp4cfg.file_type = FILE_UNKNOW; seekPosition = -1; return; @@ -100,7 +98,7 @@ static void mp4_play(char *filename) { bPlaying = TRUE; - pthread_create(&decodeThread, 0, mp4Decode, g_strdup(filename)); + decodeThread = g_thread_create((GThreadFunc)mp4Decode, g_strdup(filename), TRUE, NULL); return; } @@ -108,8 +106,7 @@ { if(bPlaying){ bPlaying = FALSE; - pthread_join(decodeThread, NULL); - memset(&decodeThread, 0, sizeof(pthread_t)); + g_thread_join(decodeThread); mp4_ip.output->close_audio(); } } @@ -184,7 +181,7 @@ { MP4FileHandle mp4file; - pthread_mutex_lock(&mutex); + g_static_mutex_lock(&mutex); seekPosition = -1; bPlaying = TRUE; if(!(mp4file = MP4Read(args, 0))){ @@ -204,8 +201,8 @@ g_free(args); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); }else{ faacDecHandle decoder; unsigned char *buffer = NULL; @@ -225,16 +222,16 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } if(faacDecInit2(decoder, buffer, bufferSize, &samplerate, &channels)<0){ g_free(args); faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } g_free(buffer); if(channels == 0){ @@ -243,8 +240,8 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } duration = MP4GetTrackDuration(mp4file, mp4track); msDuration = MP4ConvertFromTrackDuration(mp4file, mp4track, duration, @@ -277,8 +274,8 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } rc = MP4ReadSample(mp4file, mp4track, sampleID++, &buffer, &bufferSize, NULL, NULL, NULL, NULL); @@ -293,8 +290,8 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); }else{ sampleBuffer = faacDecDecode(decoder, &frameInfo, buffer, bufferSize); if(frameInfo.error > 0){ @@ -305,8 +302,8 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } if(buffer){ g_free(buffer); buffer=NULL; bufferSize=0; @@ -329,8 +326,8 @@ faacDecClose(decoder); MP4Close(mp4file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } } else{ // WE ARE READING AN AAC FILE @@ -350,15 +347,15 @@ if((file = fopen(args, "rb")) == 0){ g_print("AAC: can't find file %s\n", (char*)args); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } if((decoder = faacDecOpen()) == NULL){ g_print("AAC: Open Decoder Error\n"); fclose(file); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } config = faacDecGetCurrentConfiguration(decoder); config->useOldADTSFormat = 0; @@ -368,8 +365,8 @@ fclose(file); bPlaying = FALSE; faacDecClose(decoder); - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } if((buffervalid = fread(buffer, 1, BUFFER_SIZE, file))==0){ g_print("AAC: Error reading file\n"); @@ -377,8 +374,8 @@ fclose(file); bPlaying = FALSE; faacDecClose(decoder); - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } XMMS_NEW_TITLEINPUT(input); input->file_name = (char*)g_basename(temp); @@ -420,8 +417,8 @@ */ g_free(xmmstitle); bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); } //if(bSeek){ //mp4_ip.set_info(xmmstitle, lenght*1000, -1, samplerate, channels); @@ -502,8 +499,8 @@ } */ bPlaying = FALSE; - pthread_mutex_unlock(&mutex); - pthread_exit(NULL); - + g_static_mutex_unlock(&mutex); + g_thread_exit(NULL); + return(NULL); } }