[GnomeMeeting-devel-list] gnomemeeting + ALSA + DMIX



Hi all,

Yesterday I patched pwlib from cvs code to add changes from Damien
Sandras to use default device for DMIX.. Now tests with the wizard on
audio settings are ok: I can hear and record my voice.  But
gnomemeeting continue to have audio disabled. Any id why ? Find
enclosed the patch I've done and my asound.conf file.

Hope there is a quick fix :)
diff -ru pwlib-orig/plugins/sound_alsa/sound_alsa.cxx pwlib/plugins/sound_alsa/sound_alsa.cxx
--- pwlib-orig/plugins/sound_alsa/sound_alsa.cxx	2004-03-13 13:36:14.000000000 +0100
+++ pwlib/plugins/sound_alsa/sound_alsa.cxx	2004-10-21 18:33:38.562610536 +0200
@@ -28,6 +28,21 @@
  * Contributor(s): /
  *
  * $Log: sound_alsa.cxx,v $
+ * Revision 1.21  2004/10/18 11:43:39  dsandras
+ * Use Capture instead of Mic when changing the volume. Use the correct mixer when using the Default device.
+ *
+ * Revision 1.20  2004/10/14 19:30:16  dsandras
+ * Removed DMIX and DSNOOP plugins and added support for DEFAULT as it is the correcti way to do things.
+ *
+ * Revision 1.19  2004/08/30 21:09:41  dsandras
+ * Added DSNOOP plugin support.
+ *
+ * Revision 1.18  2004/05/14 10:15:26  dominance
+ * Fixes direct opening of sound output devices. The list of devices does no longer return NULL in that case. Patch provided by Julien Puydt <julien puydt laposte net>.
+ *
+ * Revision 1.17  2004/04/03 10:33:45  dsandras
+ * Use PStringToOrdinal to store the detected devices, that fixes problems if there is a discontinuity in the succession of soundcard ID's. For example the user has card ID 1 and 3, but not 2.
+ *
  * Revision 1.16  2004/03/13 12:36:14  dsandras
  * Added support for DMIX plugin output.
  *
@@ -81,8 +96,8 @@
 PCREATE_SOUND_PLUGIN(ALSA, PSoundChannelALSA)
 
 
-static PStringArray playback_devices;
-static PStringArray capture_devices;
+static PStringToOrdinal playback_devices;
+static PStringToOrdinal capture_devices;
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -119,8 +134,9 @@
 }
 
 
-PStringArray PSoundChannelALSA::GetDeviceNames (Directions dir)
+void PSoundChannelALSA::UpdateDictionary (Directions dir)
 {
+  
   int card = -1, dev = -1;
   
   snd_ctl_t *handle = NULL;
@@ -134,12 +150,12 @@
   if (dir == Recorder) {
 
     stream = SND_PCM_STREAM_CAPTURE;
-    capture_devices = PStringArray ();
+    capture_devices = PStringToOrdinal ();
   }
   else {
 
     stream = SND_PCM_STREAM_PLAYBACK;
-    playback_devices = PStringArray ();
+    playback_devices = PStringToOrdinal ();
   }
 
   snd_ctl_card_info_alloca (&info);
@@ -148,7 +164,7 @@
   /* No sound card found */
   if (snd_card_next (&card) < 0 || card < 0) {
 
-    return PStringArray ();
+    return;
   }
 
 
@@ -176,13 +192,11 @@
           snd_card_get_name (card, &name);
           if (dir == Recorder) {
 
-            if (capture_devices.GetStringsIndex (name) == P_MAX_INDEX)
-              capture_devices.AppendString (name);
+              capture_devices.SetAt (name, card);
           }
           else {
 
-            if (playback_devices.GetStringsIndex (name) == P_MAX_INDEX)
-              playback_devices.AppendString (name);
+              playback_devices.SetAt (name, card);
           }
 
           free (name);
@@ -193,17 +207,27 @@
     snd_ctl_close(handle);
     snd_card_next (&card);
   }
+}
 
-
-  if (dir == Recorder)
-    return capture_devices;
-  else {
+PStringArray PSoundChannelALSA::GetDeviceNames (Directions dir)
+{
+  PStringArray devices;
+  PStringToOrdinal devices_dict;
  
-    if (playback_devices.GetSize () > 0)
-      playback_devices += "DMIX Plugin";
+  if (dir == Recorder)
+    devices_dict = capture_devices;
+  else
+    devices_dict = playback_devices;
+
+  UpdateDictionary (dir);
+  
+  if (devices_dict.GetSize () > 0)
+    devices += "Default";
+  
+  for (PINDEX j = 0 ; j < devices_dict.GetSize () ; j++) 
+    devices += devices_dict.GetKeyAt (j);
     
-    return playback_devices;
-  }
+  return devices;
 }
 
 
@@ -223,7 +247,7 @@
 			      unsigned _bitsPerSample)
 {
   PString real_device_name;
-  PINDEX i = 0;
+  POrdinalKey *i = NULL;
   snd_pcm_stream_t stream;
 
   Close();
@@ -236,21 +260,31 @@
     stream = SND_PCM_STREAM_PLAYBACK;
 
   /* Open in NONBLOCK mode */
-  if (_dir != Recorder && _device == "DMIX Plugin") {
+  if (_device == "Default") {
 
-    real_device_name = "plug:dmix";
+    real_device_name = "default";
+    card_nr = -2;
   }
-  else if ((i = (_dir == Recorder) ? capture_devices.GetStringsIndex (_device) : playback_devices.GetStringsIndex (_device)) != P_MAX_INDEX) {
+  else {
+
+  if ((_dir == Recorder && capture_devices.IsEmpty ())
+      || (_dir == Player && playback_devices.IsEmpty ()))
+    UpdateDictionary (_dir);
+
+    i = (_dir == Recorder) ? capture_devices.GetAt (_device) : playback_devices.GetAt (_device);
 
-    real_device_name = "plughw:" + PString (i);
-    card_nr = i;
+    if (i) {
+
+      real_device_name = "plughw:" + PString (*i);
+      card_nr = *i;
+    }
+    else {
+
+      PTRACE (1, "ALSA\tDevice not found");
+      return FALSE;
+    }
   }
-  else {
     
-    PTRACE (1, "ALSA\tDevice unavailable");
-    return FALSE;
-  }
-
   if (snd_pcm_open (&os_handle, real_device_name, stream, SND_PCM_NONBLOCK) < 0) {
 
     PTRACE (1, "ALSA\tOpen Failed");
@@ -735,7 +769,7 @@
   snd_mixer_elem_t *elem;
   snd_mixer_selem_id_t *sid;
 
-  const char *play_mix_name = (direction == Player) ? "PCM": "Mic";
+  const char *play_mix_name = (direction == Player) ? "PCM": "Capture";
   PString card_name;
 
   long pmin = 0, pmax = 0;
@@ -744,7 +778,10 @@
   if (!os_handle)
     return FALSE;
 
-  card_name = "hw:" + PString (card_nr);
+  if (card_nr == -2)
+    card_name = "default";
+  else
+    card_name = "hw:" + PString (card_nr);
 
   //allocate simple id
   snd_mixer_selem_id_alloca (&sid);
@@ -796,23 +833,39 @@
     return FALSE;
   }
 
-  snd_mixer_selem_get_playback_volume_range (elem, &pmin, &pmax);
 
   if (set) {
-
-    vol = (set_vol * (pmax?pmax:31)) / 100;
-    snd_mixer_selem_set_playback_volume (elem, 
-					 SND_MIXER_SCHN_FRONT_LEFT, vol);
-    snd_mixer_selem_set_playback_volume (elem, 
-					 SND_MIXER_SCHN_FRONT_RIGHT, vol);
     
+    if (direction == Player) {
+      
+      snd_mixer_selem_get_playback_volume_range (elem, &pmin, &pmax);
+      vol = (set_vol * (pmax?pmax:31)) / 100;
+      snd_mixer_selem_set_playback_volume_all (elem, vol);
+    }
+    else {
+      
+      snd_mixer_selem_get_capture_volume_range (elem, &pmin, &pmax);
+      vol = (set_vol * (pmax?pmax:31)) / 100;
+      snd_mixer_selem_set_capture_volume_all (elem, vol);
+    }
     PTRACE (4, "Set volume to " << vol);
   }
   else {
 
-    snd_mixer_selem_get_playback_volume (elem, 
-					 SND_MIXER_SCHN_FRONT_LEFT, &vol);
+    if (direction == Player) {
+      
+      snd_mixer_selem_get_playback_volume_range (elem, &pmin, &pmax);
+      snd_mixer_selem_get_playback_volume (elem, SND_MIXER_SCHN_FRONT_LEFT, 
+					   &vol);
+    }
+    else {
+      
+      snd_mixer_selem_get_capture_volume_range (elem, &pmin, &pmax);
+      snd_mixer_selem_get_capture_volume (elem, SND_MIXER_SCHN_FRONT_LEFT,
+					  &vol); 
+    }
     get_vol = (vol * 100) / (pmax?pmax:31);
+
     PTRACE (4, "Got volume " << vol);
   }
 
Only in pwlib/plugins/sound_alsa: .sound_alsa.cxx-patch.swp
diff -ru pwlib-orig/plugins/sound_alsa/sound_alsa.h pwlib/plugins/sound_alsa/sound_alsa.h
--- pwlib-orig/plugins/sound_alsa/sound_alsa.h	2003-12-28 16:10:35.000000000 +0100
+++ pwlib/plugins/sound_alsa/sound_alsa.h	2004-10-21 18:35:51.559391952 +0200
@@ -89,7 +89,8 @@
   BOOL IsOpen() const;
 
  private:
-
+ 
+  static void UpdateDictionary(PSoundChannel::Directions);
   BOOL Volume (BOOL, unsigned, unsigned &);
   PSoundChannel::Directions direction;
   PString device;

Attachment: asound.conf
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]