write error handling
[ffmpeg.git] / libavformat / utils.c
index 7129b39..788f4ab 100644 (file)
@@ -1996,11 +1996,16 @@ static void truncate_ts(AVStream *st, AVPacket *pkt){
  */
 int av_write_frame(AVFormatContext *s, AVPacket *pkt)
 {
+    int ret;
+
     compute_pkt_fields2(s->streams[pkt->stream_index], pkt);
     
     truncate_ts(s->streams[pkt->stream_index], pkt);
 
-    return s->oformat->write_packet(s, pkt);
+    ret= s->oformat->write_packet(s, pkt);
+    if(!ret)
+        ret= url_ferror(&s->pb);
+    return ret;
 }
 
 /**
@@ -2111,6 +2116,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
         
         if(ret<0)
             return ret;
+        if(url_ferror(&s->pb))
+            return url_ferror(&s->pb);
     }
 }
 
@@ -2139,10 +2146,14 @@ int av_write_trailer(AVFormatContext *s)
         
         if(ret<0)
             goto fail;
+        if(url_ferror(&s->pb))
+            goto fail;
     }
 
     ret = s->oformat->write_trailer(s);
 fail:
+    if(ret == 0)
+       ret=url_ferror(&s->pb);
     for(i=0;i<s->nb_streams;i++)
         av_freep(&s->streams[i]->priv_data);
     av_freep(&s->priv_data);