diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp
index a0db12cbb3d747c3405ecd0a05fc0c22c8555154..29fab5371b33c4f313b9871faff3c4cc0855b62b 100644
--- a/src/audio/audiolayer.cpp
+++ b/src/audio/audiolayer.cpp
@@ -99,7 +99,7 @@ AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize
   ost::MutexLock lock( _mutex );
 
   std::string pcmp = buildDeviceTopo( plugin , indexOut , 0);
-  std::string pcmc = buildDeviceTopo(PCM_SURROUND40 , indexIn , 0);
+  std::string pcmc = buildDeviceTopo( plugin , indexIn , 0);
   return open_device( pcmp , pcmc , stream);
 }
 
@@ -306,7 +306,7 @@ AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag)
   int dir = 0;
   snd_pcm_uframes_t period_size_in =  getFrameSize() * getSampleRate() / 1000 ;
   snd_pcm_uframes_t buffer_size_in = 4096;
-  snd_pcm_uframes_t threshold = getFrameSize() * getSampleRate() / 1000  * 2 ;
+  snd_pcm_uframes_t threshold = 1024 ;
   snd_pcm_uframes_t period_size_out =  1024 ;
   snd_pcm_uframes_t buffer_size_out = period_size_out * 8 ;
 
@@ -363,11 +363,11 @@ AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag)
     snd_pcm_sw_params_get_start_threshold( swparams , &val);
     _debug("Start threshold = %d\n" ,val);
     //if( err = snd_pcm_sw_params_set_start_threshold( _PlaybackHandle, swparams, threshold ) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); 
+    if( err = snd_pcm_sw_params_set_stop_threshold( _PlaybackHandle, swparams, buffer_size_out ) < 0 ) _debugAlsa(" Cannot set stop threshold (%s)\n", snd_strerror(err)); 
     snd_pcm_sw_params_get_stop_threshold( swparams , &val);
     _debug("Stop threshold = %d\n" ,val);
-    //if( err = snd_pcm_sw_params_set_stop_threshold( _PlaybackHandle, swparams, buffer_size_out ) < 0 ) _debugAlsa(" Cannot set stop threshold (%s)\n", snd_strerror(err)); 
     //if( err = snd_pcm_sw_params_set_start_mode( _PlaybackHandle, swparams, SND_PCM_START_DATA ) < 0 ) _debugAlsa(" Cannot set start mode (%s)\n", snd_strerror(err)); 
-    //if( err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, threshold) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); 
+    if( err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, threshold) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); 
     snd_pcm_sw_params_get_avail_min( swparams , &val);
     _debug("Min available = %d\n" ,val);
     //if( err = snd_pcm_sw_params_set_silence_threshold( _PlaybackHandle, swparams, threshold) < 0) _debugAlsa(" Cannot set silence threshold (%s)\n" , snd_strerror(err)); 
@@ -499,6 +499,8 @@ AudioLayer::buildDeviceTopo( std::string plugin, int card, int subdevice )
 {
   std::string pcm = plugin;
   std::stringstream ss,ss1;
+  if( pcm == "default")
+    return pcm;
   ss << card;
   pcm.append(":");
   pcm.append(ss.str());
@@ -511,7 +513,7 @@ AudioLayer::buildDeviceTopo( std::string plugin, int card, int subdevice )
 }
 
   std::vector<std::string>
