emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/src ChangeLog sound.c


From: Juanma Barranquero
Subject: [Emacs-diffs] emacs/src ChangeLog sound.c
Date: Mon, 12 Jan 2009 16:18:35 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Juanma Barranquero <lektu>      09/01/12 16:18:34

Modified files:
        src            : ChangeLog sound.c 

Log message:
        * sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
          (do_play_sound): Use it.  Don't pass a hardcoded buffer size to mci
          functions, use sizeof.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/ChangeLog?cvsroot=emacs&r1=1.7274&r2=1.7275
http://cvs.savannah.gnu.org/viewcvs/emacs/src/sound.c?cvsroot=emacs&r1=1.50&r2=1.51

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/src/ChangeLog,v
retrieving revision 1.7274
retrieving revision 1.7275
diff -u -b -r1.7274 -r1.7275
--- ChangeLog   12 Jan 2009 09:21:15 -0000      1.7274
+++ ChangeLog   12 Jan 2009 16:18:31 -0000      1.7275
@@ -1,3 +1,9 @@
+2009-01-12  Juanma Barranquero  <address@hidden>
+
+       * sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
+       (do_play_sound): Use it.  Don't pass a hardcoded buffer size to mci
+       functions, use sizeof.
+
 2009-01-12  Martin Rudalics  <address@hidden>
 
        * keyboard.c (read_char): Fix case where last_nonmenu_event

Index: sound.c
===================================================================
RCS file: /sources/emacs/emacs/src/sound.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- sound.c     8 Jan 2009 03:15:56 -0000       1.50
+++ sound.c     12 Jan 2009 16:18:34 -0000      1.51
@@ -1301,6 +1301,16 @@
 
 /* BEGIN: Windows specific functions */
 
+#define SOUND_WARNING(fun, error, text)                   \
+  {                                               \
+    char buf[1024];                               \
+    char err_string[MAXERRORLENGTH];              \
+    fun (error, err_string, sizeof (err_string));  \
+    snprintf (buf, sizeof (buf), "%s\nError: %s",  \
+             text, err_string);                   \
+    sound_warning (buf);                          \
+  }
+
 static int
 do_play_sound (psz_file, ui_volume)
      const char *psz_file;
@@ -1314,16 +1324,17 @@
   unsigned long ui_volume_org = 0;
   BOOL b_reset_volume = FALSE;
 
-  memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
-  memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
+  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
+  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
   sprintf (sz_cmd_buf,
            "open \"%s\" alias GNUEmacs_PlaySound_Device wait",
            psz_file);
-  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
+  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 
NULL);
   if (mci_error != 0)
     {
-      sound_warning ("The open mciSendString command failed to open\n"
-                     "the specified sound file");
+      SOUND_WARNING (mciGetErrorString, mci_error,
+                    "The open mciSendString command failed to open "
+                    "the specified sound file.");
       i_result = (int) mci_error;
       return i_result;
     }
@@ -1334,42 +1345,46 @@
         {
           b_reset_volume = TRUE;
           mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume);
-          if ( mm_result != MMSYSERR_NOERROR)
+          if (mm_result != MMSYSERR_NOERROR)
             {
-              sound_warning ("waveOutSetVolume failed to set the volume 
level\n"
+             SOUND_WARNING (waveOutGetErrorText, mm_result,
+                            "waveOutSetVolume failed to set the volume level "
                              "of the WAVE_MAPPER device.\n"
-                             "As a result, the user selected volume level 
will\n"
+                            "As a result, the user selected volume level will "
                              "not be used.");
             }
         }
       else
         {
-          sound_warning ("waveOutGetVolume failed to obtain the original\n"
+          SOUND_WARNING (waveOutGetErrorText, mm_result,
+                        "waveOutGetVolume failed to obtain the original "
                          "volume level of the WAVE_MAPPER device.\n"
-                         "As a result, the user selected volume level will\n"
+                         "As a result, the user selected volume level will "
                          "not be used.");
         }
     }
-  memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
-  memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
+  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
+  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
   strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait");
-  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
+  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 
NULL);
   if (mci_error != 0)
     {
-      sound_warning ("The play mciSendString command failed to play the\n"
+      SOUND_WARNING (mciGetErrorString, mci_error,
+                    "The play mciSendString command failed to play the "
                      "opened sound file.");
       i_result = (int) mci_error;
     }
-  memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
-  memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
+  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
+  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
   strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait");
-  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
+  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 
NULL);
   if (b_reset_volume == TRUE)
     {
-      mm_result=waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org);
+      mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org);
       if (mm_result != MMSYSERR_NOERROR)
         {
-          sound_warning ("waveOutSetVolume failed to reset the original 
volume\n"
+          SOUND_WARNING (waveOutGetErrorText, mm_result,
+                        "waveOutSetVolume failed to reset the original volume "
                          "level of the WAVE_MAPPER device.");
         }
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]