1. Mplayer 的事件机制
1) mplayer.c 事件使用
// 5.3) 处理暂停 PAUSE
while ((cmd = mp_input_get_cmd(20,1,1)) == NULL) {
if (sh_video && video_out && vo_config_count) video_out->check_events();
...
}
cmd = mp_input_get_cmd(0, 1, 0);
// 5.5) 键盘事件处理
while (!brk_cmd && (cmd = mp_input_get_cmd(0,0,0)) != NULL) {
switch (cmd->id) {
case MP_CMD_SEEK : {
...
}
}
}
2) input/input.h 驱动程序
typedef int (*mp_key_func_t) (int fd);
typedef int (*mp_cmd_func_t) (int fd, char* dest, int size);
typedef void (*mp_close_func_t) (int fd);
extern void (*mp_input_key_cb) (int code); // Set this to grab all incoming key codes
typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);
int mp_input_add_cmd_fd (int fd, // The first arg is a file descriptor
int select, mp_cmd_func_t read_func, mp_close_func_t close_func);
void mp_input_rm_cmd_fd (int fd); // This removes driver, you usually don't need to use it
int mp_input_add_key_fd (int fd, // The args are the same as for the key's drivers.
int select, mp_key_func_t read_func, mp_close_func_t close_func);
void mp_input_rm_key_fd (int fd); // As for the cmd one you usually don't need this function.
3) input/input.h 队列与命令操作
int mp_input_queue_cmd (mp_cmd_t* cmd); // 入队
mp_cmd_t* mp_input_get_queued_cmd (int peek_only); // 出队
mp_cmd_t* mp_input_get_cmd (int time, int paused, int peek_only);// 获取事件命令
mp_cmd_t* mp_input_parse_cmd (char* str); // 分析命令串
void mp_input_add_cmd_filter (mp_input_cmd_filter, void* ctx); // 增加命令过滤器
void mp_cmd_free (mp_cmd_t* cmd);
mp_cmd_t* mp_cmd_clone (mp_cmd_t* cmd);
void mp_input_init (void); // 事件处理初始化
void mp_input_uninit (void); // 事件处理关闭
int mp_input_check_interrupt(int time); //
4) input/input.h 数据结构
- 命令类型
typedef struct mp_cmd {
int id; // 事件号码
char* name; // 事件名称
int nargs; // 事件参数个数
mp_cmd_arg_t args[MP_CMD_MAX_ARGS]; // 键盘事件变量数组
int pausing; // 暂停
} mp_cmd_t;
如 { MP_CMD_LOADFILE, "loadfile", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }
- 按键命名类型
typedef struct mp_key_name {
int key;
char* name;
} mp_key_name_t;
如 { KEY_ENTER, "ENTER" }
KEY_ENTER 定义在 osdep/keycodes.h 文件中
- 命令绑定表
typedef struct mp_cmd_bind {
int input[MP_MAX_KEY_DOWN+1];
char* cmd;
} mp_cmd_bind_t;
如 { { MOUSE_BTN3, 0 }, "seek 10" }
5) input/input.c 事件队列
static mp_cmd_t* cmd_queue[CMD_QUEUE_SIZE]; // 队列缓冲
static unsigned int cmd_queue_length = 0, // 队列长度
cmd_queue_start = 0, // 队列头指针
cmd_queue_end = 0; // 队列尾指针
队列操作:
int mp_input_queue_cmd(mp_cmd_t* cmd); // 入队
static mp_cmd_t* mp_input_get_queued_cmd(int peek_only) // 出队
6) input/Makefile 事件模块库组成
SRCS=input.c joystick.c lirc.c
$(LIBNAME): $(OBJS)
$(AR) r $(LIBNAME) $(OBJS)
$(RANLIB) $(LIBNAME)
all: $(LIBNAME)
7) 键盘配置文件 input.conf 的机制
input.c
/// 按键的名字表,用于 input.conf。如果你要加入一些新键, 你也需要在这里增加
static mp_key_name_t key_names[] = {...}
2. Mplayer 的 GUI 处理
Makefile:
* ifeq ($(GUI),yes)
PARTS += Gui
endif
* ifeq ($(GUI),yes)
COMMON_DEPS += Gui/libgui.a
GUI_LIBS = Gui/libgui.a
endif
* Gui/libgui.a:
$(MAKE) -C Gui
* ifeq ($(GUI),yes)
-ln -sf $(PRG) $(BINDIR)/gmplayer
endif
* ifeq ($(GUI),yes)
@if test ! -d $(DATADIR)/Skin ; then mkdir -p $(DATADIR)/Skin ; fi
@echo "*** Download skin(s) at http://www.mplayerhq.hu/homepage/dload.html"
@echo "*** for GUI, and extract to $(DATADIR)/Skin/"
@if test ! -d $(prefix)/share/pixmaps ; then mkdir -p $(prefix)/share/pixmaps ; fi
$(INSTALL) -m 644 Gui/mplayer/pixmaps/mplayer-desktop.xpm
$(prefix)/share/pixmaps/mplayer-desktop.xpm
@if test ! -d $(prefix)/share/applications;then mkdir -p $(prefix)/share/applications; fi
$(INSTALL) -m 644 etc/mplayer.desktop $(prefix)/share/applications/mplayer.desktop
endif
gui/mplayer/play.h
void mplEnd (void);
void mplFullScreen (void);
void mplPlay (void);
void mplPause (void);
void mplState (void);
void mplPrev (void);
void mplNext (void);
void mplCurr (void);
void mplIncAudioBufDelay(void);
void mplDecAudioBufDelay(void);
void mplRelSeek (float s);
void mplAbsSeek (float s);
float mplGetPosition (void);
void mplPlayFork (void);
void mplSigHandler (int s);
void mplPlayerThread (void);
void ChangeSkin (char* name);
void EventHandling (void);
void mplSetFileName (char* dir, char* name, int type);
gui/mplayer/mplayer.h
void mplInit (void* disp);
void mplEventHandling (int msg, float param);
void mplMainDraw (void);
void mplEventHandling (int msg, float param);
void mplMainMouseHandle(int Button, int X, int Y, int RX, int RY);
void mplMainKeyHandle (int KeyCode, int Type, int Key);
void mplDandDHandler (int num, char** files);
void mplSubDraw (void);
void mplSubMouseHandle (int Button, int X, int Y, int RX, int RY);
void mplMenuInit (void);
void mplHideMenu (int mx, int my, int w);
void mplShowMenu (int mx, int my);
void mplMenuMouseHandle(int X, int Y, int RX, int RY);
void mplPBInit (void);
void mplPBShow (int x, int y);
3. x86 Instruction Reference
Contents
1. Key to Operand Specifications
2. Key to Opcode Descriptions
2.1 Register Values
2.2 Condition Codes
2.3 SSE Condition Predicates
2.4 Status Flags
2.5 Effective Address Encoding: ModR/M and SIB
3. Key to Instruction Flags
4. x86 Instruction Set
4.1 AAA, AAS, AAM, AAD: ASCII Adjustments
...
4.337 XORPS: Bitwise Logical XOR of Single-Precision FP Values
4. 基础性研究项目规划
确定公司至少未来两年视野的技术发展方向?
(skw0rm) |