diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-23 17:21:01 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-23 17:21:01 +0000 |
commit | f9e3a4bf886ebfd865e6ffba7edc9c0a6f114b42 (patch) | |
tree | 8db9d460c3bea1a734a69a2740f25de72310c2d0 /libmpdemux | |
parent | a2dfc7a766c2f00408671327838602eebcc4cddf (diff) | |
download | mpv-f9e3a4bf886ebfd865e6ffba7edc9c0a6f114b42.tar.bz2 mpv-f9e3a4bf886ebfd865e6ffba7edc9c0a6f114b42.tar.xz |
cleanup config option handling in libmpdemux.
removed overcompilacted m_config_register_options() mess - export the
subconfig structs instead
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7868 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/cdda.c | 11 | ||||
-rw-r--r-- | libmpdemux/demux_audio.c | 15 | ||||
-rw-r--r-- | libmpdemux/demux_rawaudio.c | 10 | ||||
-rw-r--r-- | libmpdemux/demuxer.c | 24 | ||||
-rw-r--r-- | libmpdemux/network.c | 66 | ||||
-rw-r--r-- | libmpdemux/opt-reg.c | 22 | ||||
-rw-r--r-- | libmpdemux/test.c | 2 |
7 files changed, 23 insertions, 127 deletions
diff --git a/libmpdemux/cdda.c b/libmpdemux/cdda.c index 7e44f93824..b6dd1742ec 100644 --- a/libmpdemux/cdda.c +++ b/libmpdemux/cdda.c @@ -19,7 +19,7 @@ static int toc_bias = 0; static int toc_offset = 0; static int no_skip = 0; -static config_t cdda_opts[] = { +config_t cdda_opts[] = { { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, NULL }, { "paranoia", ¶noia_mode, CONF_TYPE_INT,CONF_RANGE, 0, 2, NULL }, { "generic-dev", &generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, @@ -32,15 +32,6 @@ static config_t cdda_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -static config_t cdda_conf[] = { - { "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, - { NULL,NULL, 0, 0, 0, 0, NULL} -}; - -void cdda_register_options(m_config_t* cfg) { - m_config_register_options(cfg,cdda_conf); -} - stream_t* open_cdda(char* dev,char* track) { stream_t* st; int start_track = 0; diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index ee6c89dd9b..f507fab6b7 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -29,7 +29,7 @@ typedef struct da_priv { extern void free_sh_audio(sh_audio_t* sh); extern void resync_audio_stream(sh_audio_t *sh_audio); -static int hr_mp3_seek = 0; +int hr_mp3_seek = 0; int demux_audio_open(demuxer_t* demuxer) { stream_t *s; @@ -337,16 +337,3 @@ void demux_close_audio(demuxer_t* demuxer) { free(priv); } -/****************** Options stuff ******************/ - -#include "../cfgparser.h" - -static config_t demux_audio_opts[] = { - { "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL }, - { "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {NULL, NULL, 0, 0, 0, 0, NULL} -}; - -void demux_audio_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demux_audio_opts); -} diff --git a/libmpdemux/demux_rawaudio.c b/libmpdemux/demux_rawaudio.c index d1ff7514b2..f92bd8e423 100644 --- a/libmpdemux/demux_rawaudio.c +++ b/libmpdemux/demux_rawaudio.c @@ -17,7 +17,7 @@ static int samplerate = 44100; static int samplesize = 2; static int format = 0x1; // Raw PCM -static config_t demux_rawaudio_opts[] = { +config_t demux_rawaudio_opts[] = { { "on", &use_rawaudio, CONF_TYPE_FLAG, 0,0, 1, NULL }, { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, NULL }, { "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, NULL }, @@ -26,14 +26,6 @@ static config_t demux_rawaudio_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -static config_t demux_rawaudio_conf[] = { - { "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, - { NULL,NULL, 0, 0, 0, 0, NULL} -}; - -void demux_rwaudio_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demux_rawaudio_conf); -} extern void resync_audio_stream(sh_audio_t *sh_audio); diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 08a235fcf9..a41378c061 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1037,9 +1037,10 @@ return demuxer; } char* audio_stream = NULL; -static char* sub_stream = NULL; -static int demuxer_type = 0, audio_demuxer_type = 0, sub_demuxer_type = 0; -extern m_config_t* mconfig; +char* sub_stream = NULL; +int demuxer_type = 0, audio_demuxer_type = 0, sub_demuxer_type = 0; + +extern int hr_mp3_seek; demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int dvdsub_id){ stream_t *as = NULL,*ss = NULL; @@ -1069,7 +1070,7 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int if(!ad) mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream); else if(ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3 - m_config_set_flag(mconfig,"hr-mp3-seek",1); // Enable high res seeking + hr_mp3_seek=1; // Enable high res seeking } if(ss) { sd = demux_open_stream(ss,sub_demuxer_type ? sub_demuxer_type : sfmt,-2,-2,dvdsub_id); @@ -1245,18 +1246,3 @@ char* demux_info_get(demuxer_t *demuxer, char *opt) { return NULL; } -/******************* Options stuff **********************/ - -static config_t demuxer_opts[] = { - { "audiofile", &audio_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "subfile", &sub_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "demuxer", &demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { "audio-demuxer", &audio_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { "sub-demuxer", &sub_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -void demuxer_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demuxer_opts); -} - diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 522b25b6c1..d49515cb13 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -31,14 +31,14 @@ #include "../version.h" extern int verbose; -extern m_config_t *mconfig; +extern int stream_cache_size; extern int mp_input_check_interrupt(int time); /* Variables for the command line option -user, -passwd & -bandwidth */ -char *network_username; -char *network_password; -int network_bandwidth; +char *network_username=NULL; +char *network_password=NULL; +int network_bandwidth=0; static struct { @@ -381,34 +381,24 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) { } else { mp_msg(MSGT_NETWORK,MSGL_INFO,"Authentication required\n"); } - ret = m_config_is_option_set(mconfig,"user"); - if( ret==1 ) { - char *username; - username = *((char**)m_config_get_option_ptr(mconfig, "user")); - if( username==NULL ) return -1; - url->username = (char*)malloc(strlen(username)+1); + if( network_username ) { + url->username = strdup(network_username); if( url->username==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); return -1; } - strcpy(url->username, username); } else { mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to read the username\n"); mp_msg(MSGT_NETWORK,MSGL_ERR,"Please use the option -user and -passwd to provide your username/password for a list of URLs,\n"); mp_msg(MSGT_NETWORK,MSGL_ERR,"or form an URL like: http://username:password@hostname/file\n"); return -1; } - ret = m_config_is_option_set(mconfig,"passwd"); - if( ret==1 ) { - char *password; - password = *((char**)m_config_get_option_ptr(mconfig, "passwd")); - if( password==NULL ) return -1; - url->password = (char*)malloc(strlen(password)+1); + if( network_password ) { + url->password = strdup(network_password); if( url->password==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); return -1; } - strcpy(url->password, password); } else { mp_msg(MSGT_NETWORK,MSGL_INFO,"No password provided, trying blank password\n"); } @@ -830,18 +820,7 @@ streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { ret = -1; // Get the bandwidth available - ret = m_config_is_option_set(mconfig,"bandwidth"); - if(ret < 0) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to know if the bandwidth limit was set\n"); - } else { - val = m_config_get_int( mconfig, "bandwidth", NULL); - if( val<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to retrieve the bandwidth option value\n"); - stream->streaming_ctrl->bandwidth = 0; // Don't limit bandwidth - } else { - stream->streaming_ctrl->bandwidth = val; - } - } + stream->streaming_ctrl->bandwidth = network_bandwidth; #ifndef STREAMING_LIVE_DOT_COM // For RTP streams, we usually don't know the stream type until we open it. @@ -905,31 +884,14 @@ streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { streaming_ctrl_free( stream->streaming_ctrl ); stream->streaming_ctrl = NULL; } else if( stream->streaming_ctrl->buffering ) { - int cache_size = 0; - int cache_opt, val; - cache_opt = m_config_is_option_set(mconfig,"cache"); - if(cache_opt < 0) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to know if cache size option was set\n"); - } else if(!cache_opt) { + int cache_size = stream_cache_size; + if(!stream_cache_size) { // cache option not set, will use our computed value. // buffer in KBytes, *5 because the prefill is 20% of the buffer. - val = (stream->streaming_ctrl->prebuffer_size/1024)*5; - if( val<16 ) val = 16; // 16KBytes min buffer - if( m_config_set_int( mconfig, "cache", val )<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to set the cache size option\n"); - } else { - cache_size = val; - } - } else { - // cache option set, will use the given one. - val = m_config_get_int( mconfig, "cache", NULL ); - if( val<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to retrieve the cache option value\n"); - } else { - cache_size = val; - } + stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5; + if( stream_cache_size<16 ) stream_cache_size = 16; // 16KBytes min buffer } - mp_msg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", cache_size ); + mp_msg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", stream_cache_size); } return ret; diff --git a/libmpdemux/opt-reg.c b/libmpdemux/opt-reg.c deleted file mode 100644 index 8c241934b8..0000000000 --- a/libmpdemux/opt-reg.c +++ /dev/null @@ -1,22 +0,0 @@ - -#include "config.h" -#include <stdlib.h> -#include <stdio.h> -#include "../cfgparser.h" - -extern void demux_audio_register_options(m_config_t* cfg); -extern void demuxer_register_options(m_config_t* cfg); -extern void demux_rwaudio_register_options(m_config_t* cfg); -#ifdef HAVE_CDDA -extern void cdda_register_options(m_config_t* cfg); -#endif - -void libmpdemux_register_options(m_config_t* cfg) { - - demux_audio_register_options(cfg); - demuxer_register_options(cfg); - demux_rwaudio_register_options(cfg); -#ifdef HAVE_CDDA - cdda_register_options(cfg); -#endif -} diff --git a/libmpdemux/test.c b/libmpdemux/test.c index 478c03da4e..bee727e84a 100644 --- a/libmpdemux/test.c +++ b/libmpdemux/test.c @@ -20,7 +20,7 @@ void resync_audio_stream(sh_audio_t *sh_audio){ } int mp_input_check_interrupt(int time){ - if(time) usec_sleep(time); + if(time) usleep(time); return 0; } |