From 3ddc5dbd45af3350e5f8379b871df6e0da490df6 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 16:05:32 -0400
Subject: [PATCH] * #6629 : remove unused error message from audio layer

inline error signaling in the one alsa function using them
---
 daemon/src/audio/alsa/alsalayer.cpp     |  5 +++--
 daemon/src/audio/audiolayer.cpp         |  1 -
 daemon/src/audio/audiolayer.h           | 21 --------------------
 daemon/src/global.h                     |  1 -
 daemon/src/managerimpl.cpp              | 26 +------------------------
 daemon/src/managerimpl_registration.cpp |  7 -------
 6 files changed, 4 insertions(+), 57 deletions(-)

diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp
index 7505094acf..57e68e28e5 100644
--- a/daemon/src/audio/alsa/alsalayer.cpp
+++ b/daemon/src/audio/alsa/alsalayer.cpp
@@ -34,6 +34,7 @@
 #include "eventthread.h"
 #include "audio/samplerateconverter.h"
 #include "managerimpl.h"
+#include "dbus/configurationmanager.h"
 
 class AlsaThread : public ost::Thread
 {
@@ -505,7 +506,7 @@ AlsaLayer::open_device (std::string pcm_p, std::string pcm_c, std::string pcm_r,
         int err;
         if ((err = snd_pcm_open (&playbackHandle_, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
             _warn ("Audio: Error while opening playback device %s",  pcm_p.c_str());
-            setErrorMessage (ALSA_PLAYBACK_DEVICE);
+            Manager::instance().getDbusManager()->getConfigurationManager()->errorAlert(ALSA_PLAYBACK_DEVICE);
             is_playback_open_ = false;
             return false;
         }
@@ -538,7 +539,7 @@ AlsaLayer::open_device (std::string pcm_p, std::string pcm_c, std::string pcm_r,
         if (snd_pcm_open (&captureHandle_,  pcm_c.c_str(),  SND_PCM_STREAM_CAPTURE, 0) < 0) {
             _warn ("Audio: Error: Opening capture device %s",  pcm_c.c_str());
 
-            setErrorMessage (ALSA_CAPTURE_DEVICE);
+            Manager::instance().getDbusManager()->getConfigurationManager()->errorAlert(ALSA_CAPTURE_DEVICE);
             is_capture_open_ = false;
             return false;
         }
diff --git a/daemon/src/audio/audiolayer.cpp b/daemon/src/audio/audiolayer.cpp
index af4c01df1d..89a822b6e0 100644
--- a/daemon/src/audio/audiolayer.cpp
+++ b/daemon/src/audio/audiolayer.cpp
@@ -45,7 +45,6 @@ AudioLayer::AudioLayer (int type)
     , frameSize_ (0)
     , inChannel_ (1)
     , outChannel_ (1)
-    , errorMessage_ (0)
     , mutex_ ()
 	, audioPref(Manager::instance().audioPreference)
 	, layerType_ (type)
diff --git a/daemon/src/audio/audiolayer.h b/daemon/src/audio/audiolayer.h
index 3f9b99d405..caf2f20709 100644
--- a/daemon/src/audio/audiolayer.h
+++ b/daemon/src/audio/audiolayer.h
@@ -115,24 +115,6 @@ class AudioLayer
 
         void flushUrgent (void);
 
-        /**
-         * Write accessor to the error state
-         * @param error The error code
-         *		    Could be: ALSA_PLAYBACK_DEVICE
-         *			      ALSA_CAPTURE_DEVICE
-         */
-        void setErrorMessage (int error) {
-            errorMessage_ = error;
-        }
-
-        /**
-         * Read accessor to the error state
-         * @return int  The error code
-         */
-        int getErrorMessage() const {
-            return errorMessage_;
-        }
-
         /**
          * Get the index of the audio card for capture
          * @return int The index of the card used for capture
@@ -286,9 +268,6 @@ class AudioLayer
          */
         unsigned int outChannel_;
 
-        /** Contains the current error code */
-        int errorMessage_;
-
         /**
          * Lock for the entire audio layer
          */
diff --git a/daemon/src/global.h b/daemon/src/global.h
index 66393d767c..fa9c9289e9 100644
--- a/daemon/src/global.h
+++ b/daemon/src/global.h
@@ -120,7 +120,6 @@ static const SOUND_FORMAT INT32 = 0x8;
 
 #define ALSA			  0
 #define PULSEAUDIO		  1
-#define CHECK_INTERFACE( layer , api )		  (layer == api)
 
 #define UNUSED          __attribute__((__unused__))
 
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index 0c928452f6..678633ff0d 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -2050,18 +2050,13 @@ std::string ManagerImpl::getCurrentCodecName (const std::string& id)
 void ManagerImpl::setAudioPlugin (const std::string& audioPlugin)
 {
 	audioLayerMutexLock();
-    int layerType = _audiodriver -> getLayerType();
 
     audioPreference.setPlugin (audioPlugin);
 
-    if (CHECK_INTERFACE (layerType , ALSA)) {
-        _debug ("Set input audio plugin");
+    if (_audiodriver -> getLayerType() == ALSA) {
         _audiodriver -> openDevice (_audiodriver->getIndexIn(), _audiodriver->getIndexOut(),
                                     _audiodriver->getIndexRing(), _audiodriver -> getSampleRate(),
                                     _audiodriver -> getFrameSize(), SFL_PCM_BOTH, audioPlugin);
-
-        if (_audiodriver -> getErrorMessage())
-            notifyErrClient (_audiodriver -> getErrorMessage());
     }
     audioLayerMutexUnlock();
 }
@@ -2116,9 +2111,6 @@ void ManagerImpl::setAudioDevice (const int index, int streamType)
             _warn ("Unknown stream type");
     }
 
-    if (_audiodriver -> getErrorMessage())
-        notifyErrClient (_audiodriver -> getErrorMessage());
-
     audioLayerMutexUnlock();
 }
 
@@ -2391,7 +2383,6 @@ int32_t ManagerImpl::getAudioManager (void) const
 
 void ManagerImpl::notifyErrClient (int32_t errCode)
 {
-	_debug ("Manager: NOTIFY ERR NUMBER %d" , errCode);
 	_dbus.getConfigurationManager()->errorAlert(errCode);
 }
 
@@ -2477,10 +2468,6 @@ void ManagerImpl::initAudioDriver (void)
         _audiodriver = new AlsaLayer;
     }
 
-	int error = _audiodriver->getErrorMessage();
-	if (error)
-		_error("Audio driver init: %d", error);
-
     audioLayerMutexUnlock();
 }
 
@@ -2534,11 +2521,6 @@ void ManagerImpl::selectAudioDriver (void)
     _audiodriver->openDevice (numCardIn, numCardOut, numCardRing, sampleRate, frameSize,
                               SFL_PCM_BOTH, alsaPlugin);
 
-    /* Notify the error if there is one */
-
-    if (_audiodriver-> getErrorMessage())
-        notifyErrClient (_audiodriver -> getErrorMessage());
-
     audioLayerMutexUnlock();
 }
 
@@ -2579,9 +2561,6 @@ void ManagerImpl::switchAudioManager (void)
     _audiodriver->openDevice (numCardIn, numCardOut, numCardRing, samplerate, framesize,
                               SFL_PCM_BOTH, alsaPlugin);
 
-    if (_audiodriver->getErrorMessage())
-        notifyErrClient (_audiodriver -> getErrorMessage());
-
     _debug ("Manager: Current device: %d ", type);
 
     if (wasStarted)
@@ -2635,9 +2614,6 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
     _audiodriver->openDevice (numCardIn, numCardOut, numCardRing, samplerate, framesize,
                               SFL_PCM_BOTH, alsaPlugin);
 
-    if (_audiodriver -> getErrorMessage())
-        notifyErrClient (_audiodriver -> getErrorMessage());
-
     _debug ("Manager: Current device: %d ", type);
 
     _mainBuffer.setInternalSamplingRate(samplerate);
diff --git a/daemon/src/managerimpl_registration.cpp b/daemon/src/managerimpl_registration.cpp
index 73f94cc55f..7faf1cb1c4 100644
--- a/daemon/src/managerimpl_registration.cpp
+++ b/daemon/src/managerimpl_registration.cpp
@@ -58,13 +58,6 @@ ManagerImpl::registerAccounts()
                 iter->second->registerVoIPLink();
         }
     }
-
-    audioLayerMutexLock();
-
-    if (_audiodriver->getErrorMessage() != -1)
-        notifyErrClient (_audiodriver->getErrorMessage());
-
-    audioLayerMutexUnlock();
 }
 
 
-- 
GitLab