aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sound.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/sound.c b/src/sound.c
index 51ebc70218a..323cdf59c61 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -198,7 +198,7 @@ enum sound_attr
198extern Lisp_Object QCfile; 198extern Lisp_Object QCfile;
199Lisp_Object QCvolume, QCdevice; 199Lisp_Object QCvolume, QCdevice;
200Lisp_Object Qsound; 200Lisp_Object Qsound;
201Lisp_Object Qplay_sound_hook; 201Lisp_Object Qplay_sound_functions;
202 202
203/* These are set during `play-sound' so that sound_cleanup has 203/* These are set during `play-sound' so that sound_cleanup has
204 access to them. */ 204 access to them. */
@@ -260,7 +260,8 @@ sound_perror (msg)
260 260
261 - `:volume VOL' 261 - `:volume VOL'
262 262
263 VOL must be an integer in the range 0..100. */ 263 VOL must be an integer in the range [0, 100], or a float in the
264 range [0, 1]. */
264 265
265static int 266static int
266parse_sound (sound, attrs) 267parse_sound (sound, attrs)
@@ -283,10 +284,19 @@ parse_sound (sound, attrs)
283 /* Volume must be in the range 0..100 or unspecified. */ 284 /* Volume must be in the range 0..100 or unspecified. */
284 if (!NILP (attrs[SOUND_VOLUME])) 285 if (!NILP (attrs[SOUND_VOLUME]))
285 { 286 {
286 if (!INTEGERP (attrs[SOUND_VOLUME])) 287 if (INTEGERP (attrs[SOUND_VOLUME]))
287 return 0; 288 {
288 if (XINT (attrs[SOUND_VOLUME]) < 0 289 if (XINT (attrs[SOUND_VOLUME]) < 0
289 || XINT (attrs[SOUND_VOLUME]) > 100) 290 || XINT (attrs[SOUND_VOLUME]) > 100)
291 return 0;
292 }
293 else if (FLOATP (attrs[SOUND_VOLUME]))
294 {
295 if (XFLOAT_DATA (attrs[SOUND_VOLUME]) < 0
296 || XFLOAT_DATA (attrs[SOUND_VOLUME]) > 1)
297 return 0;
298 }
299 else
290 return 0; 300 return 0;
291 } 301 }
292 302
@@ -383,8 +393,10 @@ DEFUN ("play-sound", Fplay_sound, Splay_sound, 1, 1, 0,
383 } 393 }
384 if (INTEGERP (attrs[SOUND_VOLUME])) 394 if (INTEGERP (attrs[SOUND_VOLUME]))
385 sd.volume = XFASTINT (attrs[SOUND_VOLUME]); 395 sd.volume = XFASTINT (attrs[SOUND_VOLUME]);
396 else if (FLOATP (attrs[SOUND_VOLUME]))
397 sd.volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100;
386 398
387 args[0] = Qplay_sound_hook; 399 args[0] = Qplay_sound_functions;
388 args[1] = sound; 400 args[1] = sound;
389 Frun_hook_with_args (make_number (2), args); 401 Frun_hook_with_args (make_number (2), args);
390 402
@@ -809,8 +821,8 @@ syms_of_sound ()
809 staticpro (&QCvolume); 821 staticpro (&QCvolume);
810 Qsound = intern ("sound"); 822 Qsound = intern ("sound");
811 staticpro (&Qsound); 823 staticpro (&Qsound);
812 Qplay_sound_hook = intern ("play-sound-hook"); 824 Qplay_sound_functions = intern ("play-sound-functions");
813 staticpro (&Qplay_sound_hook); 825 staticpro (&Qplay_sound_functions);
814 826
815 defsubr (&Splay_sound); 827 defsubr (&Splay_sound);
816} 828}