From bf3c311ee84e177253c033b84144bbd367d42a86 Mon Sep 17 00:00:00 2001 From: arpi Date: Wed, 23 Oct 2002 14:46:20 +0000 Subject: [PATCH] mpdemux.c|h moved to libinput, mpdemux_check_interrupt() -> mp_input_check_interrupt() git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7863 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 23 +++++++++++++++++++++++ input/input.h | 5 +++++ libmpdemux/Makefile | 2 +- libmpdemux/cache2.c | 3 ++- libmpdemux/mpdemux.c | 25 ------------------------- libmpdemux/mpdemux.h | 2 -- libmpdemux/network.c | 5 +++-- libmpdemux/test.c | 5 +++++ 8 files changed, 39 insertions(+), 31 deletions(-) delete mode 100644 libmpdemux/mpdemux.c delete mode 100644 libmpdemux/mpdemux.h diff --git a/input/input.c b/input/input.c index 95de21775f..66484fa20f 100644 --- a/input/input.c +++ b/input/input.c @@ -1367,3 +1367,26 @@ static int mp_input_print_cmd_list(config_t* cfg) { } exit(0); } + +int +mp_input_check_interrupt(int time) { + mp_cmd_t* cmd; + if((cmd = mp_input_get_cmd(time,0)) == NULL) + return 0; + switch(cmd->id) { + case MP_CMD_QUIT: + case MP_CMD_PLAY_TREE_STEP: + case MP_CMD_PLAY_TREE_UP_STEP: + case MP_CMD_PLAY_ALT_SRC_STEP: + // The cmd will be executed when we are back in the main loop + if(! mp_input_queue_cmd(cmd)) { + mp_msg(MSGT_INPUT,MSGL_ERR,"mpdemux_check_interrupt: can't queue cmd %s\n",cmd->name); + mp_cmd_free(cmd); + } + return 1; + } + mp_cmd_free(cmd); + return 0; +} + + diff --git a/input/input.h b/input/input.h index 9cff8ca7b4..27a73e62d3 100644 --- a/input/input.h +++ b/input/input.h @@ -171,3 +171,8 @@ mp_input_init(void); void mp_input_uninit(void); + +// Interruptible usleep: (used by libmpdemux) +int +mp_input_check_interrupt(int time); + diff --git a/libmpdemux/Makefile b/libmpdemux/Makefile index 169114aa3b..beab9a0e1c 100644 --- a/libmpdemux/Makefile +++ b/libmpdemux/Makefile @@ -3,7 +3,7 @@ LIBNAME = libmpdemux.a include ../config.mak -SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c +SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c ifeq ($(STREAMING),yes) SRCS += asf_streaming.c url.c http.c network.c asf_mmst_streaming.c ifeq ($(STREAMING_LIVE_DOT_COM),yes) diff --git a/libmpdemux/cache2.c b/libmpdemux/cache2.c index 7d42281a13..d2db6afe6c 100644 --- a/libmpdemux/cache2.c +++ b/libmpdemux/cache2.c @@ -26,6 +26,7 @@ int stream_fill_buffer(stream_t *s); int stream_seek_long(stream_t *s,off_t pos); +extern int mp_input_check_interrupt(int time); typedef struct { // constats: @@ -221,7 +222,7 @@ int stream_enable_cache(stream_t *stream,int size,int min,int prefill){ s->max_filepos-s->read_filepos ); if(s->eof) break; // file is smaller than prefill size - if(mpdemux_check_interrupt(PREFILL_SLEEP_TIME)) + if(mp_input_check_interrupt(PREFILL_SLEEP_TIME)) return 0; } return 1; // parent exits diff --git a/libmpdemux/mpdemux.c b/libmpdemux/mpdemux.c deleted file mode 100644 index e1baab7ebb..0000000000 --- a/libmpdemux/mpdemux.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "config.h" -#include - -#include "../input/input.h" -int mpdemux_check_interrupt(int time) { - mp_cmd_t* cmd; - if((cmd = mp_input_get_cmd(time,0)) == NULL) - return 0; - - switch(cmd->id) { - case MP_CMD_QUIT: - case MP_CMD_PLAY_TREE_STEP: - case MP_CMD_PLAY_TREE_UP_STEP: - case MP_CMD_PLAY_ALT_SRC_STEP: - // The cmd will be executed when we are back in the main loop - if(! mp_input_queue_cmd(cmd)) { - printf("mpdemux_check_interrupt: can't queue cmd %s\n",cmd->name); - mp_cmd_free(cmd); - } - return 1; - default: - mp_cmd_free(cmd); - return 0; - } -} diff --git a/libmpdemux/mpdemux.h b/libmpdemux/mpdemux.h deleted file mode 100644 index 939c6936ad..0000000000 --- a/libmpdemux/mpdemux.h +++ /dev/null @@ -1,2 +0,0 @@ - -extern int mpdemux_check_interrupt(int time); diff --git a/libmpdemux/network.c b/libmpdemux/network.c index f101a96d91..522b25b6c1 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -19,7 +19,6 @@ #include "stream.h" #include "demuxer.h" #include "../cfgparser.h" -#include "mpdemux.h" #include "network.h" #include "http.h" @@ -34,6 +33,8 @@ extern int verbose; extern m_config_t *mconfig; +extern int mp_input_check_interrupt(int time); + /* Variables for the command line option -user, -passwd & -bandwidth */ char *network_username; char *network_password; @@ -193,7 +194,7 @@ connect2Server(char *host, int port) { while((ret = select(socket_server_fd+1, NULL, &set, NULL, &tv)) == 0) { if( ret<0 ) mp_msg(MSGT_NETWORK,MSGL_ERR,"select failed\n"); else if(ret > 0) break; - else if(count > 30 || mpdemux_check_interrupt(500)) { + else if(count > 30 || mp_input_check_interrupt(500)) { if(count > 30) mp_msg(MSGT_NETWORK,MSGL_ERR,"Connection timeout\n"); else diff --git a/libmpdemux/test.c b/libmpdemux/test.c index 2d4abe9579..478c03da4e 100644 --- a/libmpdemux/test.c +++ b/libmpdemux/test.c @@ -19,6 +19,11 @@ void skip_audio_frame(sh_audio_t *sh_audio){ void resync_audio_stream(sh_audio_t *sh_audio){ } +int mp_input_check_interrupt(int time){ + if(time) usec_sleep(time); + return 0; +} + // for libmpdvdkit2: #include "../get_path.c"