1 Fix build with ffmpeg 0.11.
2 https://bugs.gentoo.org/show_bug.cgi?id=407621
4 Index: sox-14.4.0/m4/ffmpeg.m4
5 ===================================================================
6 --- sox-14.4.0.orig/m4/ffmpeg.m4
7 +++ sox-14.4.0/m4/ffmpeg.m4
9 LIBS="$LIBS $FFMPEG_LIBS"
11 AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/avformat.h],
12 - [AC_CHECK_LIB(avformat, av_open_input_file,
13 + [AC_CHECK_LIB(avformat, avformat_open_input,
14 [AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h],
15 [AC_CHECK_LIB(avcodec, avcodec_decode_audio3, have_ffmpeg=yes)])])
17 Index: sox-14.4.0/src/ffmpeg.c
18 ===================================================================
19 --- sox-14.4.0.orig/src/ffmpeg.c
20 +++ sox-14.4.0/src/ffmpeg.c
21 @@ -92,8 +92,10 @@ static int stream_component_open(priv_t
22 enc->workaround_bugs = 1;
23 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
24 enc->error_resilience = 1;
26 +#elif LIBAVCODEC_VERSION_INT < ((54<<16)+(0<<8)+0)
27 enc->error_recognition = 1;
29 + ic->error_recognition = 1;
32 if (!codec || avcodec_open(enc, codec) < 0)
33 @@ -157,7 +159,7 @@ static int audio_decode_frame(priv_t * f
34 static int startread(sox_format_t * ft)
36 priv_t * ffmpeg = (priv_t *)ft->priv;
37 - AVFormatParameters params;
38 + AVDictionary *params;
42 @@ -172,7 +174,7 @@ static int startread(sox_format_t * ft)
44 /* Open file and get format */
45 memset(¶ms, 0, sizeof(params));
46 - if ((ret = av_open_input_file(&ffmpeg->ctxt, ft->filename, NULL, 0, ¶ms)) < 0) {
47 + if ((ret = avformat_open_input(&ffmpeg->ctxt, ft->filename, NULL, ¶ms)) < 0) {
48 lsx_fail("ffmpeg cannot open file for reading: %s (code %d)", ft->filename, ret);
51 @@ -231,7 +233,7 @@ static size_t read_samples(sox_format_t
52 /* If input buffer empty, read more data */
53 if (ffmpeg->audio_buf_index * 2 >= ffmpeg->audio_buf_size) {
54 if ((ret = av_read_frame(ffmpeg->ctxt, pkt)) < 0 &&
55 - (ret == AVERROR_EOF || url_ferror(ffmpeg->ctxt->pb)))
56 + (ret == AVERROR_EOF || ( ffmpeg->ctxt->pb && ffmpeg->ctxt->pb->error)))
58 ffmpeg->audio_buf_size = audio_decode_frame(ffmpeg, ffmpeg->audio_buf_aligned, AVCODEC_MAX_AUDIO_FRAME_SIZE);
59 ffmpeg->audio_buf_index = 0;
60 @@ -373,13 +375,6 @@ static int startwrite(sox_format_t * ft)
64 - /* set the output parameters (must be done even if no
66 - if (av_set_parameters(ffmpeg->ctxt, NULL) < 0) {
67 - lsx_fail("ffmpeg invalid output format parameters");
71 /* Next line for debugging */
72 /* dump_format(ffmpeg->ctxt, 0, ft->filename, 1); */
74 @@ -391,14 +386,14 @@ static int startwrite(sox_format_t * ft)
76 /* open the output file, if needed */
77 if (!(ffmpeg->fmt->flags & AVFMT_NOFILE)) {
78 - if (url_fopen(&ffmpeg->ctxt->pb, ft->filename, URL_WRONLY) < 0) {
79 + if (avio_open(&ffmpeg->ctxt->pb, ft->filename, AVIO_FLAG_WRITE) < 0) {
80 lsx_fail("ffmpeg could not open `%s'", ft->filename);
85 /* write the stream header, if any */
86 - av_write_header(ffmpeg->ctxt);
87 + avformat_write_header(ffmpeg->ctxt, NULL);
91 @@ -475,11 +470,7 @@ static int stopwrite(sox_format_t * ft)
93 if (!(ffmpeg->fmt->flags & AVFMT_NOFILE)) {
94 /* close the output file */
95 -#if (LIBAVFORMAT_VERSION_INT < 0x340000)
96 - url_fclose(&ffmpeg->ctxt->pb);
98 - url_fclose(ffmpeg->ctxt->pb);
100 + avio_close(ffmpeg->ctxt->pb);
103 /* Free the output context */