void fb_shuffle(int shuffle) { char **item, *tmp; int i, j, k, n; if (shuffle) mvpw_set_menu_title(playlist_widget, "Shuffle Play"); else mvpw_set_menu_title(playlist_widget, "Play All"); item = alloca(sizeof(char*) * MAX_PLAYLIST_ENTRIES); // Recurse from the current directory and find all // audio files n = 0; recurse_find_audio(cwd, item, &n); if (n == 0) { gui_error("No audio files exist in this directory or its subdirectories"); return; } if (shuffle && (n > 1)) { for (i=0; i < MAX_PLAYLIST_ENTRIES; i++) { j = rand() % n; k = rand() % n; tmp = item[k]; item[k] = item[j]; item[j] = tmp; } } printf("created playlist of %d songs\n", n); switch_hw_state(MVPMC_STATE_FILEBROWSER); video_functions = &file_functions; playlist_clear(); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); playlist_create(item, n); // Release the list of items for (i = 0; i < n; i++) free(item[i]); if (shuffle) mvpw_set_text_str(fb_name, "Shuffle Play"); else mvpw_set_text_str(fb_name, "Play All"); mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); playlist_play(NULL); }
void start_thruput_test(void) { switch_hw_state(MVPMC_STATE_NONE); DEMUX_WRITE_VIDEO = demux_write_video_nop; DEMUX_WRITE_AUDIO = demux_write_audio_nop; DEMUX_JIT_WRITE_AUDIO = demux_jit_write_audio_nop; thruput = 1; gettimeofday(&thruput_start, NULL); mvpw_set_text_str(thruput_widget, "Press STOP to end test."); mvpw_show(thruput_widget); mvpw_focus(thruput_widget); }
void fb_thruput(void) { char path[256]; switch_hw_state(MVPMC_STATE_FILEBROWSER); sprintf(path, "%s/%s", cwd, current_hilite); if (current) free(current); current = strdup(path); video_functions = &file_functions; demux_reset(handle); demux_attr_reset(handle); video_play(NULL); }
void end_thruput_test(void) { struct timeval thruput_end, delta; char buf[256]; float rate, sec; if (thruput == 0) return; gettimeofday(&thruput_end, NULL); if ( video_functions->halt_stream != NULL ) { video_functions->halt_stream(); } timersub(&thruput_end, &thruput_start, &delta); sec = ((float)delta.tv_sec + (delta.tv_usec / 1000000.0)); rate = (float)thruput_count / sec; rate = (rate * 8) / (1024 * 1024); snprintf(buf, sizeof(buf), "Bytes: %d\nSeconds: %5.2f\nThroughput: %5.2f mb/s", thruput_count, sec, rate); printf("thruput test:\n%s\n", buf); switch_hw_state(MVPMC_STATE_NONE); DEMUX_WRITE_VIDEO = demux_write_video; DEMUX_WRITE_AUDIO = demux_write_audio; DEMUX_JIT_WRITE_AUDIO = demux_jit_write_audio; thruput = 0; thruput_count = 0; mvpw_set_text_str(thruput_widget, buf); }
static void select_callback(mvp_widget_t *widget, char *item, void *key) { char path[1024], *ptr; struct stat64 sb; sprintf(path, "%s/%s", cwd, item); if (stat64(path, &sb)!=0) { printf("Could not stat %s error %d\n",item,errno); if (strcmp(item,"../")==0 ) { // probably lost network put you back in root strcpy(cwd,"/"); strcpy(path,"/"); stat64(path, &sb); } } if (current_pl && !is_playlist(item)) { free(current_pl); current_pl = NULL; } if (current_pl && (playlist == NULL)) { free(current_pl); current_pl = NULL; } printf("%s(): path '%s'\n", __FUNCTION__, path); if (current && (strcmp(path, current) == 0)) { printf("selected current item\n"); if (is_video(item) || (is_streaming(item) > 100)) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); screensaver_disable(); return; } } if (current_pl && (strcmp(path, current_pl) == 0)) { if (is_playlist(item)) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); return; } } if (S_ISDIR(sb.st_mode)) { if (strcmp(item, "../") == 0) { strcpy(path, cwd); if (path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; if (path[0] == '\0') sprintf(path, "/"); } else { if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; } if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){ mount_djmount(path); } else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { unmount_djmount(); } strncpy(cwd, path, sizeof(cwd)); while ((cwd[0] == '/') && (cwd[1] == '/')) memmove(cwd, cwd+1, strlen(cwd)); mvpw_clear_menu(widget); mvpw_set_menu_title(widget, cwd); busy_start(); add_dirs(widget); add_files(widget); busy_end(); mvpw_expose(widget); } else { switch_hw_state(MVPMC_STATE_FILEBROWSER); if (current) free(current); current = NULL; audio_stop = 1; pthread_kill(audio_thread, SIGURG); while (audio_playing) usleep(1000); current = strdup(path); if (is_streaming(item) > 100) { // Use VLC callbacks for streaming items video_functions = &vlc_functions; // Allow broadcast messages to be sent so // we can tell VLC to start the stream vlc_broadcast_enabled = 1; } else { video_functions = &file_functions; } add_osd_widget(fb_program_widget, OSD_PROGRAM, osd_settings.program, NULL); mvpw_set_text_str(fb_name, item); /* * This code sends the currently playing file name to the display. */ snprintf(display_message, sizeof(display_message), "File:%s\n", item); display_send(display_message); audio_clear(); video_clear(); playlist_clear(); if (is_video(item)) { if (key != NULL) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); } else { mvpw_show(fb_progress); } mvpw_set_timer(fb_progress, fb_osd_update, 500); video_play(NULL); mvpw_show(root); mvpw_expose(root); mvpw_focus(root); } else if (is_audio(item) || is_streaming(item)>=0 ) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); audio_play(NULL); } else if (is_image(item)) { mvpw_hide(widget); printf("Displaying image '%s'\n", path); if (mvpw_load_image_jpeg(iw, path) == 0) { mvpw_show_image_jpeg(iw); av_wss_update_aspect(WSS_ASPECT_UNKNOWN); } else { mvpw_set_image(iw, path); } mvpw_show(iw); mvpw_focus(iw); loaded_offset = 0; loaded_status = 0; fb_next_image(1); } else if (is_playlist(item)) { if (current_pl) free(current_pl); current_pl = strdup(path); mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); playlist_clear(); playlist_play(NULL); } } }