summaryrefslogtreecommitdiff
path: root/libavformat/libmodplug.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2011-10-05 21:20:28 +0200
committerClément Bœsch <ubitux@gmail.com>2011-10-05 21:25:03 +0200
commit9a2ceee2e3aba4902ed1fcecfdfdd0b1921778fc (patch)
tree773faceaa27b890451102b0f368ad6b55120eb5e /libavformat/libmodplug.c
parent54208857378cc772b1a2a99dec9116d7254d7bae (diff)
libmodplug: simplify and fix read_packet() callback.
In case of av_new_packet() error, a correct return error code is raised, the data memcpy is avoided, and pkt dts/pts are not assigned anymore (since the defaults are good).
Diffstat (limited to 'libavformat/libmodplug.c')
-rw-r--r--libavformat/libmodplug.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c
index 212e225b00..b4978b9c2d 100644
--- a/libavformat/libmodplug.c
+++ b/libavformat/libmodplug.c
@@ -66,20 +66,16 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- int ret, n;
ModPlugContext *modplug = s->priv_data;
- uint8_t buf[512];
- n = ModPlug_Read(modplug->f, buf, sizeof(buf));
- if (n <= 0)
- return AVERROR(EIO);
+ if (av_new_packet(pkt, 512) < 0)
+ return AVERROR(ENOMEM);
- ret = av_new_packet(pkt, n);
- if (ret)
- return ret;
- pkt->pts = pkt->dts = AV_NOPTS_VALUE;
- pkt->size = n;
- memcpy(pkt->data, buf, n);
+ pkt->size = ModPlug_Read(modplug->f, pkt->data, 512);
+ if (pkt->size <= 0) {
+ av_free_packet(pkt);
+ return AVERROR(EIO);
+ }
return 0;
}