Example #1
0
int music_free(void)
{
	int ret;
	unsigned to = 500000;

	cache_on(false);

	music_lock();

	ret = -1;

	while (ret != 0) {
		ret = music_stop();
		if (ret != 0)
			xrKernelDelayThread(100000);
	}

	g_list.is_list_playing = 0;
	g_thread_actived = 0;
	music_unlock();
	free_shuffle_data();

	if (xrKernelWaitThreadEnd(g_music_thread, &to) != 0) {
		xrKernelTerminateDeleteThread(g_music_thread);
	} else {
		xrKernelDeleteThread(g_music_thread);
	}

	xr_lock_destroy(&music_l);

	return 0;
}
Example #2
0
void cache_free(void)
{
	cache_on(false);

	xr_lock_destroy(&cacher_locker);

	if (cache_del_event >= 0) {
		xrKernelDeleteEventFlag(cache_del_event);
		cache_del_event = -1;
	}
}
Example #3
0
dword scene_readimage(dword selidx)
{
	u64 timer_start, timer_end;
	u64 slide_start, slide_end;

	width_rotated = 0, height_rotated = 0, thumb_width = 0, thumb_height =
		0, paintleft = 0, painttop = 0;
	imgdata = NULL, imgshow = NULL;
	oldangle = 0;
	curtop = 0, curleft = 0, xpos = 0, ypos = 0;
	img_needrf = true, img_needrc = true, img_needrp = true, showinfo =
		false, thumb = false;
	slideshow = false;
	now = 0, lasttime = 0;
	imgreading = true;

	if (config.imginfobar)
		imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE;
	else
		imgh = PSP_SCREEN_HEIGHT;

	if (config.use_image_queue) {
		cache_setup(config.max_cache_img, &selidx);
		cache_set_forward(true);
		cache_on(true);
	}

	xrRtcGetCurrentTick(&timer_start);

	while (1) {
		u64 dbgnow, dbglasttick;
		dword key = 0;
		int ret;

		if (img_needrf) {
			int fid;
			dword ret;

			fid = freq_enter_hotzone();
			xrRtcGetCurrentTick(&dbglasttick);
			ret = scene_reloadimage(selidx);

			if (ret == -1) {
				freq_leave(fid);
				break;
			}

			img_needrf = false;
			xrRtcGetCurrentTick(&dbgnow);
			dbg_printf(d, _("装载图像时间: %.2f秒"),
					   pspDiffTime(&dbgnow, &dbglasttick));
			freq_leave(fid);
		}

		if (img_needrc) {
			int fid;

			fid = freq_enter_hotzone();
			xrRtcGetCurrentTick(&dbglasttick);
			scene_rotateimage();
			img_needrc = false;
			xrRtcGetCurrentTick(&dbgnow);
			dbg_printf(d, _("旋转图像时间: %.2f秒"),
					   pspDiffTime(&dbgnow, &dbglasttick));
			freq_leave(fid);
		}

		if (img_needrp) {
			scene_printimage(selidx);
			img_needrp = false;
		}

		now = time(NULL);

		if (config.thumb == conf_thumb_scroll && thumb) {
			thumb = false;
			img_needrp = true;
		}

		key = ctrl_read_cont();
		ret = image_handle_input(&selidx, key);

		if (ret == -1 && slideshow && !slideshow_move) {
			if (key == PSP_CTRL_CIRCLE) {
			} else if (key != 0
					   && (key == config.imgkey[1] || key == config.imgkey2[1]
						   || key == CTRL_FORWARD)) {
				bool should_exit = false;

				next_image(&selidx, &should_exit);

				if (should_exit) {
					break;
				}
			} else if (key != 0
					   && (key == config.imgkey[0] || key == config.imgkey2[0]
						   || key == CTRL_BACK)) {
				prev_image(&selidx);
			} else {
				xrPowerTick(0);
				if (config.imgpaging == conf_imgpaging_direct ||
					config.imgpaging == conf_imgpaging_updown ||
					config.imgpaging == conf_imgpaging_leftright) {
					if (now - lasttime >= config.slideinterval) {
						lasttime = now;
						ret = scene_slideshow_forward(&selidx);
					}
				} else {
					xrRtcGetCurrentTick(&slide_end);
					if (pspDiffTime(&slide_end, &slide_start) >= 0.1) {
						xrRtcGetCurrentTick(&slide_start);
					} else {
						lasttime = now;
						ret = scene_slideshow_forward(&selidx);
					}
				}
			}
		}

		if (showinfo && (key & PSP_CTRL_CIRCLE) == 0) {
			img_needrp = true;
			showinfo = false;
		}

		xrRtcGetCurrentTick(&timer_end);

		if (pspDiffTime(&timer_end, &timer_start) >= 1.0) {
			xrRtcGetCurrentTick(&timer_start);
			secticks++;
		}

		if (config.autosleep != 0 && secticks > 60 * config.autosleep) {
			power_down();
			xrPowerRequestSuspend();
			secticks = 0;
		}

		if (ret != -1) {
			selidx = ret;
			break;
		}

		scene_image_delay_action();
	}

	reset_image_show_ptr();

	if (config.use_image_queue) {
		cache_on(false);
	}

	imgreading = false;

	if (config.use_image_queue) {
	} else {
		if (imgdata != NULL) {
			free(imgdata);
			imgdata = NULL;
		}
	}

	if (config.use_image_queue) {
		// let cacher delete exif data
		exif_array = NULL;
	} else {
		if (exif_array) {
			buffer_array_free(exif_array);
			exif_array = NULL;
		}
	}

	return selidx;
}
Example #4
0
unsigned long int Iterate ( unsigned short int MSecs, BOOLEAN DisableInts, BOOLEAN DisableCache )
{
	int State  ;						// Tracks which edge (0 or 1/2) we are looking for
	unsigned long int elapsedjiffies ;	// Count of jiffies that have elapsed since we started looping
	unsigned long int lastjiffie ;		// Value of jiffies when we last saw a 0 edige
	unsigned long int jiffieinc ;		// Indicates whether we should increment lastjiffied upon detecting a 0 edige
    unsigned long int busycounter = 0 ;	// Counts number of iterations we manage in the given period
    unsigned long int jiffielimit ;		// Amount of time in jiffies to loop
	unsigned long flags = 0 ;			// Status flags saved when we disable interrupts
    
	//*************************************************************************
	// If we are supposed to disable interrupts or cache?
	//*************************************************************************
	if ( DisableInts )
	{
		// disable interrupts
		save_flags (flags) ;
		cli () ;
	}

	if ( DisableCache )
	{
		cache_off () ;
	}
	
	
	//*************************************************************************
	//* initialize
	//*************************************************************************
	
	// disable interrupts
	{
		unsigned long flags = 0 ;
		
		save_flags (flags) ;
		cli () ;
		
		// wait on an edge
		while ( cnxt_gettimeoffset() != 0 )
		{
			;
		}
		
		// initialize elapsed jiffies
		elapsedjiffies = 0 ;
		
		// initialize lastjiffie
		lastjiffie = jiffies ;
		
		// if interrupts are disabled, don't increment lastjiffie when measuring
		if ( DisableInts )
		{
			jiffieinc = 0 ;
		}
		else
		{
			jiffieinc = 1 ;
		}
		
		// state is initialize to look for half point of cycle since we just saw 0 edge
		State = 1;

		// enable interrupts
		restore_flags (flags) ;
	}
    
    
    
    //*************************************************************************
    //* Measure
    //*************************************************************************
    
    // loop for given period
    jiffielimit = ( MSecs * HZ ) / 1000L ;
    while ( elapsedjiffies <  jiffielimit )
    {
	    // looking for CLOCK_TICK_RATE to 0 edge
	    if ( State == 0 )
	    {
	    	// check for edge before checking for miss since when interrupts are
	    	// enabled, it will always look like we missed 1 when it rolls over.
	    	
	    	// if we passed CLOCK_TICK_RATE to 0 edge
	    	if ( cnxt_gettimeoffset() < (CLOCK_TICK_RATE/2) )
	    	{
	    		// update elapsed counter
	    		elapsedjiffies ++ ;

	    		// update lastjiffie (if interrupts are not disabled) so that we catch next edge
	    		lastjiffie += jiffieinc ;
	    		
	    		// change to state of looking for CLOCK_TICK_RATE/2 edge
	    		State = 1 ;
	    	}

	    	// if we missed this edge (and the following CLOCK_TICK_RATE/2 edge)
	    	else if ( lastjiffie != jiffies )
	    	{
	    		//  elapsed counter
	    		elapsedjiffies ++ ;

	    		// update lastjiffie (if interrupts are not disabled) so that we catch next edge
	    		lastjiffie += jiffieinc ;
	    		
	    		// change to state of looking for CLOCK_TICK_RATE/2 edge
	    		State = 1 ;
	    	}
	    }
	    else
	    // looking for CLOCK_TICK_RATE/2 edge
	    {
	    	// if we passed CLOCK_TICK_RATE/2 edge
	    	if ( cnxt_gettimeoffset() > (CLOCK_TICK_RATE/2) )
	    	{
	    		// change to state of looking for CLOCK_TICK_RATE/0 edge
	    		State = 0 ;
	    	}

	    	// if we missed this edge (and the following CLOCK_TICK_RATE to 0 edge)
	    	else if ( lastjiffie != jiffies )
	    	{
	    		// change to state of looking for CLOCK_TICK_RATE/0 edge
	    		State = 0 ;
	    	}
	    }
    	
    	// bump busyness counter for each pass through loop
    	busycounter++ ;
    }
    
    //*************************************************************************
    // enable interrupts or cache if disabled
	//*************************************************************************
	if ( DisableCache )
	{
		cache_on () ;
	}
	
	
	if ( DisableInts )
	{
		restore_flags (flags) ;
	}
	
	return busycounter ;
}