aboutsummaryrefslogtreecommitdiffstats
path: root/avconv.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-03-21 16:36:23 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-03-23 01:19:42 -0400
commitf3ab3e1aeec318763065303a1569796131d3a561 (patch)
tree031c3a49da798e90375fc9934352b742f994b73c /avconv.c
parent5023b89bba198b2f8e43b7f555aeb9c30d33db9f (diff)
downloadffmpeg-f3ab3e1aeec318763065303a1569796131d3a561.tar.gz
avconv: make the async buffer global and free it in exit_program()
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/avconv.c b/avconv.c
index 9a3c75d59e..f1da50fbae 100644
--- a/avconv.c
+++ b/avconv.c
@@ -142,6 +142,8 @@ static int print_stats = 1;
static uint8_t *audio_buf;
static unsigned int allocated_audio_buf_size;
+static uint8_t *async_buf;
+static unsigned int allocated_async_buf_size;
#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
@@ -718,6 +720,8 @@ void exit_program(int ret)
uninit_opts();
av_free(audio_buf);
allocated_audio_buf_size = 0;
+ av_free(async_buf);
+ allocated_async_buf_size = 0;
#if CONFIG_AVFILTER
avfilter_uninit();
@@ -1117,8 +1121,12 @@ need_realloc:
return;
ist->is_start = 0;
} else {
- static uint8_t *input_tmp = NULL;
- input_tmp = av_realloc(input_tmp, byte_delta + size);
+ av_fast_malloc(&async_buf, &allocated_async_buf_size,
+ byte_delta + size);
+ if (!async_buf) {
+ av_log(NULL, AV_LOG_FATAL, "Out of memory in do_audio_out\n");
+ exit_program(1);
+ }
if (byte_delta > allocated_for_size - size) {
allocated_for_size = byte_delta + (int64_t)size;
@@ -1126,9 +1134,9 @@ need_realloc:
}
ist->is_start = 0;
- generate_silence(input_tmp, dec->sample_fmt, byte_delta);
- memcpy(input_tmp + byte_delta, buf, size);
- buf = input_tmp;
+ generate_silence(async_buf, dec->sample_fmt, byte_delta);
+ memcpy(async_buf + byte_delta, buf, size);
+ buf = async_buf;
size += byte_delta;
av_log(NULL, AV_LOG_VERBOSE, "adding %d audio samples of silence\n", idelta);
}