GNU bug report logs - #3351
23.0.93; OSX sound support

Previous Next

Package: emacs;

Reported by: Alex Schröder <kensanata <at> gmail.com>

Date: Fri, 22 May 2009 13:40:04 UTC

Severity: wishlist

To reply to this bug, email your comments to 3351 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3351; Package emacs. (Fri, 22 May 2009 13:40:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Schröder <kensanata <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 22 May 2009 13:40:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Alex Schröder <kensanata <at> gmail.com>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.93; OSX sound support
Date: Fri, 22 May 2009 15:31:44 +0200
In GNU Emacs 23.0.93.2 (i386-apple-darwin8.11.1, NS apple-appkit-824.48)
 of 2009-05-22 on Pyrobombus.local
Windowing system distributor `Apple', version 10.3.824
configured using `configure  '--with-ns''

I'm using Mac OS 10.4.11 and when I try to (play-sound '(sound :file
"/some/file")) I get the error "This Emacs binary lacks sound
support".

I think no Emacs is complete without sound support. ;)




bug reassigned from package `emacs' to `emacs,ns'. Request was from Glenn Morris <rgm+emacsbugs <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Wed, 17 Jun 2009 07:35:08 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#3351; Package emacs,ns. (Fri, 15 Mar 2013 10:28:01 GMT) Full text and rfc822 format available.

Message #10 received at 3351 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Alex Schröder <kensanata <at> gmail.com>
Cc: 3351 <at> debbugs.gnu.org
Subject: Re: bug#3351: 23.0.93; OSX sound support
Date: Fri, 15 Mar 2013 18:25:25 +0800
On 2009-05-22 21:31 +0800, Alex Schröder wrote:
> In GNU Emacs 23.0.93.2 (i386-apple-darwin8.11.1, NS apple-appkit-824.48)
>  of 2009-05-22 on Pyrobombus.local
> Windowing system distributor `Apple', version 10.3.824
> configured using `configure  '--with-ns''
>
> I'm using Mac OS 10.4.11 and when I try to (play-sound '(sound :file
> "/some/file")) I get the error "This Emacs binary lacks sound
> support".
>
> I think no Emacs is complete without sound support. ;)

I am using this small function to give me sound support on OSX:
https://raw.github.com/leoliu/play-sound-osx/master/play-sound.el

Two conscious abuses (can be fixed):

 - misuse (signal 'wrong-type-argument (list sound)); it requires the
   first item of DATA to be a predicate but I decided not to add another
   function.

 - async; should probably use call-process to stay close to the C
   version.

BTW, I only remember once in the past years needing the feature.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#3351; Package emacs,ns. (Sun, 17 Mar 2013 08:39:02 GMT) Full text and rfc822 format available.

Message #13 received at 3351 <at> debbugs.gnu.org (full text, mbox):

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: Alex Schröder <kensanata <at> gmail.com>,
	3351 <at> debbugs.gnu.org
Subject: Re: bug#3351: 23.0.93; OSX sound support
Date: Sun, 17 Mar 2013 17:36:31 +0900
>>>>> On Fri, 15 Mar 2013 18:25:25 +0800, Leo Liu <sdl.web <at> gmail.com> said:

> On 2009-05-22 21:31 +0800, Alex Schröder wrote:
>> In GNU Emacs 23.0.93.2 (i386-apple-darwin8.11.1, NS apple-appkit-824.48)
>> of 2009-05-22 on Pyrobombus.local
>> Windowing system distributor `Apple', version 10.3.824
>> configured using `configure  '--with-ns''
>> 
>> I'm using Mac OS 10.4.11 and when I try to (play-sound '(sound :file
>> "/some/file")) I get the error "This Emacs binary lacks sound
>> support".
>> 
>> I think no Emacs is complete without sound support. ;)

> I am using this small function to give me sound support on OSX:
> https://raw.github.com/leoliu/play-sound-osx/master/play-sound.el

> Two conscious abuses (can be fixed):

