@@ -194,7 +194,7 @@ static int decode_audio(struct audio_buffer *audio_buf, s16 **data, int *size)
194
194
AVIOContext *avio_ctx;
195
195
AVStream *stream;
196
196
AVCodecContext *codec;
197
- AVPacket packet;
197
+ AVPacket * packet;
198
198
AVFrame *frame;
199
199
struct SwrContext *swr;
200
200
u8 *avio_ctx_buffer;
@@ -279,7 +279,11 @@ static int decode_audio(struct audio_buffer *audio_buf, s16 **data, int *size)
279
279
return -1 ;
280
280
}
281
281
282
- av_init_packet (&packet);
282
+ packet=av_packet_alloc ();
283
+ if (!packet) {
284
+ LOG (" Error allocating the packet\n " );
285
+ return -1 ;
286
+ }
283
287
frame = av_frame_alloc ();
284
288
if (!frame) {
285
289
LOG (" Error allocating the frame\n " );
@@ -289,8 +293,8 @@ static int decode_audio(struct audio_buffer *audio_buf, s16 **data, int *size)
289
293
/* iterate through frames */
290
294
*data = NULL ;
291
295
*size = 0 ;
292
- while (av_read_frame (fmt_ctx, & packet) >= 0 ) {
293
- avcodec_send_packet (codec, & packet);
296
+ while (av_read_frame (fmt_ctx, packet) >= 0 ) {
297
+ avcodec_send_packet (codec, packet);
294
298
295
299
err = avcodec_receive_frame (codec, frame);
296
300
if (err == AVERROR (EAGAIN))
@@ -301,10 +305,11 @@ static int decode_audio(struct audio_buffer *audio_buf, s16 **data, int *size)
301
305
/* Flush any remaining conversion buffers... */
302
306
convert_frame (swr, codec, frame, data, size, true );
303
307
308
+ av_packet_free (&packet);
304
309
av_frame_free (&frame);
305
310
swr_free (&swr);
306
311
// avio_context_free(); // todo?
307
- avcodec_close ( codec);
312
+ avcodec_free_context (& codec);
308
313
avformat_close_input (&fmt_ctx);
309
314
avformat_free_context (fmt_ctx);
310
315
0 commit comments