From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: play-sound-file & esd Date: Fri, 28 Apr 2006 23:50:21 -0400 Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1146282671 21057 80.91.229.2 (29 Apr 2006 03:51:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 29 Apr 2006 03:51:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 29 05:51:10 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FZgU9-0007Xn-OW for ged-emacs-devel@m.gmane.org; Sat, 29 Apr 2006 05:51:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FZgU9-0004K2-AC for ged-emacs-devel@m.gmane.org; Fri, 28 Apr 2006 23:51:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FZgTQ-00044r-62 for emacs-devel@gnu.org; Fri, 28 Apr 2006 23:50:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FZgTP-00044H-3b for emacs-devel@gnu.org; Fri, 28 Apr 2006 23:50:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FZgTO-000444-Vy for emacs-devel@gnu.org; Fri, 28 Apr 2006 23:50:23 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FZgWg-0002fL-7F for emacs-devel@gnu.org; Fri, 28 Apr 2006 23:53:46 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1FZgTN-0006S6-Uu; Fri, 28 Apr 2006 23:50:22 -0400 Original-To: sds@podval.org In-reply-to: (message from Sam Steingold on Tue, 25 Apr 2006 16:11:32 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:53577 Archived-At: Does this fix it? It compiles, but I have not tested it (I am not sure how). *** sound.c 07 Feb 2006 18:13:40 -0500 1.34 --- sound.c 28 Apr 2006 19:47:17 -0400 *************** *** 452,464 **** sound_cleanup (arg) Lisp_Object arg; { ! if (current_sound_device) ! { ! if (current_sound_device->close) ! current_sound_device->close (current_sound_device); ! if (current_sound->fd > 0) ! emacs_close (current_sound->fd); ! } return Qnil; } --- 452,463 ---- sound_cleanup (arg) Lisp_Object arg; { ! if (current_sound_device->close) ! current_sound_device->close (current_sound_device); ! if (current_sound->fd > 0) ! emacs_close (current_sound->fd); ! free (current_sound_device); ! free (current_sound); return Qnil; } *************** *** 991,998 **** #ifndef WINDOWSNT Lisp_Object file; struct gcpro gcpro1, gcpro2; - struct sound_device sd; - struct sound s; Lisp_Object args[2]; #else /* WINDOWSNT */ int len = 0; --- 990,995 ---- *************** *** 1010,1057 **** #ifndef WINDOWSNT file = Qnil; GCPRO2 (sound, file); ! bzero (&sd, sizeof sd); ! bzero (&s, sizeof s); ! current_sound_device = &sd; ! current_sound = &s; record_unwind_protect (sound_cleanup, Qnil); ! s.header = (char *) alloca (MAX_SOUND_HEADER_BYTES); if (STRINGP (attrs[SOUND_FILE])) { /* Open the sound file. */ ! s.fd = openp (Fcons (Vdata_directory, Qnil), ! attrs[SOUND_FILE], Qnil, &file, Qnil); ! if (s.fd < 0) sound_perror ("Could not open sound file"); /* Read the first bytes from the file. */ ! s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES); ! if (s.header_size < 0) sound_perror ("Invalid sound file header"); } else { ! s.data = attrs[SOUND_DATA]; ! s.header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (s.data)); ! bcopy (SDATA (s.data), s.header, s.header_size); } /* Find out the type of sound. Give up if we can't tell. */ ! find_sound_type (&s); /* Set up a device. */ if (STRINGP (attrs[SOUND_DEVICE])) { int len = SCHARS (attrs[SOUND_DEVICE]); ! sd.file = (char *) alloca (len + 1); ! strcpy (sd.file, SDATA (attrs[SOUND_DEVICE])); } if (INTEGERP (attrs[SOUND_VOLUME])) ! sd.volume = XFASTINT (attrs[SOUND_VOLUME]); else if (FLOATP (attrs[SOUND_VOLUME])) ! sd.volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; args[0] = Qplay_sound_functions; args[1] = sound; --- 1007,1056 ---- #ifndef WINDOWSNT file = Qnil; GCPRO2 (sound, file); ! current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); ! bzero (current_sound_device, sizeof (struct sound_device)); ! current_sound = (struct sound *) xmalloc (sizeof (struct sound)); ! bzero (current_sound, sizeof (struct sound)); record_unwind_protect (sound_cleanup, Qnil); ! current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); if (STRINGP (attrs[SOUND_FILE])) { /* Open the sound file. */ ! current_sound->fd = openp (Fcons (Vdata_directory, Qnil), ! attrs[SOUND_FILE], Qnil, &file, Qnil); ! if (current_sound->fd < 0) sound_perror ("Could not open sound file"); /* Read the first bytes from the file. */ ! current_sound->header_size ! = emacs_read (current_sound->fd, current_sound->header, ! MAX_SOUND_HEADER_BYTES); ! if (current_sound->header_size < 0) sound_perror ("Invalid sound file header"); } else { ! current_sound->data = attrs[SOUND_DATA]; ! current_sound->header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (current_sound->data)); ! bcopy (SDATA (current_sound->data), current_sound->header, current_sound->header_size); } /* Find out the type of sound. Give up if we can't tell. */ ! find_sound_type (current_sound); /* Set up a device. */ if (STRINGP (attrs[SOUND_DEVICE])) { int len = SCHARS (attrs[SOUND_DEVICE]); ! current_sound_device->file = (char *) alloca (len + 1); ! strcpy (current_sound_device->file, SDATA (attrs[SOUND_DEVICE])); } if (INTEGERP (attrs[SOUND_VOLUME])) ! current_sound_device->volume = XFASTINT (attrs[SOUND_VOLUME]); else if (FLOATP (attrs[SOUND_VOLUME])) ! current_sound_device->volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; args[0] = Qplay_sound_functions; args[1] = sound; *************** *** 1060,1086 **** /* There is only one type of device we currently support, the VOX sound driver. Set up the device interface functions for that device. */ ! vox_init (&sd); /* Open the device. */ ! sd.open (&sd); /* Play the sound. */ ! s.play (&s, &sd); ! ! /* Close the input file, if any. */ ! if (!STRINGP (s.data)) ! { ! emacs_close (s.fd); ! s.fd = -1; ! } ! ! /* Close the device. */ ! sd.close (&sd); /* Clean up. */ - current_sound_device = NULL; - current_sound = NULL; UNGCPRO; #else /* WINDOWSNT */ --- 1059,1073 ---- /* There is only one type of device we currently support, the VOX sound driver. Set up the device interface functions for that device. */ ! vox_init (current_sound_device); /* Open the device. */ ! current_sound_device->open (current_sound_device); /* Play the sound. */ ! current_sound->play (current_sound, current_sound_device); /* Clean up. */ UNGCPRO; #else /* WINDOWSNT */