>  - misuse (signal 'wrong-type-argument (list sound)); it requires the
>    first item of DATA to be a predicate but I decided not to add another
>    function.

>  - async; should probably use call-process to stay close to the C
>    version.

> BTW, I only remember once in the past years needing the feature.

Below is a quick hack for the Mac port (*) to have sound support.
Perhaps one may use this as a hint.

*: http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00251.html

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp

=== modified file 'configure.ac'
*** configure.ac	2013-03-11 03:49:04 +0000
--- configure.ac	2013-03-17 08:17:26 +0000
***************
*** 2752,2757 ****
--- 2752,2758 ----
  ### Use Mac OS X GUI.
  if test "${HAVE_MACGUI}" = "yes"; then
    AC_DEFINE(HAVE_MACGUI, 1, [Define to 1 if you are using GUI on Mac OS X.])
+   AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
    AC_CHECK_HEADERS(AvailabilityMacros.h)
    MAC_CFLAGS="-fconstant-cfstrings"
    ## Specify the install directory

=== modified file 'src/macappkit.h'
*** src/macappkit.h	2013-02-09 07:26:28 +0000
--- src/macappkit.h	2013-03-17 08:17:26 +0000
***************
*** 61,66 ****
--- 61,67 ----
     compiled on Mac OS X 10.5 fails in startup at -[EmacsController
     methodSignatureForSelector:] when executed on Mac OS X 10.6.  */
  @protocol NSApplicationDelegate @end
+ @protocol NSSoundDelegate @end
  @protocol NSWindowDelegate @end
  @protocol NSToolbarDelegate @end
  @protocol NSMenuDelegate @end
***************
*** 194,199 ****
--- 195,203 ----
  
    /* Set of windows whose flush is deferred.  */
    NSMutableSet *deferredFlushWindows;
+ 
+   /* Set of sounds currently being played.  */
+   NSMutableSet *soundsBeingPlayed;
  }
  - (int)getAndClearMenuItemSelection;
  - (void)storeInputEvent:(id)sender;
***************
*** 691,696 ****
--- 695,704 ----
  
  #endif	/* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
  
+ @interface EmacsController (Sound) <NSSoundDelegate>
+ - (void)addAndPlaySound:(NSSound *)sound;
+ @end
+ 
  /* Some methods that are not declared in older versions.  Should be
     used with some runtime check such as `respondsToSelector:'. */
  
***************
*** 868,870 ****
--- 876,885 ----
  @end
  #endif
  #endif
+ 
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+ @interface NSSound (AvailableOn1050AndLater)
+ - (void)setVolume:(float)volume;
+ - (void)setPlaybackDeviceIdentifier:(NSString *)deviceUID;
+ @end
+ #endif

=== modified file 'src/macappkit.m'
*** src/macappkit.m	2013-03-05 06:19:19 +0000
--- src/macappkit.m	2013-03-17 08:20:12 +0000
***************
*** 12207,12209 ****
--- 12207,12270 ----
  
    return result;
  }
+ 
+ 
+ /***********************************************************************
+ 				Sound
+ ***********************************************************************/
+ @implementation EmacsController (Sound)
+ 
+ - (void)addAndPlaySound:(NSSound *)sound
+ {
+   if (soundsBeingPlayed == nil)
+     soundsBeingPlayed = [[NSMutableSet alloc] initWithCapacity:0];
+   [soundsBeingPlayed addObject:sound];
+ 
+   [sound setDelegate:self];
+   [sound play];
+ }
+ 
+ - (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finishedPlaying
+ {
+   [soundsBeingPlayed removeObject:sound];
+ }
+ 
+ @end
+ 
+ CFTypeRef
+ mac_sound_create (Lisp_Object file, Lisp_Object data)
+ {
+   NSSound *sound;
+ 
+   if (STRINGP (file))
+     {
+       file = ENCODE_FILE (file);
+       sound = [[NSSound alloc]
+ 		initWithContentsOfFile:[NSString stringWithUTF8LispString:file]
+ 			   byReference:YES];
+     }
+   else if (STRINGP (data))
+     sound = [[NSSound alloc]
+ 	      initWithData:[NSData dataWithBytes:(SDATA (data))
+ 					  length:(SBYTES (data))]];
+   else
+     sound = nil;
+ 
+   return CF_BRIDGING_RETAIN (MRC_AUTORELEASE (sound));
+ }
+ 
+ void
+ mac_sound_play (CFTypeRef mac_sound, Lisp_Object volume, Lisp_Object device)
+ {
+   NSSound *sound = (__bridge NSSound *) mac_sound;
+ 
+   if ((INTEGERP (volume) || FLOATP (volume))
+       && [sound respondsToSelector:@selector(setVolume:)])
+     [sound setVolume:(INTEGERP (volume) ? XFASTINT (volume) * 0.01
+ 		      : XFLOAT_DATA (volume))];
+   if (STRINGP (device)
+       && [sound respondsToSelector:@selector(setPlaybackDeviceIdentifier:)])
+     [sound setPlaybackDeviceIdentifier:[NSString stringWithLispString:device]];
+ 
+   [emacsController addAndPlaySound:sound];
+ }

=== modified file 'src/sound.c'
*** src/sound.c	2013-01-01 09:11:05 +0000
--- src/sound.c	2013-03-17 08:17:27 +0000
***************
*** 53,59 ****
  
  
  /* BEGIN: Non Windows Includes */
! #ifndef WINDOWSNT
  
  #include <sys/ioctl.h>
  
--- 53,59 ----
  
  
  /* BEGIN: Non Windows Includes */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  #include <sys/ioctl.h>
  
***************
*** 79,85 ****
  
  /* END: Non Windows Includes */
  
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows Specific Includes */
  #include <stdio.h>
--- 79,85 ----
  
  /* END: Non Windows Includes */
  
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows Specific Includes */
  #include <stdio.h>
***************
*** 88,94 ****
  #include <mmsystem.h>
  /* END: Windows Specific Includes */
  
! #endif /* WINDOWSNT */
  
  /* BEGIN: Common Definitions */
  
--- 88,97 ----
  #include <mmsystem.h>
  /* END: Windows Specific Includes */
  
! #else /* HAVE_MACGUI */
! #include "blockinput.h"
! #include "macterm.h"
! #endif /* HAVE_MACGUI */
  
  /* BEGIN: Common Definitions */
  
***************
*** 112,118 ****
  /* END: Common Definitions */
  
  /* BEGIN: Non Windows Definitions */
! #ifndef WINDOWSNT
  
  /* Structure forward declarations.  */
  
--- 115,121 ----
  /* END: Common Definitions */
  
  /* BEGIN: Non Windows Definitions */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  /* Structure forward declarations.  */
  
***************
*** 291,303 ****
  #endif
  
  /* END: Non Windows Definitions */
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows Specific Definitions */
  static int do_play_sound (const char *, unsigned long);
  /*
    END: Windows Specific Definitions */
! #endif /* WINDOWSNT */
  
  
  /***********************************************************************
--- 294,309 ----
  #endif
  
  /* END: Non Windows Definitions */
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows Specific Definitions */
  static int do_play_sound (const char *, unsigned long);
  /*
    END: Windows Specific Definitions */
! #else /* HAVE_MACGUI */
! extern CFTypeRef mac_sound_create (Lisp_Object, Lisp_Object);
! extern void mac_sound_play (CFTypeRef, Lisp_Object, Lisp_Object);
! #endif /* HAVE_MACGUI */
  
  
  /***********************************************************************
***************
*** 428,434 ****
  /* END: Common functions */
  
  /* BEGIN: Non Windows functions */
! #ifndef WINDOWSNT
  
  /* Find out the type of the sound file whose file descriptor is FD.
     S is the sound file structure to fill in.  */
--- 434,440 ----
  /* END: Common functions */
  
  /* BEGIN: Non Windows functions */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  /* Find out the type of the sound file whose file descriptor is FD.
     S is the sound file structure to fill in.  */
***************
*** 1247,1253 ****
  
  
  /* END: Non Windows functions */
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows specific functions */
  
--- 1253,1259 ----
  
  
  /* END: Non Windows functions */
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows specific functions */
  
***************
*** 1356,1361 ****
--- 1362,1370 ----
    Lisp_Object file;
    struct gcpro gcpro1, gcpro2;
    Lisp_Object args[2];
+ #ifdef HAVE_MACGUI
+   CFTypeRef mac_sound;
+ #endif
  #else /* WINDOWSNT */
    int len = 0;
    Lisp_Object lo_file = {0};
***************
*** 1369,1375 ****
    if (!parse_sound (sound, attrs))
      error ("Invalid sound specification");
  
! #ifndef WINDOWSNT
    file = Qnil;
    GCPRO2 (sound, file);
    current_sound_device = xzalloc (sizeof *current_sound_device);
--- 1378,1384 ----
    if (!parse_sound (sound, attrs))
      error ("Invalid sound specification");
  
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
    file = Qnil;
    GCPRO2 (sound, file);
    current_sound_device = xzalloc (sizeof *current_sound_device);
***************
*** 1435,1441 ****
    /* Clean up.  */
    UNGCPRO;
  
! #else /* WINDOWSNT */
  
    lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
    len = XSTRING (lo_file)->size;
--- 1444,1450 ----
    /* Clean up.  */
    UNGCPRO;
  
! #elif defined WINDOWSNT
  
    lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
    len = XSTRING (lo_file)->size;
***************
*** 1464,1470 ****
      }
    i_result = do_play_sound (psz_file, ui_volume);
  
! #endif /* WINDOWSNT */
  
    unbind_to (count, Qnil);
    return Qnil;
--- 1473,1513 ----
      }
    i_result = do_play_sound (psz_file, ui_volume);
  
! #else /* HAVE_MACGUI */
!   if (inhibit_window_system || noninteractive)
!     error ("Sound support on Mac requires a window system");
! 
!   file = Qnil;
!   GCPRO2 (sound, file);
! 
!   if (STRINGP (attrs[SOUND_FILE]))
!     {
!       /* Open the sound file.  */
!       int fd = openp (Fcons (Vdata_directory, Qnil),
! 		      attrs[SOUND_FILE], Qnil, &file, Qnil);
! 
!       if (fd < 0)
! 	error ("Could not open sound file: %s", strerror (errno));
!       emacs_close (fd);
!     }
! 
!   block_input ();
!   mac_sound = mac_sound_create (file, attrs[SOUND_DATA]);
!   unblock_input ();
!   if (mac_sound == NULL)
!     error ("Unknown sound format");
! 
!   args[0] = Qplay_sound_functions;
!   args[1] = sound;
!   Frun_hook_with_args (2, args);
! 
!   block_input ();
!   mac_sound_play (mac_sound, attrs[SOUND_VOLUME], attrs[SOUND_DEVICE]);
!   CFRelease (mac_sound);
!   unblock_input ();
! 
!   UNGCPRO;
! #endif /* HAVE_MACGUI */
  
    unbind_to (count, Qnil);
    return Qnil;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#3351; Package emacs,ns. (Mon, 18 Mar 2013 02:50:02 GMT) Full text and rfc822 format available.

Message #16 received at 3351 <at> debbugs.gnu.org (full text, mbox):

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: Alex Schröder <kensanata <at> gmail.com>,
	3351 <at> debbugs.gnu.org
Subject: Re: bug#3351: 23.0.93; OSX sound support
Date: Mon, 18 Mar 2013 11:47:46 +0900
>>>>> On Sun, 17 Mar 2013 17:36:31 +0900, YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> said:

>> Two conscious abuses (can be fixed):

>> - misuse (signal 'wrong-type-argument (list sound)); it requires the
>> first item of DATA to be a predicate but I decided not to add another
>> function.

>> - async; should probably use call-process to stay close to the C
>> version.

>> BTW, I only remember once in the past years needing the feature.

> Below is a quick hack for the Mac port (*) to have sound support.
> Perhaps one may use this as a hint.

> *: http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00251.html

Oops, I didn't realize that play-sound-internal was supposed to be
synchronous and unquittable.  Below is an updated one.

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp

=== modified file 'configure.ac'
*** configure.ac	2013-03-11 03:49:04 +0000
--- configure.ac	2013-03-18 02:36:18 +0000
***************
*** 2752,2757 ****
--- 2752,2758 ----
  ### Use Mac OS X GUI.
  if test "${HAVE_MACGUI}" = "yes"; then
    AC_DEFINE(HAVE_MACGUI, 1, [Define to 1 if you are using GUI on Mac OS X.])
+   AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
    AC_CHECK_HEADERS(AvailabilityMacros.h)
    MAC_CFLAGS="-fconstant-cfstrings"
    ## Specify the install directory

=== modified file 'src/macappkit.h'
*** src/macappkit.h	2013-02-09 07:26:28 +0000
--- src/macappkit.h	2013-03-18 02:36:18 +0000
***************
*** 61,66 ****
--- 61,67 ----
     compiled on Mac OS X 10.5 fails in startup at -[EmacsController
     methodSignatureForSelector:] when executed on Mac OS X 10.6.  */
  @protocol NSApplicationDelegate @end
+ @protocol NSSoundDelegate @end
  @protocol NSWindowDelegate @end
  @protocol NSToolbarDelegate @end
  @protocol NSMenuDelegate @end
***************
*** 691,696 ****
--- 692,700 ----
  
  #endif	/* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
  
+ @interface EmacsController (Sound) <NSSoundDelegate>
+ @end
+ 
  /* Some methods that are not declared in older versions.  Should be
     used with some runtime check such as `respondsToSelector:'. */
  
***************
*** 868,870 ****
--- 872,881 ----
  @end
  #endif
  #endif
+ 
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+ @interface NSSound (AvailableOn1050AndLater)
+ - (void)setVolume:(float)volume;
+ - (void)setPlaybackDeviceIdentifier:(NSString *)deviceUID;
+ @end
+ #endif

=== modified file 'src/macappkit.m'
*** src/macappkit.m	2013-03-05 06:19:19 +0000
--- src/macappkit.m	2013-03-18 02:36:41 +0000
***************
*** 12207,12209 ****
--- 12207,12263 ----
  
    return result;
  }
+ 
+ 
+ /***********************************************************************
+ 				Sound
+ ***********************************************************************/
+ @implementation EmacsController (Sound)
+ 
+ - (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finishedPlaying
+ {
+   [NSApp postDummyEvent];
+ }
+ 
+ @end
+ 
+ CFTypeRef
+ mac_sound_create (Lisp_Object file, Lisp_Object data)
+ {
+   NSSound *sound;
+ 
+   if (STRINGP (file))
+     {
+       file = ENCODE_FILE (file);
+       sound = [[NSSound alloc]
+ 		initWithContentsOfFile:[NSString stringWithUTF8LispString:file]
+ 			   byReference:YES];
+     }
+   else if (STRINGP (data))
+     sound = [[NSSound alloc]
+ 	      initWithData:[NSData dataWithBytes:(SDATA (data))
+ 					  length:(SBYTES (data))]];
+   else
+     sound = nil;
+ 
+   return CF_BRIDGING_RETAIN (MRC_AUTORELEASE (sound));
+ }
+ 
+ void
+ mac_sound_play (CFTypeRef mac_sound, Lisp_Object volume, Lisp_Object device)
+ {
+   NSSound *sound = (__bridge NSSound *) mac_sound;
+ 
+   if ((INTEGERP (volume) || FLOATP (volume))
+       && [sound respondsToSelector:@selector(setVolume:)])
+     [sound setVolume:(INTEGERP (volume) ? XFASTINT (volume) * 0.01
+ 		      : XFLOAT_DATA (volume))];
+   if (STRINGP (device)
+       && [sound respondsToSelector:@selector(setPlaybackDeviceIdentifier:)])
+     [sound setPlaybackDeviceIdentifier:[NSString stringWithLispString:device]];
+ 
+   [sound setDelegate:emacsController];
+   [sound play];
+   while ([sound isPlaying])
+     mac_run_loop_run_once (kEventDurationForever);
+ }

=== modified file 'src/macterm.h'
*** src/macterm.h	2013-02-09 07:26:28 +0000
--- src/macterm.h	2013-03-18 02:36:18 +0000
***************
*** 652,657 ****
--- 652,660 ----
  extern void mac_invalidate_frame_cursor_rects (struct frame *f);
  extern int mac_webkit_supports_svg_p (void);
  
+ extern CFTypeRef mac_sound_create (Lisp_Object, Lisp_Object);
+ extern void mac_sound_play (CFTypeRef, Lisp_Object, Lisp_Object);
+ 
  #define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, gc)	\
    CGContextSetFillColorWithColor (context, (gc)->cg_fore_color)
  #define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, gc)	\

=== modified file 'src/sound.c'
*** src/sound.c	2013-01-01 09:11:05 +0000
--- src/sound.c	2013-03-18 02:36:18 +0000
***************
*** 53,59 ****
  
  
  /* BEGIN: Non Windows Includes */
! #ifndef WINDOWSNT
  
  #include <sys/ioctl.h>
  
--- 53,59 ----
  
  
  /* BEGIN: Non Windows Includes */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  #include <sys/ioctl.h>
  
***************
*** 79,85 ****
  
  /* END: Non Windows Includes */
  
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows Specific Includes */
  #include <stdio.h>
--- 79,85 ----
  
  /* END: Non Windows Includes */
  
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows Specific Includes */
  #include <stdio.h>
***************
*** 88,94 ****
  #include <mmsystem.h>
  /* END: Windows Specific Includes */
  
! #endif /* WINDOWSNT */
  
  /* BEGIN: Common Definitions */
  
--- 88,97 ----
  #include <mmsystem.h>
  /* END: Windows Specific Includes */
  
! #else /* HAVE_MACGUI */
! #include "blockinput.h"
! #include "macterm.h"
! #endif /* HAVE_MACGUI */
  
  /* BEGIN: Common Definitions */
  
***************
*** 112,118 ****
  /* END: Common Definitions */
  
  /* BEGIN: Non Windows Definitions */
! #ifndef WINDOWSNT
  
  /* Structure forward declarations.  */
  
--- 115,121 ----
  /* END: Common Definitions */
  
  /* BEGIN: Non Windows Definitions */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  /* Structure forward declarations.  */
  
***************
*** 291,297 ****
  #endif
  
  /* END: Non Windows Definitions */
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows Specific Definitions */
  static int do_play_sound (const char *, unsigned long);
--- 294,300 ----
  #endif
  
  /* END: Non Windows Definitions */
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows Specific Definitions */
  static int do_play_sound (const char *, unsigned long);
***************
*** 428,434 ****
  /* END: Common functions */
  
  /* BEGIN: Non Windows functions */
! #ifndef WINDOWSNT
  
  /* Find out the type of the sound file whose file descriptor is FD.
     S is the sound file structure to fill in.  */
--- 431,437 ----
  /* END: Common functions */
  
  /* BEGIN: Non Windows functions */
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
  
  /* Find out the type of the sound file whose file descriptor is FD.
     S is the sound file structure to fill in.  */
***************
*** 1247,1253 ****
  
  
  /* END: Non Windows functions */
! #else /* WINDOWSNT */
  
  /* BEGIN: Windows specific functions */
  
--- 1250,1256 ----
  
  
  /* END: Non Windows functions */
! #elif defined WINDOWSNT
  
  /* BEGIN: Windows specific functions */
  
***************
*** 1356,1361 ****
--- 1359,1367 ----
    Lisp_Object file;
    struct gcpro gcpro1, gcpro2;
    Lisp_Object args[2];
+ #ifdef HAVE_MACGUI
+   CFTypeRef mac_sound;
+ #endif
  #else /* WINDOWSNT */
    int len = 0;
    Lisp_Object lo_file = {0};
***************
*** 1369,1375 ****
    if (!parse_sound (sound, attrs))
      error ("Invalid sound specification");
  
! #ifndef WINDOWSNT
    file = Qnil;
    GCPRO2 (sound, file);
    current_sound_device = xzalloc (sizeof *current_sound_device);
--- 1375,1381 ----
    if (!parse_sound (sound, attrs))
      error ("Invalid sound specification");
  
! #if !defined WINDOWSNT && !defined HAVE_MACGUI
    file = Qnil;
    GCPRO2 (sound, file);
    current_sound_device = xzalloc (sizeof *current_sound_device);
***************
*** 1435,1441 ****
    /* Clean up.  */
    UNGCPRO;
  
! #else /* WINDOWSNT */
  
    lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
    len = XSTRING (lo_file)->size;
--- 1441,1447 ----
    /* Clean up.  */
    UNGCPRO;
  
! #elif defined WINDOWSNT
  
    lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
    len = XSTRING (lo_file)->size;
***************
*** 1464,1470 ****
      }
    i_result = do_play_sound (psz_file, ui_volume);
  
