diff options
author | wm4 <wm4@nowhere> | 2013-03-21 00:58:05 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-13 04:21:27 +0200 |
commit | fc24ab9298ff155ad94171c1b8f16f4da422376c (patch) | |
tree | d7abfad1c1c08fc972dd643959294aa2294c2c0c /audio/filter/af.c | |
parent | 8bf759e888249e57ea8e786a368e0068a24838dc (diff) | |
download | mpv-fc24ab9298ff155ad94171c1b8f16f4da422376c.tar.bz2 mpv-fc24ab9298ff155ad94171c1b8f16f4da422376c.tar.xz |
audio/filter: replace pointless memcpys with assignments
The change in af_scaletempo actually fixes a memory leak. af->data
contained a pointer to an allocated buffer, which was overwritten
during format negotiation. Set the format explicitly instead.
Diffstat (limited to 'audio/filter/af.c')
-rw-r--r-- | audio/filter/af.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c index e240c83a40..9b00bf0fa5 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -288,7 +288,6 @@ static void af_print_filter_chain(struct af_stream *s) int af_reinit(struct af_stream *s, struct af_instance *af) { do { - struct mp_audio in; // Format of the input to current filter int rv = 0; // Return value // Check if there are any filters left in the list @@ -300,10 +299,7 @@ int af_reinit(struct af_stream *s, struct af_instance *af) } // Check if this is the first filter - if (!af->prev) - memcpy(&in, &(s->input), sizeof(struct mp_audio)); - else - memcpy(&in, af->prev->data, sizeof(struct mp_audio)); + struct mp_audio in = af->prev ? *(af->prev->data) : s->input; // Reset just in case... in.audio = NULL; in.len = 0; @@ -327,10 +323,7 @@ int af_reinit(struct af_stream *s, struct af_instance *af) (rv = new->control(new, AF_CONTROL_CHANNELS, &in.nch))) return rv; // Initialize channels filter - if (!new->prev) - memcpy(&in, &(s->input), sizeof(struct mp_audio)); - else - memcpy(&in, new->prev->data, sizeof(struct mp_audio)); + in = new->prev ? (*new->prev->data) : s->input; if (AF_OK != (rv = new->control(new, AF_CONTROL_REINIT, &in))) return rv; } @@ -347,10 +340,7 @@ int af_reinit(struct af_stream *s, struct af_instance *af) (rv = new->control(new, AF_CONTROL_FORMAT_FMT, &in.format))) return rv; // Initialize format filter - if (!new->prev) - memcpy(&in, &(s->input), sizeof(struct mp_audio)); - else - memcpy(&in, new->prev->data, sizeof(struct mp_audio)); + in = new->prev ? (*new->prev->data) : s->input; if (AF_OK != (rv = new->control(new, AF_CONTROL_REINIT, &in))) return rv; } |