-AudioLayer::getSoundCardsInfo( int flag )
+AudioLayer::getSoundCardsInfo( int stream )
 {
   std::vector<std::string> cards_id;
   HwIDPair p;
@@ -538,11 +540,7 @@ AudioLayer::getSoundCardsInfo( int flag )
     if( snd_ctl_open( &handle, name.c_str(), 0) == 0 ){
       if( snd_ctl_card_info( handle, info) == 0){
 	snd_pcm_info_set_device( pcminfo , 0);
-	if(flag == SFL_PCM_CAPTURE)
-	  snd_pcm_info_set_stream( pcminfo, SND_PCM_STREAM_CAPTURE );
-	else
-	  snd_pcm_info_set_stream( pcminfo, SND_PCM_STREAM_PLAYBACK );
-
+	snd_pcm_info_set_stream( pcminfo, ( stream == SFL_PCM_CAPTURE )? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK );
 	if( snd_ctl_pcm_info ( handle ,pcminfo ) < 0) _debugAlsa(" Cannot get info\n");
 	else{
 	  _debugAlsa("card %i : %s [%s]\n", 
@@ -571,7 +569,6 @@ AudioLayer::getSoundCardsInfo( int flag )
 AudioLayer::closeCaptureStream( void)
 {
   if(_CaptureHandle){
-    //_debugAlsa(" Close the current capture device\n");
     snd_pcm_drop( _CaptureHandle );
     snd_pcm_close( _CaptureHandle );
     _CaptureHandle = 0;
@@ -582,7 +579,6 @@ AudioLayer::closeCaptureStream( void)
 AudioLayer::closePlaybackStream( void)
 {
   if(_PlaybackHandle){
-    //_debugAlsa(" Close the current playback device\n");
     snd_pcm_drop( _PlaybackHandle );
     snd_pcm_close( _PlaybackHandle );
     _PlaybackHandle = 0;
@@ -591,15 +587,21 @@ AudioLayer::closePlaybackStream( void)
 
 
   bool
-AudioLayer::soundCardIndexExist( int card )
+AudioLayer::soundCardIndexExist( int card , int stream )
 {
   snd_ctl_t* handle;
+  snd_pcm_info_t *pcminfo;
+  snd_pcm_info_alloca( &pcminfo );
   std::string name = "hw:";
   std::stringstream ss;
   ss << card ;
   name.append(ss.str());
-  if(snd_ctl_open( &handle, name.c_str(), 0) == 0 )
-    return true;
+  if(snd_ctl_open( &handle, name.c_str(), 0) == 0 ){
+   snd_pcm_info_set_stream( pcminfo , ( stream == SFL_PCM_PLAYBACK )? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE );
+    if( snd_ctl_pcm_info( handle , pcminfo ) < 0) return false;
+    else
+      return true;
+  }
   else
     return false;
 }  
@@ -611,7 +613,6 @@ AudioLayer::soundCardGetIndex( std::string description )
   for( i = 0 ; i < IDSoundCards.size() ; i++ )
   {
     HwIDPair p = IDSoundCards[i];
-    //_debug("%i %s\n", p.first , p.second.c_str());
     if( p.second == description )
       return  p.first ;
   }
diff --git a/src/audio/audiolayer.h b/src/audio/audiolayer.h
index 8cbbdaab73696ad66648e217b5fde830ef510574..471e85e2b3a1c8782969c12a06efe3f554abe224 100644
--- a/src/audio/audiolayer.h
+++ b/src/audio/audiolayer.h
@@ -154,8 +154,8 @@ class AudioLayer {
      *		   SFL_PCM_BOTH
      * @return std::vector<std::string> The vector containing the string description of the card
      */
-    std::vector<std::string> getSoundCardsInfo( int flag );
-    bool soundCardIndexExist( int card );
+    std::vector<std::string> getSoundCardsInfo( int stream );
+    bool soundCardIndexExist( int card , int stream );
     int soundCardGetIndex( std::string description );
 
     void setErrorMessage(const std::string& error) { _errorMessage = error; }
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index c5b99561e97d3d4089415aa5030d0bbea5ace195..697b148eb4f593f37a4ff2ab7c11c086e7c449ff 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -1244,9 +1244,6 @@ ManagerImpl::getOutputAudioPluginList(void)
 
   v.push_back( PCM_DEFAULT );
   v.push_back( PCM_PLUGHW );
-  v.push_back( PCM_DMIX );
-  v.push_back( PCM_SURROUND40 );
-  //v.push_back( PCM_HW );
 
   return v;
 }
@@ -1358,9 +1355,7 @@ ManagerImpl::getAudioDeviceIndex(const std::string name)
 {
   _debug("Get audio device index\n");
   int num = _audiodriver -> soundCardGetIndex( name );
-  _debug(" %s has number %i\n" , name.c_str() , num );
   return num;
-  //return _audiodriver -> soundCardGetIndex( name );
 }
 
 std::string 
@@ -1404,15 +1399,17 @@ ManagerImpl::selectAudioDriver (void)
   }
   int frameSize = getConfigInt( AUDIO , ALSA_FRAME_SIZE );
 
-  if( !_audiodriver -> soundCardIndexExist( numCardIn ) )
+  if( !_audiodriver -> soundCardIndexExist( numCardIn , SFL_PCM_CAPTURE ) )
   {
-    _debug(" Index %i is not a valid card number. Switch to 0.\n", numCardIn);
+    _debug(" Card with index %i doesn't exist or cannot capture. Switch to 0.\n", numCardIn);
     numCardIn = ALSA_DFT_CARD_ID ;
+    setConfig( AUDIO , ALSA_CARD_ID_IN , ALSA_DFT_CARD_ID );
   }
-  if( !_audiodriver -> soundCardIndexExist( numCardOut ) )
+  if( !_audiodriver -> soundCardIndexExist( numCardOut , SFL_PCM_PLAYBACK ) )
   {  
-    _debug(" Index %i is not a valid card number. Switch to 0.\n", numCardOut);
+    _debug(" Card with index %i doesn't exist or cannot playback . Switch to 0.\n", numCardOut);
     numCardOut = ALSA_DFT_CARD_ID ;
+    setConfig( AUDIO , ALSA_CARD_ID_OUT , ALSA_DFT_CARD_ID );
   }
 
   _debugInit(" AudioLayer Opening Device");