! #endif /* WINDOWSNT */
  
    unbind_to (count, Qnil);
    return Qnil;
--- 1470,1515 ----
      }
    i_result = do_play_sound (psz_file, ui_volume);
  
! #else /* HAVE_MACGUI */
!   if (inhibit_window_system || noninteractive)
!     error ("Sound support on Mac requires a window system");
! 
!   file = Qnil;
!   GCPRO2 (sound, file);
! 
!   if (STRINGP (attrs[SOUND_FILE]))
!     {
!       /* Open the sound file.  */
!       int fd = openp (Fcons (Vdata_directory, Qnil),
! 		      attrs[SOUND_FILE], Qnil, &file, Qnil);
! 
!       if (fd < 0)
! 	{
! 	  if (errno == 0)
! 	    error ("Could not open sound file");
! 	  else
! 	    error ("Could not open sound file: %s", strerror (errno));
! 	}
!       emacs_close (fd);
!     }
! 
!   block_input ();
!   mac_sound = mac_sound_create (file, attrs[SOUND_DATA]);
!   unblock_input ();
!   if (mac_sound == NULL)
!     error ("Unknown sound format");
! 
!   args[0] = Qplay_sound_functions;
!   args[1] = sound;
!   Frun_hook_with_args (2, args);
! 
!   block_input ();
!   mac_sound_play (mac_sound, attrs[SOUND_VOLUME], attrs[SOUND_DEVICE]);
!   CFRelease (mac_sound);
!   unblock_input ();
! 
!   UNGCPRO;
! #endif /* HAVE_MACGUI */
  
    unbind_to (count, Qnil);
    return Qnil;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#3351; Package emacs,ns. (Mon, 18 Mar 2013 06:49:02 GMT) Full text and rfc822 format available.

Message #19 received at 3351 <at> debbugs.gnu.org (full text, mbox):

From: Jan Djärv <jan.h.d <at> swipnet.se>
To: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Cc: Alex Schröder <kensanata <at> gmail.com>,
	Leo Liu <sdl.web <at> gmail.com>, 3351 <at> debbugs.gnu.org
Subject: Re: bug#3351: 23.0.93; OSX sound support
Date: Mon, 18 Mar 2013 07:47:03 +0100
Hello.

18 mar 2013 kl. 03:47 skrev YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>:
> 
> Oops, I didn't realize that play-sound-internal was supposed to be
> synchronous and unquittable.  Below is an updated one.
> 

I don't think that is a requirement.  It is just an artifact of current implementations.
It would be better if all sound implementations where asynchronous and quittable.

	Jan D.






Severity set to 'wishlist' from 'normal' Request was from Alan Third <alan <at> idiocy.org> to control <at> debbugs.gnu.org. (Sun, 10 Jul 2016 14:48:01 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 339 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.