diff rdt.c @ 4036:1349c277efbd libavformat

Add ByteIOContext argument to public ff_rm_* functions so that we can specify the data source as function argument instead of in s->pb before calling the function. Discussed in ML thread "[PATCH] fix small memleak in rdt.c".
author rbultje
date Mon, 17 Nov 2008 14:20:00 +0000
parents 7c85b7921e61
children 5f65cbe25494
line wrap: on
line diff
--- a/rdt.c	Mon Nov 17 07:50:25 2008 +0000
+++ b/rdt.c	Mon Nov 17 14:20:00 2008 +0000
@@ -159,8 +159,7 @@
         size = rdt->mlti_data_size;
         url_fseek(pb, 0, SEEK_SET);
     }
-    rdt->rmctx->pb = pb;
-    if (ff_rm_read_mdpr_codecdata(rdt->rmctx, st, size) < 0)
+    if (ff_rm_read_mdpr_codecdata(rdt->rmctx, pb, st, size) < 0)
         return -1;
 
     url_close_buf(pb);
@@ -259,7 +258,7 @@
                   const uint8_t *buf, int len, int flags)
 {
     int seq = 1, res;
-    ByteIOContext *pb = rdt->rmctx->pb;
+    ByteIOContext *pb;
     RMContext *rm = rdt->rmctx->priv_data;
 
     if (rm->audio_pkt_cnt == 0) {
@@ -267,8 +266,7 @@
 
         url_open_buf (&pb, buf, len, URL_RDONLY);
         flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
-        rdt->rmctx->pb = pb;
-        res = ff_rm_parse_packet (rdt->rmctx, st, len, pkt,
+        res = ff_rm_parse_packet (rdt->rmctx, pb, st, len, pkt,
                                   &seq, &flags, timestamp);
         pos = url_ftell(pb);
         url_close_buf (pb);
@@ -277,14 +275,13 @@
         if (rm->audio_pkt_cnt > 0 &&
             st->codec->codec_id == CODEC_ID_AAC) {
             memcpy (rdt->buffer, buf + pos, len - pos);
-            url_open_buf (&pb, rdt->buffer, len - pos, URL_RDONLY);
-            rdt->rmctx->pb = pb;
+            url_open_buf (&rdt->rmctx->pb, rdt->buffer, len - pos, URL_RDONLY);
         }
     } else {
-        ff_rm_retrieve_cache (rdt->rmctx, st, pkt);
+        ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
         if (rm->audio_pkt_cnt == 0 &&
             st->codec->codec_id == CODEC_ID_AAC)
-            url_close_buf (pb);
+            url_close_buf (rdt->rmctx->pb);
     }
     pkt->stream_index = st->index;
     pkt->pts = *timestamp;