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

Bug#567394: unixcw leaves audio device volume muted on exit



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


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

The programs 'cw' or 'cwcp' accidentally leave the system audio device (mixer) volume muted when they exit.

TESTCASE:
1. Ensure that the system audio volume is not muted (e.g. with the gnome volume control applet).
2. In a terminal, run
      echo KA6MAL | cw
While listening to the Morse code audio output, notice the gnome volume control applet flashing its "muted" status along with the dits and dahs.
3. After the command returns to the shell prompt, notice that the gnome volume control applet has been left muted. The volume should have been restored.

Note: If the Morse code output is completely garbled (just long continuous tones) then you're experiencing bug LP: #511676 "unixcw sends incorrect characters".

ANALYSIS:
unixcw's 'cwlib' library works by manipulating the audio device (mixer) volume control -- switching the volume on and off to generate Morse code. This is the normal behavior of the 'cwlib' library.

The library does actually preserve the initial volume setting, but fails to restore it in some scenarios -- specifically, when it exits during it 10 second "keep the soundcard held" termination phase as occurs when piping input into 'cw' and when quitting 'cwcp' with F12. These programs just need to call cw_complete_reset() in all exit paths.

I think its possible that some systems' audio devices may *not* indicate a flashing volume control applet because 'cwlib' might find and uses a different volume mixer -- this bug is probably not reproducible on such systems.

-----

Attached patch fixes the problem.
#
#  * Restore audio device volume on exit (LP: #513576)
#    - src/cw/cw.c, src/cwcp/cwcp.c: call cw_complete_reset() at exit.
#
# -- Kamal Mostafa <kamal@whence.com>  Wed, 27 Jan 2010 19:40:14 -0800
#

=== modified file 'src/cw/cw.c'
--- a/src/cw/cw.c	2006-11-19 19:52:38 +0000
+++ b/src/cw/cw.c	2010-01-28 02:51:12 +0000
@@ -922,5 +922,9 @@
 
   /* Await final tone completion before exiting. */
   cw_wait_for_tone_queue ();
+
+  /* Reset to ensure that the mixer volume gets restored. */
+  cw_complete_reset();
+
   return EXIT_SUCCESS;
 }

=== modified file 'src/cwcp/cwcp.c'
--- a/src/cwcp/cwcp.c	2006-11-19 19:52:38 +0000
+++ b/src/cwcp/cwcp.c	2010-01-28 02:53:25 +0000
@@ -1625,6 +1625,9 @@
   /* Attempt to wrestle the screen back from curses. */
   interface_destroy ();
 
+  /* Reset to ensure that the mixer volume gets restored. */
+  cw_complete_reset();
+
   /* Show the signal caught, and exit. */
   fprintf (stderr, _("\nCaught signal %d, exiting...\n"), signal_number);
   exit (EXIT_SUCCESS);
@@ -1685,5 +1688,9 @@
   /* Clean up and return. */
   interface_destroy ();
   cw_wait_for_tone_queue ();
+
+  /* Reset to ensure that the mixer volume gets restored. */
+  cw_complete_reset();
+
   return EXIT_SUCCESS;
 }


Reply to: