New unwind-protect flavors to better type-check C callbacks.
[bpt/emacs.git] / src / sound.c
index e640dac..27e06b8 100644 (file)
@@ -325,15 +325,6 @@ sound_warning (const char *msg)
 }
 
 
-/* Return S's value as a string if S is a string, otherwise DEFAULT_VALUE.  */
-
-static char const *
-string_default (Lisp_Object s, char const *default_value)
-{
-  return STRINGP (s) ? SSDATA (s) : default_value;
-}
-
-
 /* Parse sound specification SOUND, and fill ATTRS with what is
    found.  Value is non-zero if SOUND Is a valid sound specification.
    A valid sound specification is a list starting with the symbol
@@ -426,6 +417,15 @@ parse_sound (Lisp_Object sound, Lisp_Object *attrs)
 /* BEGIN: Non Windows functions */
 #ifndef WINDOWSNT
 
+/* Return S's value as a string if S is a string, otherwise DEFAULT_VALUE.  */
+
+static char const *
+string_default (Lisp_Object s, char const *default_value)
+{
+  return STRINGP (s) ? SSDATA (s) : default_value;
+}
+
+
 /* Find out the type of the sound file whose file descriptor is FD.
    S is the sound file structure to fill in.  */
 
@@ -437,10 +437,10 @@ find_sound_type (struct sound *s)
 }
 
 
-/* Function installed by play-sound-internal with record_unwind_protect.  */
+/* Function installed by play-sound-internal with record_unwind_protect_void.  */
 
-static Lisp_Object
-sound_cleanup (Lisp_Object arg)
+static void
+sound_cleanup (void)
 {
   if (current_sound_device->close)
     current_sound_device->close (current_sound_device);
@@ -448,8 +448,6 @@ sound_cleanup (Lisp_Object arg)
     emacs_close (current_sound->fd);
   xfree (current_sound_device);
   xfree (current_sound);
-
-  return Qnil;
 }
 
 /***********************************************************************
@@ -879,7 +877,7 @@ vox_init (struct sound_device *sd)
 static void
 vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes)
 {
-  if (emacs_write (sd->fd, buffer, nbytes) != nbytes)
+  if (emacs_write_sig (sd->fd, buffer, nbytes) != nbytes)
     sound_perror ("Error writing to sound device");
 }
 
@@ -1335,7 +1333,6 @@ Internal use only, use `play-sound' instead.  */)
   char * psz_file = NULL;
   unsigned long ui_volume_tmp = UINT_MAX;
   unsigned long ui_volume = UINT_MAX;
-  int i_result = 0;
 #endif /* WINDOWSNT */
 
   /* Parse the sound specification.  Give up if it is invalid.  */
@@ -1347,13 +1344,13 @@ Internal use only, use `play-sound' instead.  */)
   GCPRO2 (sound, file);
   current_sound_device = xzalloc (sizeof *current_sound_device);
   current_sound = xzalloc (sizeof *current_sound);
-  record_unwind_protect (sound_cleanup, Qnil);
+  record_unwind_protect_void (sound_cleanup);
   current_sound->header = alloca (MAX_SOUND_HEADER_BYTES);
 
   if (STRINGP (attrs[SOUND_FILE]))
     {
       /* Open the sound file.  */
-      current_sound->fd = openp (Fcons (Vdata_directory, Qnil),
+      current_sound->fd = openp (list1 (Vdata_directory),
                                 attrs[SOUND_FILE], Qnil, &file, Qnil);
       if (current_sound->fd < 0)
        sound_perror ("Could not open sound file");
@@ -1430,7 +1427,7 @@ Internal use only, use `play-sound' instead.  */)
     {
       ui_volume = ui_volume_tmp * (UINT_MAX / 100);
     }
-  i_result = do_play_sound (psz_file, ui_volume);
+  do_play_sound (psz_file, ui_volume);
 
 #endif /* WINDOWSNT */