void video_clear(void) { int cnt; TRC("%s\n", __FUNCTION__); if (fd >= 0) close(fd); fd = -1; video_playing = 0; audio_type = 0; if (video_write_thread) { pthread_kill(video_write_thread, SIGURG); } if (audio_write_thread) { pthread_kill(audio_write_thread, SIGURG); } sem_getvalue(&write_threads_idle_sem, &cnt); while ( cnt != 2 ) { sleep(0); sem_getvalue(&write_threads_idle_sem, &cnt); pthread_cond_broadcast(&video_cond); } av_stop(); av_video_blank(); av_reset(); av_reset_stc(); pthread_cond_broadcast(&video_cond); mvpw_set_bg(root, MVPW_BLACK); av_wss_update_aspect(WSS_ASPECT_FULL_4x3); }
static void video_change_aspect(int new_aspect, int new_afd) { printf("Changing to aspect %d, afd %d\n", new_aspect, new_afd); if (new_aspect != 0 && new_aspect != -1) { av_wss_aspect_t wss; if (new_aspect == 3) { printf("Source video aspect ratio: 16:9\n"); fflush(stdout); wss = av_set_video_aspect(AV_VIDEO_ASPECT_16x9, new_afd); } else { printf("Source video aspect ratio: 4:3\n"); fflush(stdout); wss = av_set_video_aspect(AV_VIDEO_ASPECT_4x3, new_afd); } av_wss_update_aspect(wss); } else { printf("Video aspect reported as 0 or -1 - not changing setting\n"); fflush(stdout); } }
int fb_next_image(int offset) { char path[1024]; char *label; long int c, i, n, o; if( offset == 0 ) { if( loaded_offset ) { offset = loaded_offset; } else { loaded_status = mvpw_load_image_jpeg(iw, current); av_wss_update_aspect(WSS_ASPECT_UNKNOWN); offset = 1; loaded_offset = 1; } } if( loaded_offset ) { if( offset != loaded_offset ) { if( offset == INT_MIN || offset == INT_MAX ) { o = offset; } else { o = offset-loaded_offset; } loaded_offset = 0; fb_next_image(o); } printf("Displaying image '%s'\n", current); if( loaded_status == -1 ) { mvpw_set_image(iw, current); } else { mvpw_show_image_jpeg(iw); } } loaded_offset = offset; o = 0; n = 0; c = 0; while( (label = mvpw_get_menu_item(file_browser, (void*)n)) ) { if( current && strcasecmp( current+strlen(cwd)+1, label) == 0 ) c = n; n++; } if( offset == INT_MIN ) { i = 0; while( (label = mvpw_get_menu_item(file_browser, (void*)i++)) ) if( is_image(label) ) break; } else if( offset == INT_MAX ) { i = n; while( (label = mvpw_get_menu_item(file_browser, (void*)i--)) ) if( is_image(label) ) break; } else { if( offset>0 ) o = 1; if( offset<0 ) o = -1; i = (c+o+n)%n; while( (label = mvpw_get_menu_item(file_browser, (void*)i)) && (i!=c) ) { if( is_image(label) ) offset-=o; if( offset == 0 ) break; i = (i+o+n)%n; } } if( label == NULL ) return -1; sprintf(path, "%s/%s", cwd, label); free(current); current = strdup(path); loaded_status = mvpw_load_image_jpeg(iw, current); av_wss_update_aspect(WSS_ASPECT_UNKNOWN); return 0; }
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); } } }