📄 mpgcontrol.h
字号:
/* mpgcontrol.h mpg123 controller object This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the 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 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, www.gnu.org. Copyright (C) 2000 Simon Harrison (email smh@N_O_S_P_A_M@dr.com)*/#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <stdarg.h>#include <signal.h>#include <unistd.h>#include <sys/types.h>#include <sys/wait.h>#include <string.h>#include <pthread.h>typedef struct { int played; int left; double elapsed; double remaining; bool active;} mpgreturn;/* HINT: The class is a singleton*/class mpgcontroller { private: static const int QUIT; static const int LOAD; static const int STOP; static const int PAUSE; static const int JUMP; static int inpipe[2], outpipe[2]; static struct sigaction handler; static int errno; static pid_t pid; static int buffersize; static char mpgpath[1024]; static fd_set fds; // critical variables. static mpgreturn mpg_data; static pthread_t threadid; static bool now_playing; static char current_track[1024]; static pthread_mutex_t mpg_mutex; // control access to variables // from outside.public: static int quit(); static int load(char*); static int stop(); static int pause(); static int jump(long); static int start_mpg_child( int bufsize, char* mp=NULL ); // size of buffer and path to player as args. static bool wait_for_player( mpgreturn* mpgr ); static char* format_playinfo(mpgreturn *message); static void startthread(); static bool get_safe_data( mpgreturn* mpgr, char* trackname ); private: static void restart_mpg_child( int ); // signal handler for restarting mpg123. static void add_player_descriptor( fd_set* ); // ??? static int send_cmd( int, ... ); // commands to mpg123 once running. static void check_player_output( fd_set*, mpgreturn* ); static mpgreturn *read_cmd( int, mpgreturn* ); // status information, progress. static void* mainthread( void* );};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -