All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Courtier-Dutton <James@superbug.demon.co.uk>
To: alsa-devel@alsa-project.org
Subject: [PATCH] Change alsamixer to show different views. Playback controls, or Capture controls.
Date: Fri, 27 Aug 2004 13:51:26 +0100	[thread overview]
Message-ID: <412F2E4E.4080300@superbug.demon.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 340 bytes --]

I attach a diff file against ./alsa-utils/alsamixer/alsamixer.c

It causes alsamixer to display 2 different views of the mixer controls.
One view shows only the "Playback" controls, the other view shows only 
the "Capture" controls, with a hidden mode (Press F1, then Enter) to 
show the old method of all controls together.

Cheers

James

[-- Attachment #2: alsamixer-separate-play-capture.txt --]
[-- Type: text/plain, Size: 9361 bytes --]

--- alsamixer.c.org	2004-08-13 12:01:34.000000000 +0100
+++ alsamixer.c	2004-08-27 13:44:29.132321190 +0100
@@ -167,6 +167,8 @@
 /* --- views --- */
 enum {
   VIEW_CHANNELS,
+  VIEW_PLAYBACK,
+  VIEW_CAPTURE,
   VIEW_HELP,
   VIEW_PROCINFO
 };
@@ -177,7 +179,7 @@
 static int	 mixer_needs_resize = 0;
 static int	 mixer_minimize = 0;
 static int	 mixer_no_lrcorner = 0;
-static int	 mixer_view = VIEW_CHANNELS;
+static int	 mixer_view = VIEW_PLAYBACK;
 static int	 mixer_max_x = 0;
 static int	 mixer_max_y = 0;
 static int	 mixer_ofs_x = 0;
@@ -227,6 +229,7 @@
 
 /* split scontrols */
 static int	 mixer_n_elems = 0;
+static int	 mixer_n_view_elems = 0;
 static int	 mixer_n_vis_elems = 0;
 static int	 mixer_first_vis_elem = 0;
 static int	 mixer_focus_elem = 0;
@@ -254,6 +257,8 @@
  " Esc     exit alsamixer\n"
  " F1      show Help screen\n"
  " F2      show /proc info screen\n"
+ " F3      show Playback controls only\n"
+ " F4      show Capture controls only\n"
  " Return  return to main screen\n"
  " Space   toggle Capture facility\n"
  " Tab     toggle ExactMode\n"
@@ -545,7 +550,7 @@
 
   if (mixer_sid == NULL)
     return;
-  
+
   sid = (snd_mixer_selem_id_t *)(((char *)mixer_sid) + snd_mixer_selem_id_sizeof() * mixer_grpidx[elem_index]);
   elem = snd_mixer_find_selem(mixer_handle, sid);
   if (elem == NULL)
@@ -758,7 +763,7 @@
       vright = vleft;
     }
   }
-  
+
   if (type == MIXER_ELEM_CAPTURE && snd_mixer_selem_has_capture_volume(elem)) {
     long vmin, vmax;
     snd_mixer_selem_get_capture_volume_range(elem, &vmin, &vmax);
@@ -779,7 +784,21 @@
     if (xlen > 63)
       xlen = 63;
     mixer_dc (DC_PROMPT);
-    mvaddstr (3, 2, "Item: ");
+    mvaddstr (3, 2, "View: ");
+    mixer_dc (DC_TEXT);
+    switch (mixer_view) {
+    case VIEW_PLAYBACK:
+      mvaddstr (3, 8, "Playback");
+      break;
+    case VIEW_CAPTURE:
+      mvaddstr (3, 8, "Capture");
+      break;
+    default:
+      mvaddstr (3, 8, "All");
+      break;
+    }
+    mixer_dc (DC_PROMPT);
+    mvaddstr (4, 2, "Item: ");
     mixer_dc (DC_TEXT);
     string1[8] = 0;
     for (i = 0; i < 63; i++)
@@ -952,7 +971,6 @@
   static int o_y = 0;
   int i, x, y;
   
-  
   if (!mixer_cbar_get_pos (mixer_focus_elem, &x, &y))
     {
       if (mixer_focus_elem < mixer_first_vis_elem)
@@ -961,15 +979,15 @@
 	mixer_first_vis_elem = mixer_focus_elem - mixer_n_vis_elems + 1;
       mixer_cbar_get_pos (mixer_focus_elem, &x, &y);
     }
-  if (mixer_first_vis_elem + mixer_n_vis_elems >= mixer_n_elems) {
-     mixer_first_vis_elem = mixer_n_elems - mixer_n_vis_elems;
+  if (mixer_first_vis_elem + mixer_n_vis_elems >= mixer_n_view_elems) {
+     mixer_first_vis_elem = mixer_n_view_elems - mixer_n_vis_elems;
      if (mixer_first_vis_elem < 0)
        mixer_first_vis_elem = 0;
      mixer_cbar_get_pos (mixer_focus_elem, &x, &y);
   }
   mixer_write_cbar(mixer_focus_elem);
   for (i = 0; i < mixer_n_vis_elems; i++) {
-    if (i + mixer_first_vis_elem >= mixer_n_elems)
+    if (i + mixer_first_vis_elem >= mixer_n_view_elems)
       continue;
     mixer_update_cbar (i + mixer_first_vis_elem);
   }
@@ -1521,53 +1539,57 @@
     elem = snd_mixer_find_selem(mixer_handle, sid);
     if (elem == NULL)
       CHECK_ABORT (ERR_FCN, "snd_mixer_find_selem()", -EINVAL);
-    for (i = 0; i < MIXER_ELEM_CAPTURE; i++) {
-      int ok;
-      for (j = ok = 0; j < 2; j++) {
-	if (mixer_changed_state)
-	  goto __again;
-	if (snd_mixer_selem_has_playback_channel(elem, mixer_elem_chn[i][j]))
-	  ok++;
+    if ( (mixer_view == VIEW_PLAYBACK) || (mixer_view == VIEW_CHANNELS) ) {
+      for (i = 0; i < MIXER_ELEM_CAPTURE; i++) {
+        int ok;
+        for (j = ok = 0; j < 2; j++) {
+	  if (mixer_changed_state)
+	    goto __again;
+ 	  if (snd_mixer_selem_has_playback_channel(elem, mixer_elem_chn[i][j]))
+	    ok++;
+        }
+        if (ok) {
+	  sid = (snd_mixer_selem_id_t *)(((char *)mixer_sid) + snd_mixer_selem_id_sizeof() * idx);
+	  mixer_grpidx[elem_index] = idx;
+	  if (snd_mixer_selem_is_enumerated(elem)) {
+	    mixer_type[elem_index] = MIXER_ELEM_ENUM;
+	  } else {
+	    mixer_type[elem_index] = i;
+	    if (i == 0 && snd_mixer_selem_has_playback_switch(elem))
+	      mixer_type[elem_index] |= MIXER_ELEM_MUTE_SWITCH;
+	    if (snd_mixer_selem_has_playback_volume(elem))
+	      mixer_type[elem_index] |= MIXER_ELEM_HAS_VOLUME;
+	  }
+	  elem_index++;
+	  nelems_added++;
+	  if (elem_index >= mixer_n_elems)
+	    break;
+        }
       }
-      if (ok) {
-	sid = (snd_mixer_selem_id_t *)(((char *)mixer_sid) + snd_mixer_selem_id_sizeof() * idx);
-	mixer_grpidx[elem_index] = idx;
-	if (snd_mixer_selem_is_enumerated(elem)) {
-	  mixer_type[elem_index] = MIXER_ELEM_ENUM;
-	} else {
-	  mixer_type[elem_index] = i;
-	  if (i == 0 && snd_mixer_selem_has_playback_switch(elem))
-	    mixer_type[elem_index] |= MIXER_ELEM_MUTE_SWITCH;
-	  if (snd_mixer_selem_has_playback_volume(elem))
-	    mixer_type[elem_index] |= MIXER_ELEM_HAS_VOLUME;
-	  if (i == 0 && snd_mixer_selem_has_capture_switch(elem))
-	    mixer_type[elem_index] |= MIXER_ELEM_CAPTURE_SWITCH;
-	}
-	elem_index++;
-	nelems_added++;
-	if (elem_index >= mixer_n_elems)
+    }
+
+    if ( (mixer_view == VIEW_CAPTURE) || (mixer_view == VIEW_CHANNELS) ) {
+      if (snd_mixer_selem_has_capture_volume(elem) ||
+	  (nelems_added == 0 && snd_mixer_selem_has_capture_switch(elem))) {
+        mixer_grpidx[elem_index] = idx;
+        mixer_type[elem_index] = MIXER_ELEM_CAPTURE;
+        if (nelems_added == 0 && snd_mixer_selem_has_capture_switch(elem))
+	  mixer_type[elem_index] |= MIXER_ELEM_CAPTURE_SWITCH;
+        if (nelems_added)
+	  mixer_type[elem_index] |= MIXER_ELEM_CAPTURE_SUFFIX;
+        if (snd_mixer_selem_has_capture_volume(elem))
+	  mixer_type[elem_index] |= MIXER_ELEM_HAS_VOLUME;
+        elem_index++;
+        if (elem_index >= mixer_n_elems)
 	  break;
       }
     }
-    if (snd_mixer_selem_has_capture_volume(elem) ||
-	(nelems_added == 0 && snd_mixer_selem_has_capture_switch(elem))) {
-      mixer_grpidx[elem_index] = idx;
-      mixer_type[elem_index] = MIXER_ELEM_CAPTURE;
-      if (nelems_added == 0 && snd_mixer_selem_has_capture_switch(elem))
-	mixer_type[elem_index] |= MIXER_ELEM_CAPTURE_SWITCH;
-      if (nelems_added)
-	mixer_type[elem_index] |= MIXER_ELEM_CAPTURE_SUFFIX;
-      if (snd_mixer_selem_has_capture_volume(elem))
-	mixer_type[elem_index] |= MIXER_ELEM_HAS_VOLUME;
-      elem_index++;
-      if (elem_index >= mixer_n_elems)
-	break;
-    }
   }
 
+  mixer_n_view_elems = elem_index;
   mixer_focus_elem = 0;
   if (focus_type >= 0) {
-    for (elem_index = 0; elem_index < mixer_n_elems; elem_index++) {
+    for (elem_index = 0; elem_index < mixer_n_view_elems; elem_index++) {
       sid = (snd_mixer_selem_id_t *)(((char *)mixer_sid) + snd_mixer_selem_id_sizeof() * mixer_grpidx[elem_index]);
       if (!strcmp(snd_mixer_selem_id_get_name(focus_gid),
                   snd_mixer_selem_id_get_name(sid)) &&
@@ -1619,7 +1641,7 @@
 
   /* required allocations */
   mixer_n_vis_elems = (mixer_max_x - mixer_ofs_x * 2 + 1) / 9;
-  mixer_n_vis_elems = CLAMP (mixer_n_vis_elems, 1, mixer_n_elems);
+  mixer_n_vis_elems = CLAMP (mixer_n_vis_elems, 1, mixer_n_view_elems);
   mixer_extra_space = mixer_max_x - mixer_ofs_x * 2 + 1 - mixer_n_vis_elems * 9;
   mixer_extra_space = MAX (0, mixer_extra_space / (mixer_n_vis_elems + 1));
   if (MIXER_TEXT_Y + 10 < mixer_max_y)
@@ -1769,9 +1791,13 @@
       break;
     case 13:	/* Return */
     case 10:	/* NewLine */
-      if (mixer_view == VIEW_CHANNELS)
+      if (mixer_view == VIEW_CHANNELS) {
 	mixer_clear (FALSE);
-      mixer_view = VIEW_CHANNELS;
+      } else {
+        mixer_view = VIEW_CHANNELS;
+        mixer_changed_state=1;
+        mixer_reinit ();
+      } 
       key = 0;
       break;
     case 'h':
@@ -1785,6 +1811,26 @@
       mixer_view = VIEW_PROCINFO;
       key = 0;
       break;
+    case KEY_F (3):
+      if (mixer_view == VIEW_PLAYBACK) {
+	mixer_clear (FALSE);
+      } else {
+        mixer_view = VIEW_PLAYBACK;
+        mixer_changed_state=1;
+        mixer_reinit ();
+      } 
+      key = 0;
+      break;
+    case KEY_F (4):
+      if (mixer_view == VIEW_CAPTURE) {
+	mixer_clear (FALSE);
+      } else {
+        mixer_view = VIEW_CAPTURE;
+        mixer_changed_state=1;
+        mixer_reinit ();
+      } 
+      key = 0;
+      break;
     case '\014':
     case 'L':
     case 'l':
@@ -1855,7 +1901,10 @@
 	break;
       }
   
-  if (key && mixer_view == VIEW_CHANNELS)
+  if (key && 
+    ((mixer_view == VIEW_CHANNELS) ||
+    (mixer_view == VIEW_PLAYBACK) ||
+    (mixer_view == VIEW_CAPTURE)) )
     switch (key)
       {
       case KEY_RIGHT:
@@ -1955,7 +2004,7 @@
   if (old_view != mixer_view)
     mixer_clear (FALSE);
   
-  mixer_focus_elem = CLAMP (mixer_focus_elem, 0, mixer_n_elems - 1);
+  mixer_focus_elem = CLAMP (mixer_focus_elem, 0, mixer_n_view_elems - 1);
   
   return finished;
 }
@@ -2027,7 +2076,7 @@
   mixer_init ();
   mixer_reinit ();
   
-  if (mixer_n_elems == 0) {
+  if (mixer_n_view_elems == 0) {
     fprintf(stderr, "No mixer elems found\n");
     mixer_abort (ERR_NONE, "", 0);
   }
@@ -2060,6 +2109,8 @@
 	  switch (mixer_view)
 	    {
 	    case VIEW_CHANNELS:
+	    case VIEW_PLAYBACK:
+	    case VIEW_CAPTURE:
 	      mixer_update_cbars ();
 	      break;
 	    case VIEW_HELP:

             reply	other threads:[~2004-08-27 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-27 12:51 James Courtier-Dutton [this message]
2004-08-27 16:30 ` [PATCH] Change alsamixer to show different views. Playback controls, or Capture controls Takashi Iwai
2004-08-27 16:42   ` James Courtier-Dutton
2004-08-27 16:52     ` Takashi Iwai
2004-08-27 17:34       ` James Courtier-Dutton
2004-08-27 17:48         ` Takashi Iwai
2004-08-27 18:37           ` Lee Revell
2004-08-30  9:28             ` Takashi Iwai
2004-08-27 21:16           ` James Courtier-Dutton
2004-08-28  7:17       ` Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=412F2E4E.4080300@superbug.demon.co.uk \
    --to=james@superbug.demon.co.uk \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.