changeset 15076:1a02a23202c2

Stop streaming if we got a server error or message on pnm streaming. This is needed to stop playback for pnm streams where mplayer can't authenticate, and avoid an endless list of "input pnm: read error".
author rtognimp
date Sat, 09 Apr 2005 13:44:43 +0000
parents 737cc83784fb
children a893e0bfa9d6
files libmpdemux/pnm.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/pnm.c	Sat Apr 09 11:30:59 2005 +0000
+++ b/libmpdemux/pnm.c	Sat Apr 09 13:44:43 2005 +0000
@@ -301,7 +301,7 @@
  * and returns number of bytes read 
  */
 
-static unsigned int pnm_get_chunk(pnm_t *p, 
+static int pnm_get_chunk(pnm_t *p, 
                          unsigned int max,
                          unsigned int *chunk_type,
                          char *data, int *need_response) {
@@ -688,12 +688,12 @@
     rm_read (p->s, &p->buffer[8], size-5);
     p->buffer[size+3]=0;
     printf("input_pnm: got message from server while reading stream:\n%s\n", &p->buffer[3]);
-    return 0;
+    return -1;
   }
   if (p->buffer[0] == 'F')
   {
     printf("input_pnm: server error.\n");
-    return 0;
+    return -1;
   }
 
   /* skip bytewise to next chunk.
@@ -808,6 +808,7 @@
   char *dest=data;
   char *source=this->recv + this->recv_read;
   int fill=this->recv_size - this->recv_read;
+  int retval;
   
   if (len < 0) return 0;
   while (to_copy > fill) {
@@ -817,10 +818,13 @@
     dest += fill;
     this->recv_read=0;
 
-    if (!pnm_get_stream_chunk (this)) {
+    if ((retval = pnm_get_stream_chunk (this)) <= 0) {
 #ifdef LOG
       printf ("input_pnm: %d of %d bytes provided\n", len-to_copy, len);
 #endif
+      if (retval < 0)
+        return retval;
+      else
       return len-to_copy;
     }
     source = this->recv;