summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-05-25 21:56:33 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-05-25 21:56:33 +0200
commitb062f43d7ec08324593cd6f1bdfed98ebeeafdc9 (patch)
tree6df630df774ab01a5df91a8414982542be433d55
parentbe9a541901d9f89403e0eb63427be1c15a28aeb9 (diff)
parent438c5366abb201a43ab339dcaa1c8b2dfd45e7c1 (diff)
Merge pull request #132 from choene/origin/aucodec_split_srate
Bug with reinit of codec structs
-rw-r--r--modules/mpa/decode.c14
-rw-r--r--modules/mpa/encode.c10
2 files changed, 15 insertions, 9 deletions
diff --git a/modules/mpa/decode.c b/modules/mpa/decode.c
index 7dfaccb..8a92fbc 100644
--- a/modules/mpa/decode.c
+++ b/modules/mpa/decode.c
@@ -51,12 +51,14 @@ int mpa_decode_update(struct audec_state **adsp, const struct aucodec *ac,
debug("MPA dec created %s\n",fmtp);
#endif
- if (ads)
- mem_deref(ads);
-
- ads = mem_zalloc(sizeof(*ads), destructor);
- if (!ads)
- return ENOMEM;
+ if (!ads) {
+ ads = mem_zalloc(sizeof(*ads), destructor);
+ if (!ads)
+ return ENOMEM;
+ }
+ else {
+ memset(ads,0,sizeof(*ads));
+ }
ads->channels = 0;
ads->resampler = NULL;
ads->start = 0;
diff --git a/modules/mpa/encode.c b/modules/mpa/encode.c
index 21a34c0..ec0b0a2 100644
--- a/modules/mpa/encode.c
+++ b/modules/mpa/encode.c
@@ -49,11 +49,15 @@ int mpa_encode_update(struct auenc_state **aesp, const struct aucodec *ac,
return EINVAL;
aes = *aesp;
- if (aes) {
- mem_deref(aes);
+ if (!aes) {
+ aes = mem_zalloc(sizeof(*aes), destructor);
+ if (!aes)
+ return ENOMEM;
+
}
+ else
+ memset(aes,0,sizeof(*aes));
- aes = mem_zalloc(sizeof(*aes), destructor);
aes->enc = twolame_init();
if (!aes->enc) {
error("MPA enc create failed\n");