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

Bug#567392: unixcw sends incorrect characters



Package: unixcw
Version: 2.3-13
Severity: important
Tags: patch


https://bugs.launchpad.net/ubuntu/+source/unixcw/+bug/511676

-----

[N7DR]
The unixcw program sends incorrect characters at the default speed (12 wpm).

Starting the program simply with the command "cw" (i.e., with no parameters), the program generates CW sounds, but the sounds do not match the characters typed on the keyboard, and in fact mostly do not match *any* letter or number.

For example, typing "T" generates a sound that sounds rather like an "R". Typing "h" creates a kind of "N" with a very long dash.

-----

[KA6MAL]
This bug in 'cwlib' is caused by the invalid use of a mixer ioctl on the soundcard audio device. For most audio devices, the invalid ioctl is harmless, but for some audio devices it prevents cwlib from properly switching the volume on and off (which is how it generates Morse code).

Attached patch fixes the problem by not trying invalid ioctl.
#
#  * Fix invalid ioctl which breaks CW output on some devices (LP: #511676).
#    - src/cwlib/cwlib.c: do not try to use mixer volume ioctl on audio device.
#
# -- Kamal Mostafa <kamal@whence.com>  Wed, 27 Jan 2010 19:40:14 -0800
#

=== modified file 'src/cwlib/cwlib.c'
--- a/src/cwlib/cwlib.c	2006-12-18 09:45:19 +0000
+++ b/src/cwlib/cwlib.c	2010-01-28 03:43:46 +0000
@@ -2138,6 +2138,18 @@
 {
   int read_volume, mixer, device_mask;
 
+/*
+ * [Kamal Mostafa <kamal@whence.com>]
+ * This attempt to use a mixer ioctl on the audio device is invalid!  I do not
+ * think that this ioctl could ever have worked.  Most audio devices will
+ * just return an error, allowing this routine to proceed to try the volume
+ * control methods on the (proper) mixer device.  However, some audio devices
+ * actually *do* have an ioctl (unrelated to volume control) corresponding to
+ * this ioctl number -- if they return 0, then this routine is tricked into
+ * thinking that it has set the volume when in fact it has not.
+ * https://bugs.launchpad.net/ubuntu/+source/unixcw/+bug/511676
+ */
+#if 0
   /* Try to use the main /dev/audio device for ioctls first. */
   if (ioctl (cw_sound_descriptor,
              MIXER_READ (SOUND_MIXER_PCM), &read_volume) == 0)
@@ -2145,6 +2157,7 @@
       *volume = read_volume;
       return RC_SUCCESS;
     }
+#endif
 
   /* Volume not found; try the mixer PCM channel volume instead. */
   mixer = open (cw_mixer_device, O_RDONLY | O_NONBLOCK);
@@ -2174,6 +2187,8 @@
 
       *volume = read_volume;
       close (mixer);
+      if (cw_is_debugging_internal (CW_DEBUG_KEYING))
+        fprintf(stderr, "cw: volume control is SOUND_MIXER_PCM\n");
       return RC_SUCCESS;
     }
   else
@@ -2191,6 +2206,8 @@
 
           *volume = read_volume;
           close (mixer);
+          if (cw_is_debugging_internal (CW_DEBUG_KEYING))
+            fprintf(stderr, "cw: volume control is SOUND_MIXER_VOLUME\n");
           return RC_SUCCESS;
         }
     }
@@ -2216,11 +2233,19 @@
 {
   int mixer, device_mask;
 
+/*
+ * [Kamal Mostafa <kamal@whence.com>]
+ * This attempt to use a mixer ioctl on the audio device is invalid!
+ * (see above).
+ */
+#if 0
   /* Try to use the main /dev/audio device for ioctls first. */
   if (ioctl (cw_sound_descriptor,
              MIXER_WRITE (SOUND_MIXER_PCM), &volume) == 0)
     return RC_SUCCESS;
 
+#endif
+
   /* Try the mixer PCM channel volume instead. */
   mixer = open (cw_mixer_device, O_RDWR | O_NONBLOCK);
   if (mixer == -1)


Reply to: