From 0c721afda0980f5d05c42b03b2555f8f6156773e Mon Sep 17 00:00:00 2001
From: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
Date: Wed, 11 Sep 2013 14:14:43 -0400
Subject: [PATCH] * #29866: fixed deallocation of recorder

---
 daemon/src/audio/opensl/opensllayer.cpp | 12 +++++++++---
 daemon/src/audio/opensl/opensllayer.h   |  4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/daemon/src/audio/opensl/opensllayer.cpp b/daemon/src/audio/opensl/opensllayer.cpp
index ed72b730b5..8ef3b26920 100644
--- a/daemon/src/audio/opensl/opensllayer.cpp
+++ b/daemon/src/audio/opensl/opensllayer.cpp
@@ -147,8 +147,8 @@ OpenSLLayer::OpenSLLayer()
     , recorderBufferQueue_(0)
     , playbackBufferIndex_(0)
     , recordBufferIndex_(0)
-    , playbackBufferStack_(ANDROID_BUFFER_QUEUE_LENGTH, AudioBuffer(3000))
-    , recordBufferStack_(ANDROID_BUFFER_QUEUE_LENGTH, AudioBuffer(3000))
+    , playbackBufferStack_(ANDROID_BUFFER_QUEUE_LENGTH, AudioBuffer(BUFFER_SIZE))
+    , recordBufferStack_(ANDROID_BUFFER_QUEUE_LENGTH, AudioBuffer(BUFFER_SIZE))
 {
 }
 
@@ -257,9 +257,15 @@ OpenSLLayer::shutdownAudioEngine()
         outputMixer_ = NULL;
     }
 
+	if(recorderObject_ != NULL){
+		(*recorderObject_)->Destroy(recorderObject_);
+		recorderObject_ = NULL;
+		recorderInterface_ = NULL;
+		recorderBufferQueue_ = NULL;
+	}
+
     // destroy engine object, and invalidate all associated interfaces
     DEBUG("Shutdown audio engine\n");
-
     if (engineObject_ != NULL) {
         (*engineObject_)->Destroy(engineObject_);
         engineObject_ = NULL;
diff --git a/daemon/src/audio/opensl/opensllayer.h b/daemon/src/audio/opensl/opensllayer.h
index 889137503a..f2ef05be45 100644
--- a/daemon/src/audio/opensl/opensllayer.h
+++ b/daemon/src/audio/opensl/opensllayer.h
@@ -36,6 +36,7 @@
 #include <vector>
 
 #include "../audiolayer.h"
+#include "logger.h"
 
 
 enum PCMType {
@@ -52,6 +53,7 @@ class AudioPreference;
 class OpenSLThread;
 
 #define ANDROID_BUFFER_QUEUE_LENGTH 2
+#define BUFFER_SIZE 5000
 
 
 /**
@@ -238,9 +240,7 @@ class OpenSLLayer : public AudioLayer {
          * Output mix interface
          */
         SLObjectItf outputMixer_;
-
         SLObjectItf playerObject_;
-
         SLObjectItf recorderObject_;
 
         /**
-- 
GitLab