mirror of
https://github.com/mpv-player/mpv
synced 2025-02-21 23:36:58 +00:00
GCC warning fixes
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7954 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
d60a88e4fa
commit
4dc9465cb8
@ -133,8 +133,8 @@ static void get_answer (int s)
|
||||
|
||||
static int get_data (int s, char *buf, size_t count)
|
||||
{
|
||||
ssize_t len, total;
|
||||
total = 0;
|
||||
ssize_t len;
|
||||
size_t total = 0;
|
||||
|
||||
while (total < count) {
|
||||
|
||||
@ -161,7 +161,7 @@ static int get_data (int s, char *buf, size_t count)
|
||||
static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
|
||||
{
|
||||
unsigned char pre_header[8];
|
||||
int header_len,i ;
|
||||
int header_len;
|
||||
|
||||
header_len = 0;
|
||||
|
||||
@ -200,16 +200,16 @@ static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
|
||||
|
||||
} else {
|
||||
|
||||
int packet_len;
|
||||
int32_t packet_len;
|
||||
int command;
|
||||
char data[BUF_SIZE];
|
||||
|
||||
if (!get_data (s, &packet_len, 4)) {
|
||||
if (!get_data (s, (char*)&packet_len, 4)) {
|
||||
printf ("packet_len read failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
packet_len = get_32 (&packet_len, 0) + 4;
|
||||
packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4;
|
||||
|
||||
// printf ("command packet detected, len=%d\n", packet_len);
|
||||
|
||||
@ -304,7 +304,6 @@ static int interp_header (uint8_t *header, int header_len)
|
||||
|
||||
static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl) {
|
||||
unsigned char pre_header[8];
|
||||
int i;
|
||||
char data[BUF_SIZE];
|
||||
|
||||
if (!get_data (s, pre_header, 8)) {
|
||||
@ -333,14 +332,15 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
|
||||
|
||||
} else {
|
||||
|
||||
int packet_len, command;
|
||||
int32_t packet_len;
|
||||
int command;
|
||||
|
||||
if (!get_data (s, &packet_len, 4)) {
|
||||
if (!get_data (s, (char*)&packet_len, 4)) {
|
||||
printf ("packet_len read failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
packet_len = get_32 (&packet_len, 0) + 4;
|
||||
packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4;
|
||||
|
||||
if (!get_data (s, data, packet_len)) {
|
||||
printf ("command data read failed\n");
|
||||
@ -415,6 +415,10 @@ int
|
||||
asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl )
|
||||
{
|
||||
return -1;
|
||||
// Shut up gcc warning
|
||||
fd++;
|
||||
pos++;
|
||||
streaming_ctrl=NULL;
|
||||
}
|
||||
|
||||
int asf_mmst_streaming_start(stream_t *stream)
|
||||
@ -426,7 +430,7 @@ int asf_mmst_streaming_start(stream_t *stream)
|
||||
int len, i, packet_length;
|
||||
char *path;
|
||||
URL_t *url1 = stream->streaming_ctrl->url;
|
||||
int s;
|
||||
int s = stream->fd;
|
||||
|
||||
if( s>0 ) {
|
||||
close( stream->fd );
|
||||
|
@ -23,6 +23,11 @@
|
||||
|
||||
extern int verbose;
|
||||
|
||||
|
||||
int asf_http_streaming_start( stream_t *stream );
|
||||
int asf_mmst_streaming_start( stream_t *stream );
|
||||
|
||||
|
||||
// ASF streaming support several network protocol.
|
||||
// One use UDP, not known, yet!
|
||||
// Another is HTTP, this one is known.
|
||||
@ -143,7 +148,7 @@ asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) {
|
||||
// is big, the ASF header will be split in 2 network chunk.
|
||||
// So we need to retrieve all the chunk before starting to parse the header.
|
||||
do {
|
||||
for( r=0; r < sizeof(ASF_stream_chunck_t) ; ) {
|
||||
for( r=0; r < (int)sizeof(ASF_stream_chunck_t) ; ) {
|
||||
i = nop_streaming_read(fd,((char*)&chunk)+r,sizeof(ASF_stream_chunck_t) - r,streaming_ctrl);
|
||||
if(i <= 0) return -1;
|
||||
r += i;
|
||||
@ -270,7 +275,7 @@ printf("Max bandwidth set to %d\n", streaming_ctrl->bandwidth);
|
||||
if( streaming_ctrl->bandwidth!=0 ) {
|
||||
int stream_count, stream_id, max_bitrate;
|
||||
char *ptr = buffer+pos;
|
||||
int total_bitrate=0, p_id, p_br;
|
||||
unsigned int total_bitrate=0, p_id=0, p_br=0;
|
||||
int i;
|
||||
ptr += sizeof(objh);
|
||||
stream_count = le2me_16(*(uint16_t*)ptr);
|
||||
@ -387,6 +392,10 @@ asf_http_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *strea
|
||||
int
|
||||
asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) {
|
||||
return -1;
|
||||
// to shut up gcc warning
|
||||
fd++;
|
||||
pos++;
|
||||
streaming_ctrl=NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@ -550,10 +559,10 @@ asf_http_request(streaming_ctrl_t *streaming_ctrl) {
|
||||
}
|
||||
|
||||
int
|
||||
asf_http_parse_response( HTTP_header_t *http_hdr ) {
|
||||
asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTTP_header_t *http_hdr ) {
|
||||
char *content_type, *pragma;
|
||||
char features[64] = "\0";
|
||||
int len;
|
||||
size_t len;
|
||||
if( http_response_parse(http_hdr)<0 ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to parse HTTP response\n");
|
||||
return -1;
|
||||
@ -583,7 +592,7 @@ asf_http_parse_response( HTTP_header_t *http_hdr ) {
|
||||
pragma += 9;
|
||||
end = strstr( pragma, "," );
|
||||
if( end==NULL ) {
|
||||
int s = strlen(pragma);
|
||||
size_t s = strlen(pragma);
|
||||
if(s > sizeof(features)) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_WARN,"ASF HTTP PARSE WARNING : Pragma %s cuted from %d bytes to %d\n",pragma,s,sizeof(features));
|
||||
len = sizeof(features);
|
||||
@ -591,7 +600,7 @@ asf_http_parse_response( HTTP_header_t *http_hdr ) {
|
||||
len = s;
|
||||
}
|
||||
} else {
|
||||
len = MIN(end-pragma,sizeof(features));
|
||||
len = MIN((unsigned int)(end-pragma),sizeof(features));
|
||||
}
|
||||
strncpy( features, pragma, len );
|
||||
features[len]='\0';
|
||||
@ -605,8 +614,8 @@ asf_http_parse_response( HTTP_header_t *http_hdr ) {
|
||||
} while( comma_ptr!=NULL );
|
||||
pragma = http_get_next_field( http_hdr );
|
||||
}
|
||||
|
||||
return asf_http_streaming_type( content_type, features, http_hdr );
|
||||
asf_http_ctrl->streaming_type = asf_http_streaming_type( content_type, features, http_hdr );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@ -614,7 +623,6 @@ asf_http_streaming_start( stream_t *stream ) {
|
||||
HTTP_header_t *http_hdr=NULL;
|
||||
URL_t *url = stream->streaming_ctrl->url;
|
||||
asf_http_streaming_ctrl_t *asf_http_ctrl;
|
||||
ASF_StreamType_e streaming_type;
|
||||
char buffer[BUFFER_SIZE];
|
||||
int i, ret;
|
||||
int fd = stream->fd;
|
||||
@ -646,7 +654,7 @@ asf_http_streaming_start( stream_t *stream ) {
|
||||
|
||||
http_hdr = asf_http_request( stream->streaming_ctrl );
|
||||
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request [%s]\n", http_hdr->buffer );
|
||||
for(i=0; i < http_hdr->buffer_size ; ) {
|
||||
for(i=0; i < (int)http_hdr->buffer_size ; ) {
|
||||
int r = write( fd, http_hdr->buffer+i, http_hdr->buffer_size-i );
|
||||
if(r <0) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Socket write error : %s\n",strerror(errno));
|
||||
@ -670,14 +678,13 @@ asf_http_streaming_start( stream_t *stream ) {
|
||||
http_hdr->buffer[http_hdr->buffer_size]='\0';
|
||||
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Response [%s]\n", http_hdr->buffer );
|
||||
}
|
||||
streaming_type = asf_http_parse_response(http_hdr);
|
||||
if( streaming_type<0 ) {
|
||||
ret = asf_http_parse_response(asf_http_ctrl, http_hdr);
|
||||
if( ret<0 ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to parse header\n");
|
||||
http_free( http_hdr );
|
||||
return -1;
|
||||
}
|
||||
asf_http_ctrl->streaming_type = streaming_type;
|
||||
switch( streaming_type ) {
|
||||
switch( asf_http_ctrl->streaming_type ) {
|
||||
case ASF_Live_e:
|
||||
case ASF_Prerecorded_e:
|
||||
case ASF_PlainText_e:
|
||||
@ -688,7 +695,7 @@ asf_http_streaming_start( stream_t *stream ) {
|
||||
}
|
||||
}
|
||||
if( asf_http_ctrl->request==1 ) {
|
||||
if( streaming_type!=ASF_PlainText_e ) {
|
||||
if( asf_http_ctrl->streaming_type!=ASF_PlainText_e ) {
|
||||
// First request, we only got the ASF header.
|
||||
ret = asf_streaming_parse_header(fd,stream->streaming_ctrl);
|
||||
if(ret < 0) return -1;
|
||||
@ -729,7 +736,7 @@ asf_http_streaming_start( stream_t *stream ) {
|
||||
} while(!done);
|
||||
|
||||
stream->fd = fd;
|
||||
if( streaming_type==ASF_PlainText_e || streaming_type==ASF_Redirector_e ) {
|
||||
if( asf_http_ctrl->streaming_type==ASF_PlainText_e || asf_http_ctrl->streaming_type==ASF_Redirector_e ) {
|
||||
stream->streaming_ctrl->streaming_read = nop_streaming_read;
|
||||
stream->streaming_ctrl->streaming_seek = nop_streaming_seek;
|
||||
} else {
|
||||
|
@ -61,5 +61,6 @@ void cd_info_free(cd_info_t *cd_info);
|
||||
cd_track_t* cd_info_add_track(cd_info_t *cd_info, char *track_name, unsigned int track_nb, unsigned int min, unsigned int sec, unsigned int msec, unsigned long frame_begin, unsigned long frame_length);
|
||||
cd_track_t* cd_info_get_track(cd_info_t *cd_info, unsigned int track_nb);
|
||||
|
||||
void cd_info_debug(cd_info_t *cd_info);
|
||||
|
||||
#endif // __CDD_H__
|
||||
|
@ -371,7 +371,7 @@ cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
|
||||
}
|
||||
// Ok found the end
|
||||
// do a sanity check
|
||||
if( http_hdr->body_size<(ptr2-ptr) ) {
|
||||
if( http_hdr->body_size<(unsigned int)(ptr2-ptr) ) {
|
||||
printf("Unexpected fix me\n");
|
||||
return -1;
|
||||
}
|
||||
@ -746,7 +746,7 @@ cddb_parse_xmcd(char *xmcd_file) {
|
||||
// Search for the genre
|
||||
else if( xmcd_parse_dgenre(cd_info, ptr) );
|
||||
// Search for a track title
|
||||
else if( xmcd_parse_ttitle(cd_info, ptr) );
|
||||
else if( xmcd_parse_ttitle(cd_info, ptr) ) audiolen++; // <-- audiolen++ to shut up gcc warning
|
||||
}
|
||||
if( ptr2[1]=='\n' ) ptr2++;
|
||||
pos = (ptr2+1)-ptr;
|
||||
|
@ -16,21 +16,21 @@ typedef struct {
|
||||
char *protocol;
|
||||
char *method;
|
||||
char *uri;
|
||||
int status_code;
|
||||
unsigned int status_code;
|
||||
char *reason_phrase;
|
||||
int http_minor_version;
|
||||
unsigned int http_minor_version;
|
||||
// Field variables
|
||||
HTTP_field_t *first_field;
|
||||
HTTP_field_t *last_field;
|
||||
int field_nb;
|
||||
unsigned int field_nb;
|
||||
char *field_search;
|
||||
HTTP_field_t *field_search_pos;
|
||||
// Body variables
|
||||
char *body;
|
||||
int body_size;
|
||||
size_t body_size;
|
||||
char *buffer;
|
||||
int buffer_size;
|
||||
int is_parsed;
|
||||
size_t buffer_size;
|
||||
unsigned int is_parsed;
|
||||
} HTTP_header_t;
|
||||
|
||||
HTTP_header_t* http_new_header();
|
||||
|
@ -35,6 +35,9 @@ extern int stream_cache_size;
|
||||
|
||||
extern int mp_input_check_interrupt(int time);
|
||||
|
||||
int asf_streaming_start( stream_t *stream );
|
||||
int rtsp_streaming_start( stream_t *stream );
|
||||
|
||||
/* Variables for the command line option -user, -passwd & -bandwidth */
|
||||
char *network_username=NULL;
|
||||
char *network_password=NULL;
|
||||
@ -150,7 +153,7 @@ connect2Server(char *host, int port) {
|
||||
fd_set set;
|
||||
struct timeval tv;
|
||||
struct sockaddr_in server_address;
|
||||
struct hostent *hp;
|
||||
struct hostent *hp=NULL;
|
||||
|
||||
socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if( socket_server_fd==-1 ) {
|
||||
@ -173,7 +176,7 @@ connect2Server(char *host, int port) {
|
||||
server_address.sin_port=htons(port);
|
||||
|
||||
// Turn the socket as non blocking so we can timeout on the connection
|
||||
if( isalpha(host[0]) ) {
|
||||
if( isalpha(host[0]) && hp!=NULL ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_STATUS,"Connecting to server %s[%d.%d.%d.%d]:%d ...\n", host, (hp->h_addr_list[0][0])&0xff, (hp->h_addr_list[0][1])&0xff, (hp->h_addr_list[0][2])&0xff, (hp->h_addr_list[0][3])&0xff, port );
|
||||
} else {
|
||||
mp_msg(MSGT_NETWORK,MSGL_STATUS,"Connecting to server %s:%d ...\n", host, port );
|
||||
@ -312,7 +315,7 @@ http_send_request( URL_t *url ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request: [%s]\n", http_hdr->buffer );
|
||||
|
||||
ret = write( fd, http_hdr->buffer, http_hdr->buffer_size );
|
||||
if( ret!=http_hdr->buffer_size ) {
|
||||
if( ret!=(int)http_hdr->buffer_size ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: didn't sent all the request\n");
|
||||
return -1;
|
||||
}
|
||||
@ -354,7 +357,7 @@ http_read_response( int fd ) {
|
||||
int
|
||||
http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
|
||||
char *aut;
|
||||
int ret;
|
||||
|
||||
if( *auth_retry==1 ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Authentication failed\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");
|
||||
@ -643,6 +646,10 @@ nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctr
|
||||
int
|
||||
nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
|
||||
return -1;
|
||||
// To shut up gcc warning
|
||||
fd++;
|
||||
pos++;
|
||||
stream_ctrl=NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@ -805,7 +812,7 @@ rtp_streaming_start( stream_t *stream ) {
|
||||
|
||||
int
|
||||
streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) {
|
||||
int ret, val;
|
||||
int ret;
|
||||
if( stream==NULL ) return -1;
|
||||
|
||||
stream->streaming_ctrl = streaming_ctrl_new();
|
||||
@ -884,7 +891,6 @@ 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 = stream_cache_size;
|
||||
if(stream_cache_size<0) {
|
||||
// cache option not set, will use our computed value.
|
||||
// buffer in KBytes, *5 because the prefill is 20% of the buffer.
|
||||
|
@ -52,6 +52,8 @@ int connect2Server(char *host, int port);
|
||||
int http_send_request(URL_t *url);
|
||||
HTTP_header_t *http_read_response(int fd);
|
||||
|
||||
int http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry);
|
||||
|
||||
/*
|
||||
* Joey Parrish <joey@yunamusic.com>:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user