summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/decode/ad_lavc.c4
-rw-r--r--audio/filter/af_export.c4
-rw-r--r--audio/out/ao_alsa.c4
-rw-r--r--core/parser-cfg.c10
-rw-r--r--demux/demux_ts.c12
-rw-r--r--stream/asf_streaming.c6
-rw-r--r--stream/cookies.c25
-rw-r--r--stream/http.c43
-rw-r--r--stream/network.c10
-rw-r--r--stream/network.h3
-rw-r--r--stream/stream_udp.c6
-rw-r--r--stream/tcp.c12
-rw-r--r--stream/tv.c57
-rw-r--r--stream/udp.c14
-rw-r--r--sub/spudec.c5
-rw-r--r--sub/subreader.c4
-rw-r--r--sub/vobsub.c12
17 files changed, 113 insertions, 118 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index ac72d62212..8553e93cf1 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -192,11 +192,11 @@ static int init(sh_audio_t *sh_audio)
mp_msg(MSGT_DECAUDIO, MSGL_V, "INFO: libavcodec \"%s\" init OK!\n",
lavc_codec->name);
- if (sh_audio->format == 0x3343414D) {
+ if (sh_audio->wf && sh_audio->format == 0x3343414D) {
// MACE 3:1
sh_audio->ds->ss_div = 2 * 3; // 1 samples/packet
sh_audio->ds->ss_mul = 2 * sh_audio->wf->nChannels; // 1 byte*ch/packet
- } else if (sh_audio->format == 0x3643414D) {
+ } else if (sh_audio->wf && sh_audio->format == 0x3643414D) {
// MACE 6:1
sh_audio->ds->ss_div = 2 * 6; // 1 samples/packet
sh_audio->ds->ss_mul = 2 * sh_audio->wf->nChannels; // 1 byte*ch/packet
diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c
index 2e25d8a642..2687904ebd 100644
--- a/audio/filter/af_export.c
+++ b/audio/filter/af_export.c
@@ -103,9 +103,11 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Init memory mapping
s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC, 0640);
mp_msg(MSGT_AFILTER, MSGL_INFO, "[export] Exporting to file: %s\n", s->filename);
- if(s->fd < 0)
+ if(s->fd < 0) {
mp_msg(MSGT_AFILTER, MSGL_FATAL, "[export] Could not open/create file: %s\n",
s->filename);
+ return AF_ERROR;
+ }
// header + buffer
mapsize = (SIZE_HEADER + (af->data->bps * s->sz * af->data->nch));
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index cd50a1c1d5..4fe744320b 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -818,13 +818,13 @@ static int play(void* data, int len, int flags)
mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Trying to reset soundcard.\n");
if ((res = snd_pcm_prepare(alsa_handler)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm prepare error: %s\n", snd_strerror(res));
- return 0;
break;
}
+ res = 0;
}
} while (res == 0);
- return res < 0 ? res : res * bytes_per_sample;
+ return res < 0 ? 0 : res * bytes_per_sample;
}
/* how many byes are free in the buffer */
diff --git a/core/parser-cfg.c b/core/parser-cfg.c
index a0e758e6a3..bf97dde010 100644
--- a/core/parser-cfg.c
+++ b/core/parser-cfg.c
@@ -49,8 +49,8 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
#define MAX_LINE_LEN 10000
#define MAX_OPT_LEN 1000
#define MAX_PARAM_LEN 1500
- FILE *fp;
- char *line;
+ FILE *fp = NULL;
+ char *line = NULL;
char opt[MAX_OPT_LEN + 1];
char param[MAX_PARAM_LEN + 1];
char c; /* for the "" and '' check */
@@ -86,7 +86,6 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
if ((fp = fopen(conffile, "r")) == NULL) {
mp_msg(MSGT_CFGPARSER, MSGL_V, ": %s\n", strerror(errno));
- free(line);
ret = 0;
goto out;
}
@@ -238,9 +237,10 @@ nextline:
;
}
- free(line);
- fclose(fp);
out:
+ free(line);
+ if (fp)
+ fclose(fp);
config->mode = prev_mode;
--recursion_depth;
if (ret < 0) {
diff --git a/demux/demux_ts.c b/demux/demux_ts.c
index a28f177f8e..ef6186f79a 100644
--- a/demux/demux_ts.c
+++ b/demux/demux_ts.c
@@ -362,13 +362,13 @@ static void ts_add_stream(demuxer_t * demuxer, ES_stream_t *es)
if (lang && lang[0])
mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_AID_%d_LANG=%s\n", es->pid, lang);
priv->last_aid++;
- }
- if(es->extradata && es->extradata_len)
- {
- sh->wf = malloc(sizeof(*sh->wf) + es->extradata_len);
- sh->wf->cbSize = es->extradata_len;
- memcpy(sh->wf + 1, es->extradata, es->extradata_len);
+ if(es->extradata && es->extradata_len)
+ {
+ sh->wf = malloc(sizeof(*sh->wf) + es->extradata_len);
+ sh->wf->cbSize = es->extradata_len;
+ memcpy(sh->wf + 1, es->extradata, es->extradata_len);
+ }
}
}
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c
index f81b5dd983..e7ca8468db 100644
--- a/stream/asf_streaming.c
+++ b/stream/asf_streaming.c
@@ -825,8 +825,6 @@ err_out:
}
static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
- URL_t *url;
-
stream->streaming_ctrl = streaming_ctrl_new();
if( stream->streaming_ctrl==NULL ) {
return STREAM_ERROR;
@@ -834,9 +832,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
stream->streaming_ctrl->audio_id_ptr = &stream->opts->audio_id;
stream->streaming_ctrl->video_id_ptr = &stream->opts->video_id;
stream->streaming_ctrl->bandwidth = network_bandwidth;
- url = url_new(stream->url);
- stream->streaming_ctrl->url = check4proxies(url);
- url_free(url);
+ stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
mp_tmsg(MSGT_OPEN, MSGL_INFO, "STREAM_ASF, URL: %s\n", stream->url);
if((!strncmp(stream->url, "http", 4)) && (*file_format!=DEMUXER_TYPE_ASF && *file_format!=DEMUXER_TYPE_UNKNOWN)) {
diff --git a/stream/cookies.c b/stream/cookies.c
index 2680bf1834..62025b157b 100644
--- a/stream/cookies.c
+++ b/stream/cookies.c
@@ -112,44 +112,49 @@ static int parse_line(char **ptr, char *cols[6])
/* Loads a file into RAM */
static char *load_file(const char *filename, off_t * length)
{
- int fd;
- char *buffer;
+ int fd = -1;
+ char *buffer = NULL;
mp_msg(MSGT_NETWORK, MSGL_V, "Loading cookie file: %s\n", filename);
fd = open(filename, O_RDONLY);
if (fd < 0) {
mp_msg(MSGT_NETWORK, MSGL_V, "Could not open");
- return NULL;
+ goto err_out;
}
*length = lseek(fd, 0, SEEK_END);
if (*length < 0) {
mp_msg(MSGT_NETWORK, MSGL_V, "Could not find EOF");
- return NULL;
+ goto err_out;
}
if (*length > SIZE_MAX - 1) {
mp_msg(MSGT_NETWORK, MSGL_V, "File too big, could not malloc.");
- return NULL;
+ goto err_out;
}
lseek(fd, 0, SEEK_SET);
if (!(buffer = malloc(*length + 1))) {
mp_msg(MSGT_NETWORK, MSGL_V, "Could not malloc.");
- return NULL;
+ goto err_out;
}
if (read(fd, buffer, *length) != *length) {
mp_msg(MSGT_NETWORK, MSGL_V, "Read is behaving funny.");
- return NULL;
+ goto err_out;
}
close(fd);
buffer[*length] = 0;
return buffer;
+
+err_out:
+ if (fd != -1) close(fd);
+ free(buffer);
+ return NULL;
}
/* Loads a cookies.txt file into a linked list. */
@@ -164,7 +169,7 @@ static struct cookie_list_type *load_cookies_from(const char *filename,
if (!ptr)
return list;
- while (*ptr > 0) {
+ while (*ptr) {
char *cols[7];
if (parse_line(&ptr, cols)) {
struct cookie_list_type *new;
@@ -178,6 +183,7 @@ static struct cookie_list_type *load_cookies_from(const char *filename,
list = new;
}
}
+ free(ptr);
return list;
}
@@ -253,6 +259,5 @@ cookies_set(HTTP_header_t * http_hdr, const char *domain, const char *url)
if (found_cookies)
http_set_field(http_hdr, buf);
- else
- free(buf);
+ free(buf);
}
diff --git a/stream/http.c b/stream/http.c
index a6d977c10a..1638d80790 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -223,7 +223,6 @@ static int scast_streaming_start(stream_t *stream) {
static int nop_streaming_start( stream_t *stream ) {
HTTP_header_t *http_hdr = NULL;
char *next_url=NULL;
- URL_t *rd_url=NULL;
int fd,ret;
if( stream==NULL ) return -1;
@@ -253,12 +252,9 @@ static int nop_streaming_start( stream_t *stream ) {
ret=-1;
next_url = http_get_field( http_hdr, "Location" );
- if (next_url != NULL)
- rd_url=url_new(next_url);
-
- if (next_url != NULL && rd_url != NULL) {
+ if (next_url != NULL) {
mp_msg(MSGT_NETWORK,MSGL_STATUS,"Redirected: Using this url instead %s\n",next_url);
- stream->streaming_ctrl->url=check4proxies(rd_url);
+ stream->streaming_ctrl->url=url_new_with_proxy(next_url);
ret=nop_streaming_start(stream); //recursively get streaming started
} else {
mp_msg(MSGT_NETWORK,MSGL_ERR,"Redirection failed\n");
@@ -402,7 +398,7 @@ http_response_parse( HTTP_header_t *http_hdr ) {
// Get the reason phrase
ptr = strstr( hdr_ptr, "\n" );
- if( hdr_ptr==NULL ) {
+ if( ptr==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_ERR,"Malformed answer. Unable to get the reason phrase.\n");
return -1;
}
@@ -463,24 +459,20 @@ http_response_parse( HTTP_header_t *http_hdr ) {
char *
http_build_request( HTTP_header_t *http_hdr ) {
- char *ptr, *uri;
+ char *ptr;
int len;
HTTP_field_t *field;
if( http_hdr==NULL ) return NULL;
if( http_hdr->uri==NULL ) return NULL;
if( http_hdr->method==NULL ) http_set_method( http_hdr, "GET");
-
- uri = malloc(strlen(http_hdr->uri) + 1);
- if( uri==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n");
- return NULL;
- }
- strcpy(uri,http_hdr->uri);
+ if( http_hdr->uri==NULL ) http_set_uri( http_hdr, "/");
+ if( !http_hdr->uri || !http_hdr->method)
+ return NULL;
//**** Compute the request length
// Add the Method line
- len = strlen(http_hdr->method)+strlen(uri)+12;
+ len = strlen(http_hdr->method)+strlen(http_hdr->uri)+12;
// Add the fields
field = http_hdr->first_field;
while( field!=NULL ) {
@@ -508,7 +500,7 @@ http_build_request( HTTP_header_t *http_hdr ) {
//*** Building the request
ptr = http_hdr->buffer;
// Add the method line
- ptr += sprintf( ptr, "%s %s HTTP/1.%d\r\n", http_hdr->method, uri, http_hdr->http_minor_version );
+ ptr += sprintf( ptr, "%s %s HTTP/1.%d\r\n", http_hdr->method, http_hdr->uri, http_hdr->http_minor_version );
field = http_hdr->first_field;
// Add the field
while( field!=NULL ) {
@@ -521,7 +513,6 @@ http_build_request( HTTP_header_t *http_hdr ) {
memcpy( ptr, http_hdr->body, http_hdr->body_size );
}
- free(uri);
return http_hdr->buffer;
}
@@ -726,7 +717,7 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
do
{
redirect = 0;
- if (fd > 0) closesocket(fd);
+ if (fd >= 0) closesocket(fd);
fd = http_send_request( url, 0 );
if( fd<0 ) {
goto err_out;
@@ -856,12 +847,12 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
} while( redirect );
err_out:
- if (fd > 0) closesocket( fd );
+ if (fd >= 0) closesocket( fd );
fd = -1;
http_free( http_hdr );
http_hdr = NULL;
out:
- stream->streaming_ctrl->data = (void*)http_hdr;
+ stream->streaming_ctrl->data = http_hdr;
stream->fd = fd;
return res;
}
@@ -895,16 +886,13 @@ static int fixup_open(stream_t *stream,int seekable) {
static int open_s1(stream_t *stream,int mode, void* opts, int* file_format) {
int seekable=0;
- URL_t *url;
stream->streaming_ctrl = streaming_ctrl_new();
if( stream->streaming_ctrl==NULL ) {
return STREAM_ERROR;
}
stream->streaming_ctrl->bandwidth = network_bandwidth;
- url = url_new(stream->url);
- stream->streaming_ctrl->url = check4proxies(url);
- url_free(url);
+ stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
mp_msg(MSGT_OPEN, MSGL_V, "STREAM_HTTP(1), URL: %s\n", stream->url);
seekable = http_streaming_start(stream, file_format);
@@ -924,16 +912,13 @@ static int open_s1(stream_t *stream,int mode, void* opts, int* file_format) {
static int open_s2(stream_t *stream,int mode, void* opts, int* file_format) {
int seekable=0;
- URL_t *url;
stream->streaming_ctrl = streaming_ctrl_new();
if( stream->streaming_ctrl==NULL ) {
return STREAM_ERROR;
}
stream->streaming_ctrl->bandwidth = network_bandwidth;
- url = url_new(stream->url);
- stream->streaming_ctrl->url = check4proxies(url);
- url_free(url);
+ stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
mp_msg(MSGT_OPEN, MSGL_V, "STREAM_HTTP(2), URL: %s\n", stream->url);
seekable = http_streaming_start(stream, file_format);
diff --git a/stream/network.c b/stream/network.c
index c324017d48..b23ed8ef02 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -106,7 +106,7 @@ streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl ) {
}
URL_t*
-check4proxies( URL_t *url ) {
+check4proxies( const URL_t *url ) {
URL_t *url_out = NULL;
if( url==NULL ) return NULL;
url_out = url_new( url->url );
@@ -161,6 +161,14 @@ check4proxies( URL_t *url ) {
return url_out;
}
+URL_t *url_new_with_proxy(const char *urlstr)
+{
+ URL_t *url = url_new(urlstr);
+ URL_t *url_with_proxy = check4proxies(url);
+ url_free(url);
+ return url_with_proxy;
+}
+
int
http_send_request( URL_t *url, off_t pos ) {
HTTP_header_t *http_hdr;
diff --git a/stream/network.h b/stream/network.h
index 33b668c516..96d486e910 100644
--- a/stream/network.h
+++ b/stream/network.h
@@ -74,7 +74,8 @@ int http_send_request(URL_t *url, off_t pos);
HTTP_header_t *http_read_response(int fd);
int http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry);
-URL_t* check4proxies(URL_t *url);
+URL_t* check4proxies(const URL_t *url);
+URL_t *url_new_with_proxy(const char *urlstr);
void fixup_network_stream_cache(stream_t *stream);
int http_seek(stream_t *stream, off_t pos);
diff --git a/stream/stream_udp.c b/stream/stream_udp.c
index 5b901cf543..2654a01577 100644
--- a/stream/stream_udp.c
+++ b/stream/stream_udp.c
@@ -61,7 +61,6 @@ udp_streaming_start (stream_t *stream)
static int
udp_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
{
- URL_t *url;
extern int network_bandwidth;
mp_msg (MSGT_OPEN, MSGL_INFO, "STREAM_UDP, URL: %s\n", stream->url);
@@ -70,10 +69,9 @@ udp_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
return STREAM_ERROR;
stream->streaming_ctrl->bandwidth = network_bandwidth;
- url = url_new (stream->url);
- stream->streaming_ctrl->url = check4proxies (url);
+ stream->streaming_ctrl->url = url_new(stream->url);
- if (url->port == 0)
+ if (stream->streaming_ctrl->url->port == 0)
{
mp_msg (MSGT_NETWORK, MSGL_ERR,
"You must enter a port number for UDP streams!\n");
diff --git a/stream/tcp.c b/stream/tcp.c
index 54ebf33e61..be27c490dc 100644
--- a/stream/tcp.c
+++ b/stream/tcp.c
@@ -127,9 +127,9 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
#endif
switch (af) {
- case AF_INET: our_s_addr = (void *) &server_address.four.sin_addr; break;
+ case AF_INET: our_s_addr = &server_address.four.sin_addr; break;
#ifdef HAVE_AF_INET6
- case AF_INET6: our_s_addr = (void *) &server_address.six.sin6_addr; break;
+ case AF_INET6: our_s_addr = &server_address.six.sin6_addr; break;
#endif
default:
mp_tmsg(MSGT_NETWORK,MSGL_ERR, "Unknown address family %d\n", af);
@@ -150,21 +150,21 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
if(verb) mp_tmsg(MSGT_NETWORK,MSGL_STATUS,"Resolving %s for %s...\n", host, af2String(af));
#ifdef HAVE_GETHOSTBYNAME2
- hp=(struct hostent*)gethostbyname2( host, af );
+ hp=gethostbyname2( host, af );
#else
- hp=(struct hostent*)gethostbyname( host );
+ hp=gethostbyname( host );
#endif
if( hp==NULL ) {
if(verb) mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Couldn't resolve name for %s: %s\n", af2String(af), host);
return TCP_ERROR_FATAL;
}
- memcpy( our_s_addr, (void*)hp->h_addr_list[0], hp->h_length );
+ memcpy( our_s_addr, hp->h_addr_list[0], hp->h_length );
}
#if HAVE_WINSOCK2_H
else {
unsigned long addr = inet_addr(host);
- memcpy( our_s_addr, (void*)&addr, sizeof(addr) );
+ memcpy( our_s_addr, &addr, sizeof(addr) );
}
#endif
diff --git a/stream/tv.c b/stream/tv.c
index 922fa5f008..e8346e1b15 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -111,6 +111,11 @@ void tv_start_scan(tvi_handle_t *tvh, int start)
tvh->tv_param->scan=start?1:0;
}
+static int tv_set_freq_float(tvi_handle_t *tvh, float freq)
+{
+ return tv_set_freq(tvh, freq/1000.0*16);
+}
+
static void tv_scan(tvi_handle_t *tvh)
{
unsigned int now;
@@ -134,7 +139,7 @@ static void tv_scan(tvi_handle_t *tvh)
scan=calloc(1,sizeof(tv_scan_t));
tvh->scan=scan;
cl = tvh->chanlist_s[scan->channel_num];
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ tv_set_freq_float(tvh, cl.freq);
scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
}
if(scan->scan_timer>now)
@@ -191,12 +196,12 @@ static void tv_scan(tvi_handle_t *tvh)
}
if (!tv_channel_current) tv_channel_current=tv_channel_list;
if (tv_channel_current)
- tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
+ tv_set_freq_float(tvh, tv_channel_current->freq);
free(tvh->scan);
tvh->scan=NULL;
}else{
cl = tvh->chanlist_s[scan->channel_num];
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ tv_set_freq_float(tvh, cl.freq);
mp_msg(MSGT_TV, MSGL_INFO, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
}
}
@@ -393,18 +398,17 @@ static int tv_set_norm_i(tvi_handle_t *tvh, int norm)
static void set_norm_and_freq(tvi_handle_t *tvh, tv_channels_t *chan)
{
- float freq = (float)chan->freq/1000;
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
- chan->number, chan->name, freq);
+ chan->number, chan->name, chan->freq/1000.0);
tv_set_norm_i(tvh, chan->norm);
- tv_set_freq(tvh, (unsigned long)(freq*16));
+ tv_set_freq_float(tvh, chan->freq);
}
static int open_tv(tvi_handle_t *tvh)
{
int i;
const tvi_functions_t *funcs = tvh->functions;
- int tv_fmt_list[] = {
+ static const int tv_fmt_list[] = {
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_UYVY,
@@ -519,10 +523,11 @@ static int open_tv(tvi_handle_t *tvh)
}
}
- if (tvh->chanlist == -1)
+ if (tvh->chanlist == -1) {
mp_tmsg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
tvh->tv_param->chanlist);
- else
+ return 0;
+ } else
mp_tmsg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n",
chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
@@ -583,7 +588,7 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
mp_tmsg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n",
- freq, (float)freq/16);
+ freq, freq/16.0);
}
if (tvh->tv_param->channel) {
@@ -600,8 +605,8 @@ static int open_tv(tvi_handle_t *tvh)
strcpy(tv_channel_last_real, cl.name);
tvh->channel = i;
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
- cl.name, (float)cl.freq/1000);
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ cl.name, cl.freq/1000.0);
+ tv_set_freq_float(tvh, cl.freq);
break;
}
}
@@ -900,7 +905,7 @@ int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
{
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
- *freq, (float)*freq/16);
+ *freq, *freq/16.0);
}
return 1;
}
@@ -916,7 +921,7 @@ int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
- freq, (float)freq/16);
+ freq, freq/16.0);
}
return 1;
}
@@ -958,9 +963,9 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[--tvh->channel];
- mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
- cl.name, (float)cl.freq/1000);
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ cl.name, cl.freq/1000.0);
+ tv_set_freq_float(tvh, cl.freq);
}
}
@@ -970,9 +975,9 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[++tvh->channel];
- mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
- cl.name, (float)cl.freq/1000);
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ cl.name, cl.freq/1000.0);
+ tv_set_freq_float(tvh, cl.freq);
}
}
return 1;
@@ -1016,9 +1021,9 @@ int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
if (!strcasecmp(cl.name, channel))
{
tvh->channel = i;
- mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
- cl.name, (float)cl.freq/1000);
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ cl.name, cl.freq/1000.0);
+ tv_set_freq_float(tvh, cl.freq);
break;
}
}
@@ -1063,9 +1068,9 @@ int tv_last_channel(tvi_handle_t *tvh) {
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
tvh->channel = i;
- mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
- cl.name, (float)cl.freq/1000);
- tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ cl.name, cl.freq/1000.0);
+ tv_set_freq_float(tvh, cl.freq);
break;
}
}
diff --git a/stream/udp.c b/stream/udp.c
index 53a581e332..c09a7f7e07 100644
--- a/stream/udp.c
+++ b/stream/udp.c
@@ -76,7 +76,7 @@ udp_open_socket (URL_t *url)
if (isalpha (url->hostname[0]))
{
#if !HAVE_WINSOCK2_H
- hp = (struct hostent *) gethostbyname (url->hostname);
+ hp = gethostbyname (url->hostname);
if (!hp)
{
mp_msg (MSGT_NETWORK, MSGL_ERR,
@@ -84,8 +84,8 @@ udp_open_socket (URL_t *url)
closesocket (socket_server_fd);
return -1;
}
- memcpy ((void *) &server_address.sin_addr.s_addr,
- (void *) hp->h_addr_list[0], hp->h_length);
+ memcpy (&server_address.sin_addr.s_addr,
+ hp->h_addr_list[0], hp->h_length);
#else
server_address.sin_addr.s_addr = htonl (INADDR_ANY);
#endif /* HAVE_WINSOCK2_H */
@@ -124,7 +124,7 @@ udp_open_socket (URL_t *url)
#if HAVE_WINSOCK2_H
if (isalpha (url->hostname[0]))
{
- hp = (struct hostent *) gethostbyname (url->hostname);
+ hp = gethostbyname (url->hostname);
if (!hp)
{
mp_msg (MSGT_NETWORK, MSGL_ERR,
@@ -132,13 +132,13 @@ udp_open_socket (URL_t *url)
closesocket (socket_server_fd);
return -1;
}
- memcpy ((void *) &server_address.sin_addr.s_addr,
- (void *) hp->h_addr, hp->h_length);
+ memcpy (&server_address.sin_addr.s_addr,
+ hp->h_addr, hp->h_length);
}
else
{
unsigned int addr = inet_addr (url->hostname);
- memcpy ((void *) &server_address.sin_addr, (void *) &addr, sizeof (addr));
+ memcpy (&server_address.sin_addr, &addr, sizeof (addr));
}
#endif /* HAVE_WINSOCK2_H */
diff --git a/sub/spudec.c b/sub/spudec.c
index 8f05724fab..22f121e92c 100644
--- a/sub/spudec.c
+++ b/sub/spudec.c
@@ -455,11 +455,6 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
current_nibble[0] / 2, current_nibble[1] / 2);
off+=4;
break;
- case 0xff:
- /* All done, bye-bye */
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Done!\n");
- return;
-// break;
default:
mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n",
type, next_off - off);
diff --git a/sub/subreader.c b/sub/subreader.c
index 99b2c6849c..adb12724c4 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -165,7 +165,7 @@ static subtitle *sub_read_line_sami(stream_t* st, subtitle *current,
s++;
if (*s == 'P' || *s == 'p') { s++; state = 2; continue; } /* found '<P' */
for (; *s != '>' && *s != '\0'; s++); /* skip remains of non-<P> TAG */
- if (s == '\0')
+ if (*s == '\0')
break;
s++;
continue;
@@ -276,7 +276,7 @@ static const char *sub_readtext(const char *source, char **dest) {
}
*dest= malloc (len+1);
- if (!dest) {return ERR;}
+ if (!*dest) {return ERR;}
strncpy(*dest, source, len);
(*dest)[len]=0;
diff --git a/sub/vobsub.c b/sub/vobsub.c
index 1643f249f0..5ae7e6cf1a 100644
--- a/sub/vobsub.c
+++ b/sub/vobsub.c
@@ -38,6 +38,7 @@
#include "core/mp_msg.h"
#include "core/path.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
extern int vobsub_id;
// Record the original -vobsubid set by commandline, since vobsub_id will be
@@ -660,8 +661,7 @@ int vobsub_parse_ifo(void* this, const char *const name, unsigned int *palette,
} else if (memcmp(block, ifo_magic, strlen(ifo_magic) + 1))
mp_msg(MSGT_VOBSUB, MSGL_ERR, "VobSub: Bad magic in IFO header\n");
else {
- unsigned long pgci_sector = block[0xcc] << 24 | block[0xcd] << 16
- | block[0xce] << 8 | block[0xcf];
+ unsigned pgci_sector = AV_RB32(block + 0xcc);
int standard = (block[0x200] & 0x30) >> 4;
int resolution = (block[0x201] & 0x0c) >> 2;
*height = standard ? 576 : 480;
@@ -693,12 +693,12 @@ int vobsub_parse_ifo(void* this, const char *const name, unsigned int *palette,
|| rar_read(block, sizeof(block), 1, fd) != 1)
mp_msg(MSGT_VOBSUB, MSGL_ERR, "VobSub: Can't read IFO PGCI\n");
else {
- unsigned long idx;
- unsigned long pgc_offset = block[0xc] << 24 | block[0xd] << 16
- | block[0xe] << 8 | block[0xf];
+ unsigned idx;
+ unsigned pgc_offset = AV_RB32(block + 0xc);
+ pgc_offset = FFMIN(pgc_offset, sizeof(block) - 0xa4 - 4*16);
for (idx = 0; idx < 16; ++idx) {
unsigned char *p = block + pgc_offset + 0xa4 + 4 * idx;
- palette[idx] = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+ palette[idx] = AV_RB32(p);
}
if (vob)
vob->have_palette = 1;