fixes bug that causes mp3 stream to hang is server is not fast enough
SVN-Revision: 8754
This commit is contained in:
parent
6ce13a764f
commit
9bf211bb90
1 changed files with 6 additions and 6 deletions
|
@ -173,15 +173,15 @@ int mp3_stream_setup(unsigned char *url, unsigned int type, unsigned char *ip,
|
||||||
ip);
|
ip);
|
||||||
printf("Sending request :\n%s\n", icy_request);
|
printf("Sending request :\n%s\n", icy_request);
|
||||||
send(mp3_stream.sockfd, icy_request, strlen(icy_request), 0);
|
send(mp3_stream.sockfd, icy_request, strlen(icy_request), 0);
|
||||||
//wait 200 ms ??!? some icecast servers seem to not push data to us fast enough ?!?!?
|
mp3_stream.numbytes = 0;
|
||||||
poll(0,0,200);
|
while(mp3_stream.numbytes < MAX_PACKET_SIZE-1) {
|
||||||
if ((mp3_stream.numbytes=recv(mp3_stream.sockfd, mp3_stream.buf, MAX_PACKET_SIZE-1, 0)) == -1) {
|
if ((mp3_stream.numbytes += recv(mp3_stream.sockfd, &mp3_stream.buf[mp3_stream.numbytes], MAX_PACKET_SIZE - 1 - mp3_stream.numbytes, 0)) == -1) {
|
||||||
perror("recv");
|
perror("recv");
|
||||||
return MP3_ERROR;
|
return MP3_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mp3_stream.buf[mp3_stream.numbytes] = '\0';
|
mp3_stream.buf[mp3_stream.numbytes] = '\0';
|
||||||
printf("numbytes = %d\n", mp3_stream.numbytes);
|
printf("numbytes = %d\n", mp3_stream.numbytes);
|
||||||
printf("------\n%s\n---------\n", mp3_stream.buf);
|
|
||||||
unsigned char *p = strstr(mp3_stream.buf, "\r\n\r\n");
|
unsigned char *p = strstr(mp3_stream.buf, "\r\n\r\n");
|
||||||
if(p) {
|
if(p) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
Loading…
Reference in a new issue