diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-05-11 20:37:04 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-05-11 20:37:04 +0200 |
commit | 748da53ac00b40a722bdfdf9a89beaa01c689762 (patch) | |
tree | 40f6fffc8302e22375b56b39cc53d982f4e2239f /plugins/converter | |
parent | 1428dcfd195e1547822512690a41df5f09ebc8bd (diff) |
converter: use heap for buffer allocation instead of stack
Diffstat (limited to 'plugins/converter')
-rw-r--r-- | plugins/converter/converter.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/converter/converter.c b/plugins/converter/converter.c index 04faaae3..41e896dd 100644 --- a/plugins/converter/converter.c +++ b/plugins/converter/converter.c @@ -802,6 +802,8 @@ check_dir (const char *dir, mode_t mode) int convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float, ddb_encoder_preset_t *encoder_preset, ddb_dsp_preset_t *dsp_preset, int *abort) { + char *buffer = NULL; + char *dspbuffer = NULL; if (deadbeef->pl_get_item_duration (it) <= 0) { deadbeef->pl_lock (); fprintf (stderr, "converter: stream %s doesn't have finite length, skipped\n", deadbeef->pl_find_meta (it, ":URI")); @@ -945,9 +947,9 @@ convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float int bs = 2000 * samplesize; // expected buffer size after worst-case dsp int dspsize = bs/samplesize*sizeof(float)*8*48; - char buffer[dspsize]; + char *buffer = malloc (dspsize); // account for up to float32 7.1 resampled to 48x ratio - char dspbuffer[dspsize]; + char *dspbuffer = malloc (dspsize); int eof = 0; for (;;) { if (eof) { @@ -973,7 +975,7 @@ convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float ddb_dsp_context_t *dsp = dsp_preset->chain; int frames = sz / samplesize; while (dsp) { - frames = dsp->plugin->process (dsp, (float *)dspbuffer, frames, sizeof (dspbuffer) / (fmt.channels * 4), &fmt, NULL); + frames = dsp->plugin->process (dsp, (float *)dspbuffer, frames, dspsize / (fmt.channels * 4), &fmt, NULL); if (frames <= 0) { break; } @@ -1073,6 +1075,14 @@ convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float } err = 0; error: + if (buffer) { + free (buffer); + buffer = NULL; + } + if (dspbuffer) { + free (dspbuffer); + dspbuffer = NULL; + } if (temp_file != -1 && (!enc_pipe || temp_file != fileno (enc_pipe))) { close (temp_file); temp_file = -1; |