From c5d8c3a9a1029e3e616fe38e384b38307252c800 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?=
 <rafael.carre@savoirfairelinux.com>
Date: Mon, 29 Aug 2011 15:49:02 -0400
Subject: [PATCH] Fix logic error when switching audio API

---
 daemon/src/audio/audiolayer.cpp | 4 ++--
 daemon/src/audio/audiolayer.h   | 6 ++++--
 daemon/src/managerimpl.cpp      | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/daemon/src/audio/audiolayer.cpp b/daemon/src/audio/audiolayer.cpp
index 354a185744..af4c01df1d 100644
--- a/daemon/src/audio/audiolayer.cpp
+++ b/daemon/src/audio/audiolayer.cpp
@@ -35,8 +35,7 @@
 #include "manager.h"
 
 AudioLayer::AudioLayer (int type)
-    : layerType_ (type)
-    , isStarted_ (false)
+    : isStarted_ (false)
     , urgentRingBuffer_ (SIZEBUF, Call::DEFAULT_ID)
     , recorder_ (0)
     , indexIn_ (0)
@@ -49,6 +48,7 @@ AudioLayer::AudioLayer (int type)
     , errorMessage_ (0)
     , mutex_ ()
 	, audioPref(Manager::instance().audioPreference)
+	, layerType_ (type)
     , lastNotificationTime_ (0)
 {}
 
diff --git a/daemon/src/audio/audiolayer.h b/daemon/src/audio/audiolayer.h
index 20e5458f10..3f9b99d405 100644
--- a/daemon/src/audio/audiolayer.h
+++ b/daemon/src/audio/audiolayer.h
@@ -224,8 +224,6 @@ class AudioLayer
 
     protected:
 
-        int layerType_;
-
         /**
          * Drop the pending frames and close the capture device
          */
@@ -301,6 +299,10 @@ class AudioLayer
         AudioPreference &audioPref;
 
     private:
+
+        const int layerType_;
+
+
         /**
          * Time of the last incoming call notification
          */
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index 38e552dd5d..0c928452f6 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -2628,9 +2628,9 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
 
     delete _audiodriver;
     if (type == PULSEAUDIO)
-    	_audiodriver = new PulseLayer;
-    else
     	_audiodriver = new AlsaLayer;
+    else
+    	_audiodriver = new PulseLayer;
 
     _audiodriver->openDevice (numCardIn, numCardOut, numCardRing, samplerate, framesize,
                               SFL_PCM_BOTH, alsaPlugin);
-- 
GitLab