aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2007-09-11 17:34:52 +0000
committerJohn Crispin <blogic@openwrt.org>2007-09-11 17:34:52 +0000
commit3dccb1de2d8fb41cf6753e7c4d6aaa5fecdb15f6 (patch)
tree7a2bd719cf05a5b1aa154614b986a47598011900
parentcd45260e94abb81668b785027ecf5489ccd137f2 (diff)
downloadupstream-3dccb1de2d8fb41cf6753e7c4d6aaa5fecdb15f6.tar.gz
upstream-3dccb1de2d8fb41cf6753e7c4d6aaa5fecdb15f6.tar.bz2
upstream-3dccb1de2d8fb41cf6753e7c4d6aaa5fecdb15f6.zip
fixes bug that causes mp3 stream to hang is server is not fast enough
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8754 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--package/fonera-mp3/src/lib/mp3_stream.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/package/fonera-mp3/src/lib/mp3_stream.c b/package/fonera-mp3/src/lib/mp3_stream.c
index 0dd3437e3b..f6f214a990 100644
--- a/package/fonera-mp3/src/lib/mp3_stream.c
+++ b/package/fonera-mp3/src/lib/mp3_stream.c
@@ -173,15 +173,15 @@ int mp3_stream_setup(unsigned char *url, unsigned int type, unsigned char *ip,
ip);
printf("Sending request :\n%s\n", icy_request);
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 ?!?!?
- poll(0,0,200);
- if ((mp3_stream.numbytes=recv(mp3_stream.sockfd, mp3_stream.buf, MAX_PACKET_SIZE-1, 0)) == -1) {
- perror("recv");
- return MP3_ERROR;
+ mp3_stream.numbytes = 0;
+ while(mp3_stream.numbytes < MAX_PACKET_SIZE-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");
+ return MP3_ERROR;
+ }
}
mp3_stream.buf[mp3_stream.numbytes] = '\0';
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");
if(p) {
*p = '\0';