chp-operation.sgml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. <chapter id="oal-operation">
  2. <title>&OAL; Operation</title>
  3. <sect1>
  4. <title>&OAL; Fundamentals</title>
  5. <para>
  6. &OAL; (henceforth, the "&AL;") is concerned only with rendering audio
  7. into an output buffer,
  8. and primarily meant for spatialized audio.
  9. There is no support for reading audio input from buffers at this
  10. time, and no support for MIDI and other components usually
  11. associated with audio hardware. Programmers must relay on other
  12. mechanisms to obtain audio (e.g. voice) input or generate music.
  13. </para>
  14. <para>
  15. The &AL; has three fundamental primitives or objects -- Buffers, Sources,
  16. and a single Listener. Each object can be changed independently,
  17. the setting of one object does not affect the setting of others.
  18. The application can also set modes that affect processing. Modes
  19. are set, objects specified, and other &AL; operations performed
  20. by sending commands in the form of function or procedure calls.
  21. </para><para>
  22. Sources store locations, directions, and other attributes of an object in 3D
  23. space and have a buffer associated with them for playback. There are
  24. normally far more sources defined than buffers. When the program wants to play
  25. a sound, it controls execution through a source object. Sources are
  26. processed independently from each other.
  27. </para><para>
  28. Buffers store compressed or un-compressed audio data. It is common to
  29. initialize a large set of buffers when the program first starts (or at
  30. non-critical times during execution -- between levels in a game, for instance).
  31. Buffers are referred to by Sources. Data (audio sample data) is associated
  32. with buffers.
  33. </para><para>
  34. There is only one listener (per audio context). The listener attributes are
  35. similar to source attributes, but are used to represent where the user is
  36. hearing the audio from. The influence of all the sources from the
  37. perspective of the listener is mixed and played for the user.
  38. </para>
  39. <![ %RFC [
  40. <note id="rfc-bk000926-03"><title>RFC: Data Binding</title><para>
  41. Have to specifiy when pointer arguments are dereferenced.
  42. </para></note>
  43. ]]>
  44. <sect2>
  45. <title>Primitive Types</title>
  46. <para>
  47. As &AL; is meant to allow for seamless integration with &OGL; code
  48. if needed, the &AL; primitive (scalar) data types mimic the
  49. &OGL; data types. Guaranteed minimum sizes are stated for &OGL;
  50. data types (see table 2.2 of the &OGL; 1.2 Specification), but
  51. the actual choice of C datatype is left to the implementation.
  52. All implementations on a given binary architecture, however, must
  53. use a common definition of these datatypes.
  54. </para>
  55. <![ %RFC [
  56. <note><title>RFC/000507:</title><para>
  57. ALlong/ALulong are omitted from the Linux OpenGL Base ABI,
  58. and the GL specification. Do we want to go ahead on this,
  59. or trail GL? Do we include non-i386 architectures to list
  60. sizes explicitely. I.e. do we make the ABI part of our
  61. mandate?
  62. </para></note>
  63. ]]>
  64. <para>
  65. Note that this table uses explicit AL prefixes for clarity,
  66. while they might be omitted from the rest of the document
  67. for brevity. GCC equivalents are given for IA32, i.e. a
  68. portable and widely available compiler on the most common
  69. target architecture.
  70. <table>
  71. <title>&AL; Primitive Data Types</title>
  72. <tgroup cols="4" align="left" colsep=1 rowsep=1>
  73. <colspec colname=c1>
  74. <colspec colname=c2>
  75. <thead>
  76. <row>
  77. <entry>AL Type</>
  78. <entry>Description</>
  79. <entry>GL Type</>
  80. <entry>GCC IA32</entry>
  81. </row>
  82. </thead>
  83. <tbody>
  84. <row>
  85. <entry> ALboolean </entry>
  86. <entry> 8-bit boolean </entry>
  87. <entry> GLboolean </entry>
  88. <entry> unsigned char </entry>
  89. </row>
  90. <row>
  91. <entry> ALbyte </entry>
  92. <entry> signed 8-bit 2's-complement integer </entry>
  93. <entry> GLbyte </entry>
  94. <entry> signed char </entry>
  95. </row>
  96. <row >
  97. <entry> ALubyte </entry>
  98. <entry> unsigned 8-bit integer </entry>
  99. <entry> GLubyte </entry>
  100. <entry> unsigned char </entry>
  101. </row>
  102. <row>
  103. <entry> ALshort </entry>
  104. <entry> signed 16-bit 2's-complement integer </entry>
  105. <entry> GLshort </entry>
  106. <entry> short </entry>
  107. </row
  108. <row>
  109. <entry> ALushort </entry>
  110. <entry> unsigned 16-bit integer </entry>
  111. <entry> GLushort </entry>
  112. <entry> unsigned short </entry>
  113. </row>
  114. <row>
  115. <entry> ALint </entry>
  116. <entry> signed 32-bit 2's-complement integer </entry>
  117. <entry> GLint </entry>
  118. <entry> int </entry>
  119. </row>
  120. <row>
  121. <entry> ALuint </entry>
  122. <entry> unsigned 32-bit integer </entry>
  123. <entry> GLuint </entry>
  124. <entry> unsigned int </entry>
  125. </row>
  126. <![ %RFC [
  127. <row>
  128. <entry> ALlong </entry>
  129. <entry> signed 64-bit 2's-complement integer </entry>
  130. <entry> n/a </entry>
  131. <entry> long long </entry>
  132. </row>
  133. <row>
  134. <entry> ALulong </entry>
  135. <entry> unsigned 64-bit integer </entry>
  136. <entry> n/a </entry>
  137. <entry> unsigned long long </entry>
  138. </row>
  139. ]]>
  140. <row>
  141. <entry> ALsizei </entry>
  142. <entry> non-negative 32-bit binary integer size </entry>
  143. <entry> GLsizei </entry>
  144. <entry> int </entry>
  145. </row>
  146. <row>
  147. <entry> ALenum </entry>
  148. <entry> enumerated 32-bit value </entry>
  149. <entry> GLenum </entry>
  150. <entry> unsigned int </entry>
  151. </row>
  152. <row>
  153. <entry> ALbitfield </entry>
  154. <entry> 32 bit bitfield </entry>
  155. <entry> GLbitfield </entry>
  156. <entry> unsigned int </entry>
  157. </row>
  158. <row>
  159. <entry> ALfloat </entry>
  160. <entry> 32-bit IEEE754 floating-point </entry>
  161. <entry> GLfloat </entry>
  162. <entry> float </entry>
  163. </row>
  164. <row>
  165. <entry> ALclampf </entry>
  166. <entry> Same as ALfloat, but in range [0, 1] </entry>
  167. <entry> GLclampf </entry>
  168. <entry> float </entry>
  169. </row>
  170. <row>
  171. <entry> ALdouble </entry>
  172. <entry> 64-bit IEEE754 floating-point </entry>
  173. <entry> GLdouble </entry>
  174. <entry> double </entry>
  175. </row>
  176. <row>
  177. <entry> ALclampd </entry>
  178. <entry> Same as ALdouble, but in range [0, 1] </entry>
  179. <entry> GLclampd </entry>
  180. <entry> double </entry>
  181. </row>
  182. </tbody>
  183. </tgroup>
  184. </table>
  185. </para>
  186. <![ %Annote [
  187. <note><title>Annotation on Type Sizes</title><para>
  188. It would be desirable to guarantee the bit size of &AL; data
  189. types, but this might affect the mapping to &OGL; types
  190. for which the &OGL; specification only guarantees a minimum
  191. size.
  192. </para></note>
  193. <note><title>Annotation on 64bit integral</title><para>
  194. It would be desirable to define ulong and long, but again
  195. we defer to &OGL; in this decision.
  196. </para></note>
  197. <note><title>Annotation on Enumeration</title><para>
  198. &enum; is not a C or C++ enumeration, but implemented as
  199. C preprocesor defines. This makes it easier to handle
  200. extensions to the &AL; namespace, in particular in
  201. dealing with delays in distributing updated reference
  202. headers.
  203. </para></note>
  204. ]]>
  205. </sect2>
  206. <sect2>
  207. <title>Floating-Point Computation</title>
  208. <para>
  209. Any representable floating-point value is legal as input
  210. to a &AL; command that requires floating point data.
  211. The result of providing a value that is not a floating
  212. point number to such a command is unspecified, but must not
  213. lead to &AL; interruption or termination. In IEEE arithmetic,
  214. for example, providing a negative zero or a denormalized
  215. number to a GL command yields predictable results, while
  216. providing an NaN or infinity yields unspecified results.
  217. </para><para>
  218. Some calculations require division. In such cases (including
  219. implied divisions required by vector normalizations), a
  220. division by zero produces an unspecified result but must
  221. not lead to GL interruption or termination.
  222. </para>
  223. </sect2>
  224. </sect1>
  225. <sect1>
  226. <title>AL State</title>
  227. <para>
  228. The &AL; maintains considerable state. This documents enumerates
  229. each state variable and describes how each variable can be
  230. changed. For purposes of discussion, state variables are
  231. categorized somewhat arbitrarily by their function. For example,
  232. although we describe operations that the &AL; performs on the
  233. implied output buffer, the outbut buffer is not part of the
  234. &AL; state. Certain states of &AL; objects (e.g. buffer states
  235. with respect to queueing) are introduced for discussion purposes,
  236. but not exposed through the API.
  237. </para>
  238. </sect1>
  239. <sect1>
  240. <title>AL Command Syntax</title>
  241. <para>
  242. &AL; commands are functions or procedures. Various groups of
  243. commands perform the same operation but differ in how
  244. arguments are supplied to them. To conveniently accomodate
  245. this variation, we adopt the &OGL; nnotation for describing
  246. commands and their arguments.
  247. </para>
  248. <![ %Annote [
  249. <note><title>Annotation (Not all types supported yet)</title><para>
  250. At this time &AL; does not support the full flexibility that
  251. &OGL; offers. Certain entry points are supported only for
  252. some data types. In general, &AL; tends to use less entry
  253. points, using setter commands that use the same tokens
  254. as the matching query commands.
  255. </para></note>
  256. ]]>
  257. </sect1>
  258. <sect1>
  259. <title>Basic AL Operation</title>
  260. <para>
  261. &AL; can be used for a variety of audio playback tasks, and is an
  262. excellent complement to &OGL; for real-time rendering. A programmer who is
  263. familiar with &OGL; will immediately notice the similarities between the
  264. two APIs in that they describe their 3D environments using similar methods.
  265. </para>
  266. <para>
  267. For an &OGL;/&AL; program, most of the audio programming will be in two
  268. places in the code: initialization of the program, and the rendering loop.
  269. An &OGL;/&AL; program will typically contain a section where the graphics and
  270. audio systems are initialized, although it may be spread into multiple functions.
  271. For OpenAL, initialization normally consists of creating a context, creating
  272. the initial set of buffers, loading the buffers with sample data, creating
  273. sources, attaching buffers to sources, setting locations and directions for
  274. the listener and sources, and setting the initial values for state global
  275. to &AL;.
  276. </para>
  277. <example>
  278. <title>Initialization Example</title>
  279. <para>
  280. &sample.c;
  281. </para>
  282. <programlisting>
  283. </programlisting>
  284. </example>
  285. <![ %Example [
  286. <example>
  287. <title>Initialization Example</title>
  288. <programlisting>
  289. &ExInitAL.c;
  290. </programlisting>
  291. </example>
  292. ]]>
  293. <para>
  294. The audio update within
  295. the rendering loop normally consists of telling &AL; the current locations
  296. of the sources and listener, updating the environment settings, and managing
  297. buffers.
  298. </para>
  299. <![ %Example [
  300. <example>
  301. <title>Processing Loop</title>
  302. <programlisting>
  303. // PlaceCamera -- places OpenGL camera and updates OpenAL listener position and source state
  304. void 3DEnvironemnt:PlaceCamera()
  305. {
  306. // update OpenGL camera position
  307. glMatrixMode(GL_PROJECTION);
  308. glLoadIdentity();
  309. glFrustum(-0.1333, 0.1333, -0.1, 0.1, 0.2, 50.0);
  310. gluLookAt(listenerPos[0], listenerPos[1], listenerPos[2],
  311. (listenerPos[0] + sin(listenerAngle)), listenerPos[1], (listenerPos[2] - cos(listenerAngle)),
  312. 0.0, 1.0, 0.0);
  313. // OpenAL stuff...
  314. // place listener at camera
  315. alListener3f(AL_POSITION, listenerPos[0], listenerPos[1], listenerPos[2]);
  316. float directionvect[6];
  317. directionvect[0] = (float) sin(listenerAngle);
  318. directionvect[1] = 0;
  319. directionvect[2] = (float) cos(listenerAngle);
  320. directionvect[3] = 0;
  321. directionvect[4] = 1;
  322. directionvect[5] = 0;
  323. alListenerfv(AL_ORIENTATION, directionvect);
  324. // play phasor if in range, else stop playback
  325. if (range() < 9)
  326. {
  327. alSourcePlay(source[1]);
  328. } else
  329. {
  330. alSourceStop(source[1]);
  331. }
  332. }
  333. </programlisting>
  334. </example>
  335. ]]>
  336. </sect1>
  337. <sect1 id="errors">
  338. <title>AL Errors</title>
  339. <para>
  340. The AL detects only a subset of those conditions that could be
  341. considered errors. This is because in many cases error checking
  342. would adversely impact the performance of an error-free program.
  343. The command
  344. <funcsynopsis><funcprototype>
  345. <funcdef> &enum; <function> GetError </function></funcdef>
  346. <void>
  347. </funcprototype></funcsynopsis>
  348. is used to obtain error information. Each detectable error is
  349. assigned a numeric code. When an error is detected by AL,
  350. a flag is set and the error code is recorded. Further errors,
  351. if they occur, do not affect this recorded code. When GetError
  352. is called, the code is returned and the flag is cleared, so that
  353. a further error will again record its code. If a call to GetError
  354. returns NO_ERROR then there has been no detectable error since
  355. the last call to GetError (or since the AL was initialized).
  356. </para>
  357. <![ %RFC [
  358. <note id="rfc-bk000926-04"><title>RFC: GL distributed error </title><para>
  359. To allow for distributed implementations there may be several
  360. flag/code pairs. In this case, after a call to GetError returns a
  361. value other than NO_ERROR each subsequent call returns the
  362. non-NO_ERROR code of another distinct flag-code pair (in
  363. unspecified order), until all NO_ERROR codes have been returned.
  364. When there are no more non-NO_ERROR codes, all flags be reset.
  365. The initial state of all flags is cleared and the initial value
  366. of all codes is NO_ERROR.
  367. </para></note>
  368. <note><title>Annotation (Looping GetError)</title><para>
  369. &AL; applications are advised to loop calls of GetError to
  370. make sure that all flags are reset. Only the first error
  371. occurence for each flag/code pair is recorded, subsequent
  372. errors are ignored. The result of a repeated GetError call
  373. is not a stack trace or LIFO sequence. All error handling
  374. is context specific.
  375. </para></note>
  376. ]]>
  377. <![ %Annote [
  378. <note><title>Annotation (Only First Error)</title><para>
  379. Like &OGL; &AL; will ignore subsequent errors once an
  380. error conditation has been encountered.
  381. </para></note>
  382. ]]>
  383. <para>
  384. Error codes can be mapped to strings. The GetString function
  385. returns a pointer to a constant (literal) string that is
  386. identical to the identifier used for the enumeration value,
  387. as defined in the specification.
  388. </para>
  389. <![ %Annote [
  390. <note><title>Annotation/ Verbose Error String</title><para>
  391. There is no need to maintain a separate GetErrorString
  392. function (inspired by the proposed gluGetErrorStrings)
  393. as the existing GetString entry point can be used.
  394. </para></note>
  395. ]]>
  396. <para>
  397. <table>
  398. <title>Error Conditions</title>
  399. <tgroup cols="2" align="left" colsep=1 rowsep=1>
  400. <colspec colname=c1>
  401. <colspec colname=c2>
  402. <thead>
  403. <row>
  404. <entry>Name</>
  405. <entry>Description</>
  406. </row>
  407. </thead>
  408. <tbody>
  409. <row>
  410. <entry>NO_ERROR</>
  411. <entry>"No Error" token.</>
  412. </row>
  413. <row>
  414. <entry>INVALID_NAME</>
  415. <entry>Invalid Name parameter.</>
  416. </row>
  417. <row>
  418. <entry>INVALID_ENUM</>
  419. <entry>Invalid parameter.</>
  420. </row>
  421. <row>
  422. <entry>INVALID_VALUE</>
  423. <entry>Invalid enum parameter value.</>
  424. </row>
  425. <row>
  426. <entry>INVALID_OPERATION</>
  427. <entry>Illegal call.</>
  428. </row>
  429. <row>
  430. <entry>OUT_OF_MEMORY</>
  431. <entry>Unable to allocate memory.</>
  432. </row>
  433. </tbody>
  434. </tgroup>
  435. </table>
  436. The table summarizes the AL errors. Currently, when an error flag
  437. is set, results of AL operations are undefined only if OUT_OF_MEMORY
  438. has occured. In other cases, the command generating the error is
  439. ignored so that it has no effect on AL state or output buffer
  440. contents. If the error generating command returns a value,
  441. it returns zero. If the generating command modifies values
  442. through a pointer argument, no change is made to these values.
  443. These error semantics apply only to AL errors, not to system errors
  444. such as memory access errors.
  445. </para>
  446. <para>
  447. Several error generation conditions are implicit in the description
  448. of the various AL commands. First, if a command that requires
  449. an enumerated value is passed a value that is not one of those
  450. specified as allowable for that command, the error INVALID_ENUM
  451. results. This is the case even if the argument is a pointer to
  452. a symbolic constant if that value is not allowable for the given
  453. command.
  454. This will occur whether the value is allowable for other functions,
  455. or an invalid integer value.
  456. </para>
  457. <para>
  458. Integer parameters that are used as names for &AL; objects
  459. such as Buffers and Sources are checked for validity. If an invalid
  460. name parameter is specified in an &AL; command, an
  461. INVALID_NAME error will be generated, and the command is ignored.
  462. </para>
  463. <para>
  464. If a negative integer is provided where an argument of type
  465. &sizei; is specified, the error INVALID_VALUE results. The same
  466. error will result from attempts to set integral and floating
  467. point values for attributes exceeding the legal range for
  468. these. The specification does not guarantee that the implementation
  469. emits INVALID_VALUE if a &NaN; or &Infty; value is
  470. passed in for a &float; or &double; argument (as the specification
  471. does not enforce possibly expensive testing of floating point
  472. values).
  473. </para>
  474. <para>
  475. Commands can be invalid. For example, certain commands might not be
  476. applicable to a given object. There are also illegal combinations
  477. of tokens and values as arguments to a command. &AL; responds to any
  478. such illegal command with an INVALID_OPERATION error.
  479. </para>
  480. <![ %Scratch [
  481. <para>
  482. No longer true except for extensions. To be avoided
  483. in general: &AL; has
  484. mutually exclusive commands operating on similar objects.
  485. One example is treating a streaming buffer as a
  486. non-streaming buffer, another is appending data to a
  487. non-streaming buffer.
  488. </para>
  489. ]]>
  490. <para>
  491. If memory is exhausted as a side effect of the execution of an
  492. AL command, either on system level or by exhausting the allocated
  493. resources at AL's internal disposal, the error OUT_OF_MEMORY
  494. may be generated. This can also happen independent of recent
  495. commands if &AL; has to request memory for an internal task
  496. and fails to allocate the required memory from the operating
  497. system.
  498. </para>
  499. <para>
  500. Otherwise errors are generated only for conditions that are
  501. explicitely described in this specification.
  502. </para>
  503. <![ %RFC [
  504. <note id="rfc-bk000807-01"><title>RFC: INVALID_SIZE?</title><para>
  505. Specific error case in which the size argument is
  506. negative, or mismatches internal conditions for a getter?
  507. </para></note>
  508. ]]>
  509. <![ %RFC [
  510. <note id="rfc-bk000802-03"><title>RFC: INVALID_POINTER?</title><para>
  511. GL seemingly does not specify a response to NULL pointer
  512. destinations, and does not assign an error case. INVALID_VALUE
  513. could be used, also we could introduce a separate INVALID_POINTER.
  514. Is there a good reason not to catch these cases?
  515. </para></note>
  516. ]]>
  517. </sect1>
  518. <sect1 id="control">
  519. <title>Controlling AL Execution</title>
  520. <para>
  521. The application can temporarily disable certain AL capabilities
  522. on a per Context basis. This allows the driver implementation
  523. to optimize for certain subsets of operations.
  524. Enabling and disabling capabilities is handled using a function
  525. pair.
  526. <funcsynopsis><funcprototype>
  527. <funcdef> &void; <function> Enable </function></funcdef>
  528. <paramdef> &enum; <parameter> target </parameter></paramdef>
  529. </funcprototype></funcsynopsis>
  530. <funcsynopsis><funcprototype>
  531. <funcdef> &void; <function> Disable </function></funcdef>
  532. <paramdef> &enum; <parameter> target </parameter></paramdef>
  533. </funcprototype></funcsynopsis>
  534. The application can also query whether a given capability is
  535. currently enabled or not.
  536. <funcsynopsis><funcprototype>
  537. <funcdef> &bool; <function> IsEnabled </function></funcdef>
  538. <paramdef> &enum; <parameter> target </parameter></paramdef>
  539. </funcprototype></funcsynopsis>
  540. If the token used to specify target is not legal,
  541. an INVALID_ENUM error will be generated.
  542. </para>
  543. <para>
  544. At this time, this mechanism is not used. There are no valid
  545. targets.
  546. </para>
  547. <![ %Annote [
  548. <note><title>Annotation (Enable/Disable)</title><para>
  549. Currently, &AL; is controlled exploiting existing
  550. commands. For example, to disable sound output but
  551. not processing, the Listener can be muted setting
  552. GAIN to zero. Selecting NONE as the distance model
  553. disables distance attenuation. Setting DOPPLER_FACTOR
  554. to zero disables the Doppler Effect. A redundant
  555. mechanism to accomplish the same is not needed.
  556. </para></note>
  557. ]]>
  558. </sect1>
  559. <sect1 id="objects">
  560. <title>Object Paradigm</title>
  561. <para>
  562. &AL; is an object-oriented API, but it does not expose classes, structs,
  563. or other explicit data structures to the application.
  564. </para>
  565. <sect2 id="object-overview-categories">
  566. <title>Object Categories</title>
  567. <para>
  568. &AL; has three primary categories of Objects:
  569. <itemizedlist>
  570. <listitem>
  571. <para>
  572. one unique Listener per Context
  573. </para>
  574. </listitem>
  575. <listitem>
  576. <para>
  577. multiple Buffers shared among Contexts
  578. </para>
  579. </listitem>
  580. <listitem>
  581. <para>
  582. multiple Sources, each local to a Context
  583. </para>
  584. </listitem>
  585. </itemizedlist>
  586. In the following, "{Object}" will stand for either Source,
  587. Listener, or Buffer.
  588. </para>
  589. </sect2>
  590. <sect2 id="object-overview-dynamic">
  591. <title>Static vs. Dynamic Objects</title>
  592. <para>
  593. The vast majority of &AL; objects are dynamic, and will be created
  594. on application demand. There are also &AL; objects that do not have
  595. to be created, and can not be created, on application demand.
  596. Currently, the Listener is the only such static object in &AL;.
  597. </para>
  598. </sect2>
  599. <sect2>
  600. <title>Object Names</title>
  601. <para>
  602. Dynamic Objects are manipulated using an integer, which in
  603. analogy to &OGL; is referred to as the object's "name". These
  604. are of type unsigned integer (uint). Names can be valid
  605. beyond the lifetime of the context they were requested
  606. if the objects in question can be shared among contexts.
  607. No guarantees or assumptions are
  608. made in the specification about the precise values or their distribution
  609. over the lifetime of the application. As objects might be shared,
  610. Names are guaranteed to be
  611. unique within a class of &AL; objects, but no guarantees are made
  612. across different classes of objects. Objects that are unique
  613. (singletons), like the Listener, do not require and do not have
  614. an integer "name".
  615. </para>
  616. </sect2>
  617. <sect2>
  618. <title>Requesting Object Names</title>
  619. <para>
  620. &AL; provides calls to obtain Object Names. The application requests
  621. a number of Objects of a given category using Gen{Object}s.
  622. If the number n of Objects requested is negative,
  623. an INVALID_VALUE error will caused. The actual values of the
  624. Names returned are implementation dependent. No guarantees on
  625. range or value are made. Unlike &OGL; &OAL does not offer alternative
  626. means to define (bind) a Name.
  627. </para>
  628. <para>
  629. Allocation of Object Names does not imply immediate allocation of
  630. resources or creation of Objects: the implementation is free to
  631. defer this until a given Object is actually used in mutator calls.
  632. The Names are written at the memory location specified by the caller.
  633. <funcsynopsis><funcprototype>
  634. <funcdef> void <function> Gen{Object}s </function></funcdef>
  635. <paramdef> &sizei; <parameter> n </parameter></paramdef>
  636. <paramdef> &uint;* <parameter> objectNames </parameter></paramdef>
  637. </funcprototype></funcsynopsis>
  638. </para>
  639. <para>
  640. Requesting zero names is a legal NOP. Requesting a negative
  641. number of names causes an INVALID_VALUE error.
  642. &AL; will respond with an OUT_OF_MEMORY if the application
  643. requests too many objects. The specification does not guarantee
  644. that the &AL; implementation will allocate all resources
  645. needed for the actual objects at the time the names are
  646. reserved. In many cases (Buffers) this could only be
  647. implemented by worst case estimation. Allocation of names
  648. does not guarantee that all the named objects can actually
  649. be used.
  650. </para>
  651. <![ %Scratch [
  652. <note><para>
  653. We do not re-use Names under any circumstance. Do we require
  654. implementations throwing OUT_OF_MERMORY errors on allocation of
  655. Names? No - we don't even specify buffer sizes. Ambiguity - could
  656. an implementation throw OOM because of no names, or OOM because
  657. of a (worst case) estimate of object sizes? Do we need OUT_OF_NAMES?
  658. </para></note>
  659. ]]>
  660. <![ %Scratch [
  661. <warning><para>
  662. The current headers include a sizei return parameter:
  663. "Returns the number of ids actually allocated."
  664. This violates the "failed commands are NOPs" design
  665. and introduces ambiguity in error handling, and has
  666. thus been changed breaking backwards compatibility.
  667. </para></warning>
  668. ]]>
  669. <![ %Annote [
  670. <note><title>Annotation (No application selected Names)</title><para>
  671. Unlike GL, applications are not free to choose Names; all
  672. Names have to be requested. Aside from possible benefits for
  673. the implementation, and avoidance of errors in projects
  674. that have many modules using the AL implementation (a problem
  675. encountered in GL, when the two generation mechanisms are
  676. mixed), this also leaves open the door to feed different
  677. kinds of objects by Name through the same API entry points.
  678. </para></note>
  679. ]]>
  680. <![ %Annote [
  681. <note><title>Annotate (Negative/zero sizei)</title><para>
  682. The specification does not guarantee that sizei is an
  683. unsigned integer, but legal values have to be non-negative.
  684. However, requesting zero names is a legal NOP.
  685. </para></note>
  686. ]]>
  687. <![ %RFC [
  688. <note id=rfc-bk000626-02><title>RFC: Resource Release Hint</title><para>
  689. Do we need a hint that resource release has to be done on DeleteXXX,
  690. instead of leaving this housekeeping to &AL;?
  691. </para></note>
  692. <note id=rfc-bk000626-03><title>RFC: Zero Name</title><para>
  693. Do we reserve the name "0"? &OGL; provides an alternative mechanism
  694. which lets the application pick texture names, which we discarded
  695. because it is prone to create error conditions when mixing both
  696. approaches. As all our names are generated using GenXXXX, there
  697. is no real need to treat "0" special.
  698. </para></note>
  699. ]]>
  700. </sect2>
  701. <sect2>
  702. <title>Releasing Object Names</title>
  703. <para>
  704. &AL; provides calls to the application to release Object Names
  705. using Delete{Object}s, implicitly requesting deletion of the
  706. Objects associated with the Names released. If the number n of Objects named
  707. is negative, an INVALID_VALUE error will be caused.
  708. If one or more of the specified Names is not valid, an INVALID_NAME
  709. error will be caused. Implementation behavior following any error
  710. is undefined.
  711. </para>
  712. <para>
  713. Once deleted (even if an error occured on deletion), the Names are
  714. no longer valid for use with any &AL; function calls including
  715. calls to Delete{Objects}s. Any such use will cause an INVALID_NAME
  716. error.
  717. </para>
  718. <para>
  719. The &AL; implementation is free to defer actual release of
  720. resources. Ideally, resources should be released as soon as
  721. possible, but no guarantees are made.
  722. <funcsynopsis><funcprototype>
  723. <funcdef>&void;<function>Delete{Object}s</function></funcdef>
  724. <paramdef>&sizei;<parameter>n</parameter></paramdef>
  725. <paramdef>&uint;*<parameter>objectNames</parameter></paramdef>
  726. </funcprototype></funcsynopsis>
  727. </para>
  728. <![ %Annote [
  729. <note><title>Annotation</title><para>
  730. GenXXX and DeleteXXX can not reasonably be expected to be used
  731. for controlling driver-side resource management from the
  732. application. A driver might never release a Source once allocated
  733. during the lifetime of the application.
  734. </para></note>
  735. ]]>
  736. <![ %RFC [
  737. <note id="rfc-bk000724-18"><title>RFC: Deletion Errors</title><para>
  738. chasan@acm.org:
  739. What happens if an active source (or its associated buffer) is deleted?
  740. The source should be stopped? Or the delete operation is invalid?
  741. </para></note>
  742. ]]>
  743. </sect2>
  744. <sect2>
  745. <title>Validating an Object Name</title>
  746. <para>
  747. &AL; provides calls to validate the Name of an Object.
  748. The application can verify whether an Object Name is valid
  749. using the Is{Object} query. There is no vector (array)
  750. version of this function as it defeats the purpose of
  751. unambiguous (in)valdiation. Returns &TRUE; if id is a
  752. valid Object Name, and &FALSE; otherwise. Object Names are
  753. valid between request (Gen{Object}s) and release (Delete{Object}s).
  754. Is{Object} does not distinguish between invalid and deleted Names.
  755. <funcsynopsis><funcprototype>
  756. <funcdef>&bool;<function>Is{Object}</function></funcdef>
  757. <paramdef>&uint;<parameter>objectName</parameter></paramdef>
  758. </funcprototype></funcsynopsis>
  759. </para>
  760. <![ %RFC [
  761. <note><title>RFC/bk000504:</title><para>
  762. If zero is a valid name, this function will have to accept
  763. it without an actyual object (or only an internal dummy)
  764. being associated with it. I recommend that implementations
  765. never return "0" as an object name.
  766. </para></note>
  767. ]]>
  768. </sect2>
  769. <sect2>
  770. <title>Setting Object Attributes</title>
  771. <para>
  772. For &AL; Objects, calls to control their attributes are provided.
  773. These depend on the actual properties of a given Object
  774. Category. The precise API is discussed for each category,
  775. below. Each &AL; command affecting the state of
  776. a named Object is usually of the form
  777. <funcsynopsis><funcprototype>
  778. <funcdef> void <function> {Object}{n}{sifd}{v} </function></funcdef>
  779. <paramdef> &uint; <parameter> objectName </parameter></paramdef>
  780. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  781. <paramdef> &type; <parameter> values </parameter></paramdef>
  782. </funcprototype></funcsynopsis>
  783. In the case of unnamed (unique) Objects, the (integer) objectName
  784. is omitted, as it is implied by the {Object} part of function name:
  785. <funcsynopsis><funcprototype>
  786. <funcdef> void <function> {Object}{n}{sifd}{v} </function></funcdef>
  787. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  788. <paramdef> &type; <parameter> values </parameter></paramdef>
  789. </funcprototype></funcsynopsis>
  790. For example, the Listener3d command would not require an (integer)
  791. objectName argument.
  792. </para>
  793. <para>
  794. The objectName specifies the &AL; object affected by this call.
  795. Use of an invalid Name will cause an INVALID_NAME error.
  796. </para>
  797. <para>
  798. The Object's Attribute to be affected has to be named
  799. as paramName. &AL; parameters applicable to one category
  800. of Objects are not necessarily legal for another catetgory
  801. of &AL; Objects. Specification of a parameter illegal for
  802. a given object will cause an INVALID_OPERATION error.
  803. </para>
  804. <para>
  805. Not all possible values for a type will be legal for a
  806. given objectName and parameterName. Use of an illegal value
  807. or a NULL value pointer will cause an INVALID_VALUE error.
  808. </para>
  809. <para>
  810. Any command that causes an error is a NOP.
  811. </para>
  812. </sect2>
  813. <sect2>
  814. <title>Querying Object Attributes</title>
  815. <para>
  816. For named and for unique &AL; Objects, calls to query their
  817. current attributes are provided.
  818. These depend on the actual properties of a given Object
  819. Category. The performance of such queries is implementation
  820. dependent, no performance guarantees are made. The valid values for the
  821. parameter paramName are identical to the ones legal for the complementing
  822. attribute setting function.
  823. <funcsynopsis><funcprototype>
  824. <funcdef> void <function> Get{Object}{n}{sifd}{v} </function></funcdef>
  825. <paramdef> &uint; <parameter> objectName </parameter></paramdef>
  826. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  827. <paramdef> &type;* <parameter> destination </parameter></paramdef>
  828. </funcprototype></funcsynopsis>
  829. For unnamed unique Objects, the objectName is omitted as it is
  830. implied by the function name:
  831. <funcsynopsis><funcprototype>
  832. <funcdef> void <function> Get{Object}{n}{sifd}{v} </function></funcdef>
  833. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  834. <paramdef> &type;* <parameter> destination </parameter></paramdef>
  835. </funcprototype></funcsynopsis>
  836. </para>
  837. <para>
  838. The precise API is discussed for each category separately, below.
  839. Unlike their matching mutators, Query functions for non-scalar
  840. properties (vectors etc.) are only available in array form.
  841. </para>
  842. <para>
  843. Use of an invalid Name will cause an INVALID_NAME error.
  844. Specification of an illegal parameter type (token) will cause
  845. an INVALID_ENUM error. A call with a destination
  846. NULL pointer will be quietly ignored. The &AL; state will not
  847. be affected by errors. In case of errors, destination memory
  848. will not be changed.
  849. </para>
  850. </sect2>
  851. <sect2>
  852. <title>Object Attributes</title>
  853. <para>
  854. Attributes affecting the processing of sounds can be set for various
  855. &AL; Object categories, or might change as an effect of &AL; calls.
  856. The vast majority of these Object properties are specific to the
  857. &AL; Object category, in question, but some are applicable to two
  858. or more categories, and are listed separately.
  859. </para>
  860. <para>
  861. The general form in which this document describes parameters is
  862. <table>
  863. <title>{Object} Parameters</title>
  864. <tgroup cols="4" align="left" colsep=1 rowsep=1>
  865. <colspec colname=c1>
  866. <colspec colname=c2>
  867. <colspec colname=c3>
  868. <colspec colname=c4>
  869. <thead>
  870. <row>
  871. <entry>&Par;</>
  872. <entry>&Sig;</>
  873. <entry>&Val</>
  874. <entry>&Def;</>
  875. </row>
  876. </thead>
  877. <tbody>
  878. <row>
  879. <entry>paramName</>
  880. <entry>T</>
  881. <entry> range or set </>
  882. <entry> scalar or n-tuple </>
  883. </row>
  884. </tbody>
  885. </tgroup>
  886. </table>
  887. Description:
  888. The description specifies additional restrictions and details.
  889. paramName is given as the &AL; enum defined as its name.
  890. T can be a list of legal signatures, usually the array form
  891. as well as the flat (unfolded) form.
  892. </para>
  893. <![ %RFC [
  894. <note id="rfc-bk000626-04"><title>RFC: Initial (Default) State</title><para>
  895. The default state of objects will have to be specified here.
  896. There will be no commands that allow the application to set
  897. other defaults.
  898. </para></note>
  899. ]]>
  900. </sect2>
  901. </sect1>
  902. </chapter>