diff rdt.c @ 4096:233ba738a68e libavformat

Don't access RMContext directly in rdt.c. Rather, use the return value of ff_rm_parse_packet() to indicate whether more audio packets are available in the demuxer from the last RM frame, and save that in the RDT parsing context. See patch/discussion in "[PATCH] rdt.c: don't access RMContext" on ML.
author rbultje
date Sat, 13 Dec 2008 21:37:27 +0000
parents 8adccfc01be3
children 90a12fced519
line wrap: on
line diff
--- a/rdt.c	Sat Dec 13 17:18:11 2008 +0000
+++ b/rdt.c	Sat Dec 13 21:37:27 2008 +0000
@@ -84,6 +84,7 @@
     uint8_t *mlti_data;
     unsigned int mlti_data_size;
     char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
+    int audio_pkt_cnt[MAX_STREAMS]; /**< remaining audio packets in rmdec */
 };
 
 void
@@ -294,9 +295,8 @@
 {
     int seq = 1, res;
     ByteIOContext pb;
-    RMContext *rm = rdt->rmctx->priv_data;
 
-    if (rm->audio_pkt_cnt == 0) {
+    if (rdt->audio_pkt_cnt == 0) {
         int pos;
 
         init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
@@ -306,7 +306,8 @@
         pos = url_ftell(&pb);
         if (res < 0)
             return res;
-        if (rm->audio_pkt_cnt > 0 &&
+        rdt->audio_pkt_cnt[st->id] = res;
+        if (rdt->audio_pkt_cnt[st->id] > 0 &&
             st->codec->codec_id == CODEC_ID_AAC) {
             memcpy (rdt->buffer, buf + pos, len - pos);
             rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
@@ -314,14 +315,14 @@
         }
     } else {
         ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
-        if (rm->audio_pkt_cnt == 0 &&
+        if (rdt->audio_pkt_cnt[st->id] == 0 &&
             st->codec->codec_id == CODEC_ID_AAC)
             av_freep(&rdt->rmctx->pb);
     }
     pkt->stream_index = st->index;
     pkt->pts = *timestamp;
 
-    return rm->audio_pkt_cnt > 0;
+    return rdt->audio_pkt_cnt[st->id] > 0;
 }
 
 int