SystemSound.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. (*
  2. File: OSServices/SystemSound.h
  3. Contains: SystemSound include file
  4. Version: OSServices-97~320
  5. Copyright: © 2000-2005 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. *)
  10. { Pascal Translation: Peter N Lewis, <[email protected]>, 2005 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit SystemSound;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,Files,CFBase,CFRunLoop;
  92. {$ALIGN POWER}
  93. (* ================================================================================ *)
  94. (* Errors *)
  95. (* ================================================================================ *)
  96. const
  97. kSystemSoundNoError = 0;
  98. kSystemSoundUnspecifiedError = -1500;
  99. kSystemSoundClientTimedOutError = -1501;
  100. (* ================================================================================ *)
  101. (* Types *)
  102. (* ================================================================================ *)
  103. type
  104. SystemSoundActionID = UInt32;
  105. type
  106. SystemSoundCompletionProcPtr = function( actionID: SystemSoundActionID; userData: UnivPtr ): OSStatus;
  107. type
  108. SystemSoundCompletionUPP = SystemSoundCompletionProcPtr;
  109. (*
  110. * NewSystemSoundCompletionUPP()
  111. *
  112. * Availability:
  113. * Mac OS X: in version 10.3 and later in CoreServices.framework
  114. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  115. * Non-Carbon CFM: available as macro/inline
  116. *)
  117. function NewSystemSoundCompletionUPP( userRoutine: SystemSoundCompletionProcPtr ): SystemSoundCompletionUPP; external name '_NewSystemSoundCompletionUPP'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  118. (*
  119. * DisposeSystemSoundCompletionUPP()
  120. *
  121. * Availability:
  122. * Mac OS X: in version 10.3 and later in CoreServices.framework
  123. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  124. * Non-Carbon CFM: available as macro/inline
  125. *)
  126. procedure DisposeSystemSoundCompletionUPP( userUPP: SystemSoundCompletionUPP ); external name '_DisposeSystemSoundCompletionUPP'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  127. (*
  128. * InvokeSystemSoundCompletionUPP()
  129. *
  130. * Availability:
  131. * Mac OS X: in version 10.3 and later in CoreServices.framework
  132. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  133. * Non-Carbon CFM: available as macro/inline
  134. *)
  135. function InvokeSystemSoundCompletionUPP( actionID: SystemSoundActionID; userData: UnivPtr; userUPP: SystemSoundCompletionUPP ): OSStatus; external name '_InvokeSystemSoundCompletionUPP'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  136. (* ================================================================================ *)
  137. (* Public APIs *)
  138. (* ================================================================================ *)
  139. (*
  140. * AlertSoundPlay()
  141. *
  142. * Summary:
  143. * Play an Alert Sound
  144. *
  145. * Discussion:
  146. * Play the user's current alert sound, interrupting any previously
  147. * playing alert sound.
  148. *
  149. * Availability:
  150. * Mac OS X: in version 10.2 and later in CoreServices.framework
  151. * CarbonLib: not available in CarbonLib 1.x
  152. * Non-Carbon CFM: not available
  153. *)
  154. procedure AlertSoundPlay; external name '_AlertSoundPlay'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  155. (*
  156. * AlertSoundPlayCustomSound()
  157. *
  158. * Summary:
  159. * Play a User designated Alert Sound
  160. *
  161. * Discussion:
  162. * Play a sound, designated by a SystemSoundActionID, with the
  163. * behavior of AlertSoundPlay().
  164. *
  165. * Parameters:
  166. *
  167. * inAction:
  168. * A SystemSoundActionID indicating the desired Sound to be played
  169. * with AlertSound behavior.
  170. *
  171. * Availability:
  172. * Mac OS X: in version 10.3 and later in CoreServices.framework
  173. * CarbonLib: not available in CarbonLib 1.x
  174. * Non-Carbon CFM: not available
  175. *)
  176. procedure AlertSoundPlayCustomSound( inAction: SystemSoundActionID ); external name '_AlertSoundPlayCustomSound'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  177. (*
  178. * SystemSoundPlay()
  179. *
  180. * Summary:
  181. * Play a System Sound
  182. *
  183. * Discussion:
  184. * Immediately play the sound designated by actionID. Use for one
  185. * time actions that do not require a duration or modification
  186. * during playback. Sustain loops in the sound will be ignored.
  187. *
  188. * Parameters:
  189. *
  190. * inAction:
  191. * A SystemSoundActionID indicating the desired System Sound to be
  192. * played.
  193. *
  194. * Availability:
  195. * Mac OS X: in version 10.2 and later in CoreServices.framework
  196. * CarbonLib: not available in CarbonLib 1.x
  197. * Non-Carbon CFM: not available
  198. *)
  199. procedure SystemSoundPlay( inAction: SystemSoundActionID ); external name '_SystemSoundPlay'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  200. (*
  201. * SystemSoundGetActionID()
  202. *
  203. * Summary:
  204. * Create a 'custom' System Sound by providing an audio file.
  205. *
  206. * Discussion:
  207. * If the user wants to add a sound that can be played via
  208. * SystemSoundPlay(), an FSRef for an audio file can be passed and a
  209. * SystemSoundActionID, which can be passed to SystemSoundPlay() or
  210. * AlertSoundPlayCustomSound(), will be returned. It is important
  211. * that SystemSoundRemoveActionID() be called when the action is no
  212. * longer needed by the client application so the System Sound
  213. * Server can release any resources dedicated to the returned action
  214. * id.
  215. *
  216. * Parameters:
  217. *
  218. * userFile:
  219. * An const FSRef * for the audio file to be used as a System
  220. * Sound. Any audio file supported by the AudioFile APIs in the
  221. * AudioToolbox framework may be used.
  222. *
  223. * outAction:
  224. * If successful, a SystemSoundActionID will be returned, which in
  225. * turn can be passed to SystemSoundPlay().
  226. *
  227. * Availability:
  228. * Mac OS X: in version 10.2 and later in CoreServices.framework
  229. * CarbonLib: not available in CarbonLib 1.x
  230. * Non-Carbon CFM: not available
  231. *)
  232. function SystemSoundGetActionID( const (*var*) userFile: FSRef; var outAction: SystemSoundActionID ): OSStatus; external name '_SystemSoundGetActionID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  233. (*
  234. * SystemSoundRemoveActionID()
  235. *
  236. * Summary:
  237. * Remove a 'custom' System Sound.
  238. *
  239. * Discussion:
  240. * If the user no longer needs to use the custom system sound that
  241. * was created via SystemSoundGetActionID, this function should be
  242. * called so the SystemSoundServer can release resources that are no
  243. * longer needed.
  244. *
  245. * Parameters:
  246. *
  247. * inAction:
  248. * A SystemSoundActionID indicating the desired System Sound to be
  249. * removed.
  250. *
  251. * Availability:
  252. * Mac OS X: in version 10.2 and later in CoreServices.framework
  253. * CarbonLib: not available in CarbonLib 1.x
  254. * Non-Carbon CFM: not available
  255. *)
  256. function SystemSoundRemoveActionID( inAction: SystemSoundActionID ): OSStatus; external name '_SystemSoundRemoveActionID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  257. (*
  258. * SystemSoundSetCompletionRoutine()
  259. *
  260. * Summary:
  261. * Call the provided Completion Routine when the provided
  262. * SystemSoundActionID finishes playing in the server.
  263. *
  264. * Discussion:
  265. * Once set, the System Sound Server will send a message to the
  266. * System Sound Client indicating which SystemSoundActionID has
  267. * finished playing.
  268. *
  269. * Parameters:
  270. *
  271. * inAction:
  272. * The SystemSoundActionID that the completion routine will be
  273. * associated with.
  274. *
  275. * inRunLoop:
  276. * A CFRunLoopRef indicating the desired run loop the completion
  277. * routine should be run on. Pass NULL for the main run loop.
  278. *
  279. * inRunLoopMode:
  280. * A CFStringRef indicating the run loop mode for the runloop mode
  281. * for the runloop where the completion routine will be executed.
  282. * Pass NULL to use kCFRunLoopDefaultMode.
  283. *
  284. * inCompletionRoutine:
  285. * A SystemSoundCompletionProc for the completion routine proc to
  286. * be called when the provided SystemSoundActionID has completed
  287. * playing in the server.
  288. *
  289. * inUserData:
  290. * A void * to pass user data to the completion routine.
  291. *
  292. * Availability:
  293. * Mac OS X: in version 10.3 and later in CoreServices.framework
  294. * CarbonLib: not available in CarbonLib 1.x
  295. * Non-Carbon CFM: not available
  296. *)
  297. function SystemSoundSetCompletionRoutine( inAction: SystemSoundActionID; inRunLoop: CFRunLoopRef; inRunLoopMode: CFStringRef; inCompletionRoutine: SystemSoundCompletionUPP; inUserData: UnivPtr ): OSStatus; external name '_SystemSoundSetCompletionRoutine'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  298. (*
  299. * SystemSoundRemoveCompletionRoutine()
  300. *
  301. * Summary:
  302. * Remove the Completion Routine being used for the provided
  303. * SystemSoundActionID.
  304. *
  305. * Discussion:
  306. * To be called when it is no longer desired for the Completion
  307. * Routine to be called when a System Sound action has finished
  308. * playing.
  309. *
  310. * Parameters:
  311. *
  312. * inAction:
  313. * A SystemSoundActionID that currently has an associated
  314. * completion routine.
  315. *
  316. * Availability:
  317. * Mac OS X: in version 10.3 and later in CoreServices.framework
  318. * CarbonLib: not available in CarbonLib 1.x
  319. * Non-Carbon CFM: not available
  320. *)
  321. procedure SystemSoundRemoveCompletionRoutine( inAction: SystemSoundActionID ); external name '_SystemSoundRemoveCompletionRoutine'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  322. end.