Mercurial > mplayer.hg
changeset 22823:98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
"implicit declaration of function ¡Æmplayer_put_key¡Ç" warnings
Based on Attila's suggestions.
Approved by Uoti and Ivan.
author | rathann |
---|---|
date | Thu, 29 Mar 2007 17:16:11 +0000 |
parents | 79cac4f79e36 |
children | cd0ec0b1d931 |
files | Gui/win32/gui.c Makefile cfg-mplayer.h fifo.c libvo/vo_aa.c libvo/vo_caca.c libvo/vo_dfbmga.c libvo/vo_directfb2.c libvo/vo_directx.c libvo/vo_ggi.c libvo/vo_quartz.c libvo/vo_sdl.c libvo/vo_winvidix.c libvo/w32_common.c libvo/x11_common.c mp_fifo.c mplayer.c |
diffstat | 17 files changed, 86 insertions(+), 82 deletions(-) [+] |
line wrap: on
line diff
--- a/Gui/win32/gui.c Thu Mar 29 09:27:36 2007 +0000 +++ b/Gui/win32/gui.c Thu Mar 29 17:16:11 2007 +0000 @@ -28,6 +28,7 @@ #include <shlobj.h> #include <version.h> #include <mplayer.h> +#include <mp_fifo.h> #include <mp_msg.h> #include <help_mp.h> #include <input/input.h>
--- a/Makefile Thu Mar 29 09:27:36 2007 +0000 +++ b/Makefile Thu Mar 29 17:16:11 2007 +0000 @@ -41,6 +41,7 @@ SRCS_MPLAYER = mplayer.c \ m_property.c \ + mp_fifo.c \ mp_msg.c \ mixer.c \ parser-mpcmd.c \
--- a/cfg-mplayer.h Thu Mar 29 09:27:36 2007 +0000 +++ b/cfg-mplayer.h Thu Mar 29 17:16:11 2007 +0000 @@ -4,6 +4,8 @@ #include "cfg-common.h" +extern int key_fifo_size; +extern unsigned doubleclick_time; extern int noconsolecontrols; #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
--- a/fifo.c Thu Mar 29 09:27:36 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#include "input/mouse.h" - - -int key_fifo_size = 7; -static int *key_fifo_data = NULL; -static int key_fifo_read=0; -static int key_fifo_write=0; - -static void mplayer_put_key_internal(int code){ - int fifo_free = key_fifo_read - key_fifo_write - 1; - if (fifo_free < 0) fifo_free += key_fifo_size; -// printf("mplayer_put_key(%d)\n",code); - if (key_fifo_data == NULL) - key_fifo_data = malloc(key_fifo_size * sizeof(int)); - if(!fifo_free) return; // FIFO FULL!! - // reserve some space for key release events to avoid stuck keys - if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1)) - return; - key_fifo_data[key_fifo_write]=code; - key_fifo_write=(key_fifo_write+1)%key_fifo_size; -} - -int mplayer_get_key(int fd){ - int key; -// printf("mplayer_get_key(%d)\n",fd); - if (key_fifo_data == NULL) - return MP_INPUT_NOTHING; - if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING; - key=key_fifo_data[key_fifo_read]; - key_fifo_read=(key_fifo_read+1)%key_fifo_size; -// printf("mplayer_get_key => %d\n",key); - return key; -} - - -static unsigned doubleclick_time = 300; - -static void put_double(int code) { - if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9) - mplayer_put_key_internal(code - MOUSE_BTN0 + MOUSE_BTN0_DBL); -} - -void mplayer_put_key(int code) { - static unsigned last_key_time[2]; - static int last_key[2]; - unsigned now = GetTimerMS(); - // ignore system-doubleclick if we generate these events ourselves - if (doubleclick_time && - (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL && - (code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL) - return; - mplayer_put_key_internal(code); - if (code & MP_KEY_DOWN) { - code &= ~MP_KEY_DOWN; - last_key[1] = last_key[0]; - last_key[0] = code; - last_key_time[1] = last_key_time[0]; - last_key_time[0] = now; - if (last_key[1] == code && - now - last_key_time[1] < doubleclick_time) - put_double(code); - return; - } - if (last_key[0] == code && last_key[1] == code && - now - last_key_time[1] < doubleclick_time) - put_double(code); -}
--- a/libvo/vo_aa.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_aa.c Thu Mar 29 17:16:11 2007 +0000 @@ -37,6 +37,7 @@ #include "subopt-helper.h" #include "help_mp.h" #include "mp_msg.h" +#include "mp_fifo.h" #define MESSAGE_DURATION 3 @@ -83,8 +84,6 @@ /* our version of the playmodes :) */ -extern void mplayer_put_key(int code); - /* to disable stdout outputs when curses/linux mode */ extern int quiet;
--- a/libvo/vo_caca.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_caca.c Thu Mar 29 17:16:11 2007 +0000 @@ -26,6 +26,7 @@ #include "osdep/keycodes.h" #include "mp_msg.h" +#include "mp_fifo.h" #include <caca.h> #ifdef CACA_API_VERSION_1
--- a/libvo/vo_dfbmga.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_dfbmga.c Thu Mar 29 17:16:11 2007 +0000 @@ -39,6 +39,7 @@ #include "sub.h" #include "mp_msg.h" #include "aspect.h" +#include "mp_fifo.h" static vo_info_t info = { "DirectFB / Matrox G200/G400/G450/G550", @@ -1425,8 +1426,6 @@ return VO_NOTIMPL; } -extern void mplayer_put_key( int code ); - #include "osdep/keycodes.h" static void
--- a/libvo/vo_directfb2.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_directfb2.c Thu Mar 29 17:16:11 2007 +0000 @@ -47,6 +47,7 @@ #include "mp_msg.h" #include "aspect.h" #include "subopt-helper.h" +#include "mp_fifo.h" #ifndef min #define min(x,y) (((x)<(y))?(x):(y)) @@ -892,8 +893,6 @@ return 0; } -extern void mplayer_put_key(int code); - #include "osdep/keycodes.h" static void check_events(void)
--- a/libvo/vo_directx.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_directx.c Thu Mar 29 17:16:11 2007 +0000 @@ -34,6 +34,7 @@ #include "mp_msg.h" #include "aspect.h" #include "geometry.h" +#include "mp_fifo.h" #ifdef HAVE_NEW_GUI #include "Gui/interface.h" @@ -85,7 +86,6 @@ static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL; static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE}; -extern void mplayer_put_key(int code); //let mplayer handel the keyevents extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); extern int vidmode;
--- a/libvo/vo_ggi.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_ggi.c Thu Mar 29 17:16:11 2007 +0000 @@ -26,6 +26,7 @@ #include "video_out_internal.h" #include "fastmemcpy.h" +#include "mp_fifo.h" #include <ggi/ggi.h> @@ -471,7 +472,6 @@ /* EVENT handling */ #include "osdep/keycodes.h" -extern void mplayer_put_key(int code); static void check_events(void) {
--- a/libvo/vo_quartz.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_quartz.c Thu Mar 29 17:16:11 2007 +0000 @@ -30,6 +30,7 @@ #include "aspect.h" #include "mp_msg.h" #include "m_option.h" +#include "mp_fifo.h" #include "input/input.h" #include "input/mouse.h" @@ -128,7 +129,6 @@ #include "osdep/keycodes.h" -extern void mplayer_put_key(int code); extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); //PROTOTYPE/////////////////////////////////////////////////////////////////
--- a/libvo/vo_sdl.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_sdl.c Thu Mar 29 17:16:11 2007 +0000 @@ -125,6 +125,7 @@ #include "input/input.h" #include "input/mouse.h" #include "subopt-helper.h" +#include "mp_fifo.h" static vo_info_t info = { @@ -1160,7 +1161,6 @@ **/ #include "osdep/keycodes.h" -extern void mplayer_put_key(int code); #define shift_key (event.key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT)) static void check_events (void)
--- a/libvo/vo_winvidix.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/vo_winvidix.c Thu Mar 29 17:16:11 2007 +0000 @@ -22,11 +22,11 @@ #include "aspect.h" #include "mp_msg.h" +#include "mp_fifo.h" #include "vosub_vidix.h" #include "vidix/vidixlib.h" -extern void mplayer_put_key(int code); static vo_info_t info = {
--- a/libvo/w32_common.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/w32_common.c Thu Mar 29 17:16:11 2007 +0000 @@ -10,8 +10,8 @@ #include "video_out.h" #include "aspect.h" #include "w32_common.h" +#include "mp_fifo.h" -extern void mplayer_put_key(int code); extern int enable_mouse_movements; #ifndef MONITOR_DEFAULTTOPRIMARY
--- a/libvo/x11_common.c Thu Mar 29 09:27:36 2007 +0000 +++ b/libvo/x11_common.c Thu Mar 29 17:16:11 2007 +0000 @@ -6,6 +6,7 @@ #include "config.h" #include "mp_msg.h" +#include "mp_fifo.h" #include "x11_common.h" #ifdef X11_FULLSCREEN @@ -557,8 +558,6 @@ #include "osdep/keycodes.h" #include "wskeys.h" -extern void mplayer_put_key(int code); - #ifdef XF86XK_AudioPause static void vo_x11_putkey_ext(int keysym) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mp_fifo.c Thu Mar 29 17:16:11 2007 +0000 @@ -0,0 +1,70 @@ +#include <stdlib.h> +#include "osdep/timer.h" +#include "input/input.h" +#include "input/mouse.h" + + +int key_fifo_size = 7; +static int *key_fifo_data = NULL; +static int key_fifo_read=0; +static int key_fifo_write=0; + +static void mplayer_put_key_internal(int code){ + int fifo_free = key_fifo_read - key_fifo_write - 1; + if (fifo_free < 0) fifo_free += key_fifo_size; +// printf("mplayer_put_key(%d)\n",code); + if (key_fifo_data == NULL) + key_fifo_data = malloc(key_fifo_size * sizeof(int)); + if(!fifo_free) return; // FIFO FULL!! + // reserve some space for key release events to avoid stuck keys + if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1)) + return; + key_fifo_data[key_fifo_write]=code; + key_fifo_write=(key_fifo_write+1)%key_fifo_size; +} + +int mplayer_get_key(int fd){ + int key; +// printf("mplayer_get_key(%d)\n",fd); + if (key_fifo_data == NULL) + return MP_INPUT_NOTHING; + if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING; + key=key_fifo_data[key_fifo_read]; + key_fifo_read=(key_fifo_read+1)%key_fifo_size; +// printf("mplayer_get_key => %d\n",key); + return key; +} + + +unsigned doubleclick_time = 300; + +static void put_double(int code) { + if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9) + mplayer_put_key_internal(code - MOUSE_BTN0 + MOUSE_BTN0_DBL); +} + +void mplayer_put_key(int code) { + static unsigned last_key_time[2]; + static int last_key[2]; + unsigned now = GetTimerMS(); + // ignore system-doubleclick if we generate these events ourselves + if (doubleclick_time && + (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL && + (code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL) + return; + mplayer_put_key_internal(code); + if (code & MP_KEY_DOWN) { + code &= ~MP_KEY_DOWN; + last_key[1] = last_key[0]; + last_key[0] = code; + last_key_time[1] = last_key_time[0]; + last_key_time[0] = now; + if (last_key[1] == code && + now - last_key_time[1] < doubleclick_time) + put_double(code); + return; + } + if (last_key[0] == code && last_key[1] == code && + now - last_key_time[1] < doubleclick_time) + put_double(code); +}
--- a/mplayer.c Thu Mar 29 09:27:36 2007 +0000 +++ b/mplayer.c Thu Mar 29 17:16:11 2007 +0000 @@ -188,7 +188,7 @@ //**************************************************************************// // Common FIFO functions, and keyboard/event FIFO code -#include "fifo.c" +#include "mp_fifo.h" int noconsolecontrols=0; //**************************************************************************//