[Mplayerplug-in-cvs] mplayerplug-in/Source plugin-threads.cpp,1.55,1.56
Brought to you by:
kdekorte
From: <kde...@us...> - 2004-03-14 17:10:07
|
Update of /cvsroot/mplayerplug-in/mplayerplug-in/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5488/Source Modified Files: plugin-threads.cpp Log Message: Applied Alex's mms->mmst fallback patch Index: plugin-threads.cpp =================================================================== RCS file: /cvsroot/mplayerplug-in/mplayerplug-in/Source/plugin-threads.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** plugin-threads.cpp 13 Mar 2004 15:38:14 -0000 1.55 --- plugin-threads.cpp 14 Mar 2004 17:01:09 -0000 1.56 *************** *** 456,461 **** int playNode(ThreadData * local_td, Node * local_list, char *local_url, ! int *usefps) { --- 456,463 ---- + //return true if we should try to play this again immediately, false if not + int playNode(ThreadData * local_td, Node * local_list, char *local_url, ! int local_mmsstream, int *usefps) { *************** *** 467,474 **** char vm[10]; char *cf; ! int cfpercent; ! int tryagain = 0; char *eos; while (1) { pthread_testcancel(); --- 469,503 ---- char vm[10]; char *cf; ! double cfpercent; ! int retval = FALSE; char *eos; + long cfbytes; + int i; + int zerocfbytes_count = 0; + char url_copy[1024]; + + + #define TRYAGAIN_FALSE 0 + #define TRYAGAIN_TRUE 1 + #define TRYAGAIN_FALLBACK 2 + + int tryagain = TRYAGAIN_FALLBACK; + + + /* + the meaning of the above is as follows: + TRYAGAIN_TRUE: we should definitely try playing this url again immediately + TRYAGAIN_FALSE: we should definitely NOT do that. + TRYAGAIN_FALLBACK if we should try playing this url again immediately + only if we have a fallback url. + + these are for internal use in this function only. The function + should still return either 0 or 1 (and never 2). + + */ + + + while (1) { pthread_testcancel(); *************** *** 523,527 **** if (strstr(eos, "Cache fill:") != NULL) { cf = strstr(eos, "Cache fill:"); ! sscanf(cf, "Cache fill: %i", &cfpercent); strlcpy(message, "Buffering ", sizeof(message)); strlcat(message, local_url, 1000); --- 552,579 ---- if (strstr(eos, "Cache fill:") != NULL) { cf = strstr(eos, "Cache fill:"); ! i = sscanf(cf, "Cache fill: %lf %% (%ld bytes)", ! &cfpercent, &cfbytes); ! //the following is a workaround for an mplayer bug ! // we can try to fallback to mmst when we get ! // Cache Fill: 0% (0 bytes) several times. ! if (i == 2 && cfbytes == 0) { ! zerocfbytes_count++; ! } ! if (DEBUG && zerocfbytes_count > 0) { ! printf("Cache Fill: 0% (0 bytes), count = %d\n", ! zerocfbytes_count); ! } ! if (zerocfbytes_count >= 1 && ! ((strncmp(local_url, "mms://", 6) == 0) || ! local_mmsstream ! && strncmp(local_url, "http://", 7) == 0)) { ! ! if (DEBUG) { ! printf("Exiting. Will try again with mmst://\n"); ! } ! tryagain = TRYAGAIN_FALLBACK; ! break; ! } ! strlcpy(message, "Buffering ", sizeof(message)); strlcat(message, local_url, 1000); *************** *** 529,533 **** #ifdef X_ENABLED DrawUI(local_td->instance->widget, ! local_td->instance, eos, -1, cfpercent); #endif #ifdef GTK_ENABLED --- 581,585 ---- #ifdef X_ENABLED DrawUI(local_td->instance->widget, ! local_td->instance, eos, -1, (int) cfpercent); #endif #ifdef GTK_ENABLED *************** *** 537,540 **** --- 589,593 ---- local_td->instance->percent = (cfpercent / 100.0); g_idle_add(gtkgui_progress, local_td->instance); + #endif } *************** *** 595,598 **** --- 648,657 ---- } + // this is only needed for the retry code + if (strstr(buffer, "\rA: ") != 0 || strstr(buffer, "\rV: ") != 0) { + //audio or video is playing + tryagain = TRYAGAIN_FALSE; + } + if (strstr(buffer, "Video: no video") != NULL) { *************** *** 647,651 **** if (strstr(buffer, "MOV: missing header (moov/cmov) chunk!") != NULL) { ! tryagain = 1; while (1) { pthread_testcancel(); --- 706,714 ---- if (strstr(buffer, "MOV: missing header (moov/cmov) chunk!") != NULL) { ! if (DEBUG) { ! printf ! ("----player thread: waiting to download entire movie\n"); ! } ! tryagain = TRYAGAIN_TRUE; while (1) { pthread_testcancel(); *************** *** 653,660 **** --- 716,726 ---- pthread_testcancel(); pthread_mutex_lock(&(local_td->instance->playlist_mutex)); + local_td->instance->state = STATE_DOWNLOADING; if (local_list->retrieved == 1) { + local_td->instance->state = STATE_PLAYING; pthread_mutex_unlock(& (local_td->instance-> playlist_mutex)); + printf("----player thread: Movie downloaded\n"); break; } *************** *** 662,669 **** (local_td->instance->playlist_mutex)); } } if (strstr(buffer, "FPS not specified") != NULL) { ! tryagain = 1; *usefps = 1; break; --- 728,736 ---- (local_td->instance->playlist_mutex)); } + break; } if (strstr(buffer, "FPS not specified") != NULL) { ! tryagain = TRYAGAIN_TRUE; *usefps = 1; break; *************** *** 704,708 **** } ! return tryagain; } --- 771,806 ---- } ! ! if (DEBUG) { ! printf("---player thread: tryagain = %d\n", tryagain); ! } ! //we always return either true or false ! if (tryagain == TRYAGAIN_TRUE) { ! retval = TRUE; ! } ! ! if (tryagain == TRYAGAIN_FALSE) { ! retval = FALSE; ! } ! ! if (tryagain == TRYAGAIN_FALLBACK) { ! //fallback to msst if we can ! strncpy(url_copy, local_url, 1023); ! url_copy[1023] = '\0'; ! ! if (strncmp(local_url, "mms://", 6) == 0) { ! snprintf(local_url, 1023, "mmst://%s", url_copy + 6); ! retval = TRUE; ! } else if (local_mmsstream && ! strncmp(local_url, "http://", 7) == 0) { ! ! snprintf(local_url, 1023, "mmst://%s", url_copy + 7); ! retval = TRUE; ! } else { ! retval = FALSE; ! } ! } ! ! return retval; } *************** *** 722,725 **** --- 820,824 ---- Node *local_list; char local_url[1024]; + int local_mmsstream; int i; Node *node; *************** *** 862,865 **** --- 961,965 ---- snprintf(local_url, 1024, "%s", local_list->url); local_url[1023] = '\0'; + local_mmsstream = local_list->mmsstream; pthread_mutex_unlock(&(local_td->instance->playlist_mutex)); *************** *** 870,876 **** usefps = 0; - tryagain = 1; ! while (tryagain) { pthread_testcancel(); --- 970,975 ---- usefps = 0; ! do { pthread_testcancel(); *************** *** 919,923 **** local_td->instance->mmsstream = local_list->mmsstream; if (local_list->mmsstream) { ! argv[argc++] = local_list->url; if (local_td->instance->keep_download) { snprintf(mmsplaylist, sizeof(mmsplaylist), --- 1018,1022 ---- local_td->instance->mmsstream = local_list->mmsstream; if (local_list->mmsstream) { ! argv[argc++] = local_url; if (local_td->instance->keep_download) { snprintf(mmsplaylist, sizeof(mmsplaylist), *************** *** 926,930 **** playlist = fopen(mmsplaylist, "a"); if (playlist != NULL) { ! fprintf(playlist, "%s\n", local_list->url); fclose(playlist); } --- 1025,1029 ---- playlist = fopen(mmsplaylist, "a"); if (playlist != NULL) { ! fprintf(playlist, "%s\n", local_url); fclose(playlist); } *************** *** 932,936 **** } else { if (strlen(local_list->fname) == 0) { ! argv[argc++] = strdup(local_list->url); } else { argv[argc++] = strdup(local_list->fname); --- 1031,1035 ---- } else { if (strlen(local_list->fname) == 0) { ! argv[argc++] = strdup(local_url); } else { argv[argc++] = strdup(local_list->fname); *************** *** 939,943 **** if (DEBUG) { ! printf("----player thread: URL: %s\n", local_list->url); } --- 1038,1042 ---- if (DEBUG) { ! printf("----player thread: URL: %s\n", local_url); } *************** *** 974,981 **** tryagain = ! playNode(local_td, local_list, local_url, &usefps); if (DEBUG) ! printf("tryagain = %d\n", tryagain); pthread_testcancel(); --- 1073,1080 ---- tryagain = ! playNode(local_td, local_list, local_url, local_mmsstream, &usefps); if (DEBUG) ! printf("----player thread: playNode returned = %d\n", tryagain); pthread_testcancel(); *************** *** 1014,1018 **** } ! } //if we get here, either the control pipes are closed --- 1113,1117 ---- } ! } while (tryagain); //if we get here, either the control pipes are closed *************** *** 1051,1060 **** - /* this will happen automatically upon exit? - - pthread_mutex_unlock(&(local_td->instance->playlist_mutex)); - pthread_cleanup_pop(0); - */ - //once we get here, the thread is only allowed to access stack --- 1150,1153 ---- |