📄 pmp_play.c.svn-base
字号:
/*PMP ModCopyright (C) 2006 jonnyHomepage: http://jonny.leffe.dnsalias.comE-mail: jonny@leffe.dnsalias.comThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*//*this play the file (av output and basic functions - pause, seek ... )*/#include "pmp_play.h"void pmp_play_safe_constructor(struct pmp_play_struct *p) { p->audio_reserved = -1; p->semaphore_can_get = -1; p->semaphore_can_put = -1; p->semaphore_can_show = -1; p->semaphore_show_done = -1; p->output_thread = -1; p->show_thread = -1; pmp_decode_safe_constructor(&p->decoder); }void pmp_play_close(struct pmp_play_struct *p, int usePos, int pspType) { if (!(p->audio_reserved < 0)) { while(sceAudioGetChannelRestLen(0) > 0 ); sceAudioChRelease(0); } cooleyesAudioSetFrequency(sceKernelDevkitVersion(), 44100); if (!(p->semaphore_can_get < 0)) sceKernelDeleteSema(p->semaphore_can_get); if (!(p->semaphore_can_put < 0)) sceKernelDeleteSema(p->semaphore_can_put); if (!(p->semaphore_can_show < 0)) sceKernelDeleteSema(p->semaphore_can_show); if (!(p->semaphore_show_done < 0)) sceKernelDeleteSema(p->semaphore_show_done); if (!(p->output_thread < 0)) sceKernelDeleteThread(p->output_thread); if (!(p->show_thread < 0)) sceKernelDeleteThread(p->show_thread); pmp_decode_close(&p->decoder, pspType); int i = 0; for (i=0; i<p->subtitle_count; i++) subtitle_parse_close( &subtitle_parser[i] ); //if (usePos) pmp_stat_save( p ); pmp_stat_save( p ); pmp_play_safe_constructor(p); } static int pmp_wait(volatile struct pmp_play_struct *p, SceUID s, char *e) { SceUInt t = 1000000; while (1) { int result = sceKernelWaitSema(s, 1, &t); if (result == SCE_KERNEL_ERROR_OK) { break; } else if (result == SCE_KERNEL_ERROR_WAIT_TIMEOUT) { sceKernelDelayThread(1); if (p->return_request == 1) { return(0); } } else { p->return_result = e; p->return_request = 1; return(0); } } return(1); }static int pmp_show_thread(SceSize input_length, void *input) { volatile struct pmp_play_struct *p = *((void **) input); unsigned int current_buffer_number = 0; while (p->return_request == 0) { if (pmp_wait(p, p->semaphore_can_show, "pmp_show_thread: sceKernelWaitSema failed on semaphore_can_show") == 0) { break; } sceDisplayWaitVblankStart(); sceDisplaySetFrameBuf(p->decoder.output_frame_buffers[current_buffer_number].video_frame, p->decoder.output_texture_width, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_IMMEDIATE); if (sceKernelSignalSema(p->semaphore_show_done, 1) < 0) { p->return_result = "pmp_show_thread: sceKernelSignalSema failed on semaphore_show_done"; p->return_request = 1; break; } current_buffer_number = (current_buffer_number + 1) % p->decoder.number_of_frame_buffers; } return(0); }unsigned int FONTCOLORS[] ={ 0xffffff, 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0x00ffff};unsigned int BORDERCOLORS[] ={ 0x000000, 0x7f0000, 0x007f00, 0x00007f, 0x7f7f00, 0x007f7f};static void pmp_input(volatile struct pmp_play_struct *p, SceCtrlData *previous_controller) { scePowerTick(0); SceCtrlData controller; sceCtrlReadBufferPositive(&controller, 1); if(1) { if (((controller.Buttons & PSP_CTRL_TRIANGLE) == 0) && (previous_controller->Buttons & PSP_CTRL_TRIANGLE)) { p->return_request = 1; //add by cooleyes 2007/01/16 p->return_result = "exit: manual"; //add end } else { if (p->paused == 1) { p->seek = 0; if ((controller.Buttons & PSP_CTRL_SQUARE) && ((previous_controller->Buttons & PSP_CTRL_SQUARE) == 0)) { p->paused = 0; } else if ((controller.Buttons & PSP_CTRL_CIRCLE) && ((previous_controller->Buttons & PSP_CTRL_CIRCLE) == 0)) { make_screenshot(); } } else { if (controller.Buttons & PSP_CTRL_CROSS) { if (controller.Buttons & PSP_CTRL_RIGHT) { p->seek = 2; } else if (controller.Buttons & PSP_CTRL_LEFT) { p->seek = -2; } else { p->seek = 0; if ((controller.Buttons & PSP_CTRL_UP) && ((previous_controller->Buttons & PSP_CTRL_UP) == 0)) { if (p->zoom != 200) { p->zoom += 5; } } else if ((controller.Buttons & PSP_CTRL_DOWN) && ((previous_controller->Buttons & PSP_CTRL_DOWN) == 0)) { if (p->zoom != 100) { p->zoom -= 5; } } else if ((controller.Buttons & PSP_CTRL_RTRIGGER) && ((previous_controller->Buttons & PSP_CTRL_RTRIGGER) == 0)) { if (p->loop == 0) { p->loop = 1; } else { p->loop = 0; } } else if ((controller.Buttons & PSP_CTRL_LTRIGGER) && ((previous_controller->Buttons & PSP_CTRL_LTRIGGER) == 0)) { if (p->subtitle_count) { p->subtitle = (p->subtitle + 1)%(p->subtitle_count+1); if (p->subtitle) snprintf(info_string,512,"[i]%s[/i]", subtitle_parser[p->subtitle-1].filename); else snprintf(info_string,512,"[i]no subtitle[/i]"); info_count = 60; } } //remove by cooleyes 2007/02/01 /*/ else if ((controller.Buttons & PSP_CTRL_SELECT) && ((previous_controller->Buttons & PSP_CTRL_SELECT) == 0)) { p->subtitle_format ^= 1; if (p->subtitle_format) snprintf(info_string,512,"[i]UTF-8[/i]"); else snprintf(info_string,512,"[i]ASCII[/i]"); info_count = 60; } //*/ //remove end else if ((controller.Buttons & PSP_CTRL_SQUARE) && ((previous_controller->Buttons & PSP_CTRL_SQUARE) == 0)) { p->subtitle_fontcolor = (p->subtitle_fontcolor+1)%NUMBER_OF_FONTCOLORS; gu_font_color_set( FONTCOLORS[p->subtitle_fontcolor] ); } else if ((controller.Buttons & PSP_CTRL_CIRCLE) && ((previous_controller->Buttons & PSP_CTRL_CIRCLE) == 0)) { p->subtitle_bordercolor = (p->subtitle_bordercolor+1)%NUMBER_OF_BORDERCOLORS; gu_font_border_color_set( BORDERCOLORS[p->subtitle_bordercolor] ); } //add by cooleyes 2007/02/01 else if ((controller.Buttons & PSP_CTRL_SELECT) && ((previous_controller->Buttons & PSP_CTRL_SELECT) == 0)) { if(p->audio_channel > -1) { p->audio_channel--; } else { p->audio_channel = 1; } } //add end else if ((controller.Buttons & PSP_CTRL_START) && ((previous_controller->Buttons & PSP_CTRL_START) == 0)) { gu_lcd_output_inversion_set(); } } } else if ((controller.Buttons & PSP_CTRL_SQUARE) && ((previous_controller->Buttons & PSP_CTRL_SQUARE) == 0)) { p->paused = 1; p->seek = 0; } else if (controller.Buttons & PSP_CTRL_RIGHT) { p->seek = 1; } else if (controller.Buttons & PSP_CTRL_LEFT) { p->seek = -1; } else if ((controller.Buttons & PSP_CTRL_SELECT) && ((previous_controller->Buttons & PSP_CTRL_SELECT) == 0)) { if (p->audio_stream + 1 == p->decoder.reader.file.header.audio.number_of_streams) { p->audio_stream = 0; } else { p->audio_stream ++; } } else if ((controller.Buttons & PSP_CTRL_UP) && ((previous_controller->Buttons & PSP_CTRL_UP) == 0)) { if (p->volume_boost != 6) { p->volume_boost ++; } pcm_set_normalize_ratio(p->volume_boost); } else if ((controller.Buttons & PSP_CTRL_DOWN) && ((previous_controller->Buttons & PSP_CTRL_DOWN) == 0)) { if (p->volume_boost != 0) { p->volume_boost --; } pcm_set_normalize_ratio(p->volume_boost); } else if ((controller.Buttons & PSP_CTRL_RTRIGGER) && ((previous_controller->Buttons & PSP_CTRL_RTRIGGER) == 0)) { if (p->luminosity_boost != (number_of_luminosity_boosts - 1)) { p->luminosity_boost ++; } } else if ((controller.Buttons & PSP_CTRL_LTRIGGER) && ((previous_controller->Buttons & PSP_CTRL_LTRIGGER) == 0)) { if (p->luminosity_boost != 0) { p->luminosity_boost --; } } else if ((controller.Buttons & PSP_CTRL_START) && ((previous_controller->Buttons & PSP_CTRL_START) == 0)) { if (p->aspect_ratio != (number_of_aspect_ratios - 1)) { p->aspect_ratio ++; } else { p->aspect_ratio = 0; } } else if ((controller.Buttons & PSP_CTRL_CIRCLE) && ((previous_controller->Buttons & PSP_CTRL_CIRCLE) == 0)) { if (p->show_interface == 0) { p->show_interface = 1; } else { p->show_interface = 0; } } else { p->seek = 0; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -