chp-buffers.sgml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <chapter id="buffers">
  2. <title>Buffers</title>
  3. <para>
  4. A Buffer encapsulates &AL; state related to storing sample data. The
  5. application can request and
  6. release Buffer objects, and fill them with data. Data can be supplied
  7. compressed and encoded as long as the format is supported.
  8. Buffers can, internally, contain waveform data as uncompressed or
  9. compressed samples.
  10. </para>
  11. <para>
  12. Unlike Sources and Listener, Buffer Objects can be shared among AL contexts.
  13. Buffers are referenced by Sources.
  14. A single Buffer can be referred to by multiple Sources. This separation allows
  15. drivers and hardware to optimize storage and processing where applicable.
  16. </para>
  17. <para>
  18. The simplest supported format for buffer data is PCM.
  19. </para>
  20. <![ %Annote [
  21. <note id="ann-bk000721-01"><title>Annotation/ Compressed Buffers</title><para>
  22. Compressed formats are in no way guaranteed by the implementation
  23. to remain compressed. The driver might have to uncompres in memory
  24. at once, if no hardware-assisted or incremental decoding is possible.
  25. In many cases an implementation has to decompress the buffer,
  26. converting the uncompressed data to a canonical internal format,
  27. and resample it into the format native to the current context.
  28. </para></note>
  29. ]]>
  30. <![ %RFC [
  31. <note id="rfc-bk000721-18"><title>RFC: Compressed Buffers</title><para>
  32. MikeV suggests: an application can query the amount of memory buffer
  33. is consuming. He suggests using GetBufferi(AL_SIZE, ... ). This seems
  34. a bad idea as (a) the application is not meant to micromanage
  35. driver-internal memory, (b) the memory requirements known to the
  36. application might differ from the actual, (c) there are OS
  37. mechanisms to query free memory, (d) AL_SIZE is now ambiguous as
  38. it announces app-side memory as allocated vs. driver side memory
  39. as used by the driver. For clarity AL_INTERNAL_SIZE (analog to
  40. internal format enums) might be a better choice.
  41. </para></note>
  42. ]]>
  43. <![ %Scratch [
  44. <para>
  45. Buffers can be non-streaming (default) or streaming. Non-streaming
  46. buffers are used to store looping and non-looping (single-shot) sound
  47. data. Streaming buffers have to be used to cache streaming
  48. media that the application can not keep in memory for technical
  49. reasons: e.g. data delivered in real time over network. Streaming buffers
  50. can also be used to partially store sound samples that the application
  51. coder consider too large to keep in memory at once.
  52. </para>
  53. ]]>
  54. <sect1>
  55. <title>Buffer States</title>
  56. <para>
  57. At this time, Buffer states are defined for purposes of discussion.
  58. The states described in this section are not exposed through the API
  59. (can not be queried, or be set directly), and the state description
  60. used in the implementation might differ from this.
  61. </para>
  62. <para>
  63. A Buffer is considered to be in one of the following States, with respect
  64. to all Sources:
  65. <itemizedlist>
  66. <listitem>
  67. <para>
  68. UNUSED: the Buffer is not included in any queue
  69. for any Source. In particular, the
  70. Buffer is neither pending nor current
  71. for any Source. The Buffer name can be
  72. deleted at this time.
  73. </para>
  74. </listitem>
  75. <listitem>
  76. <para>
  77. PROCESSED: the Buffer is listed in the queue of
  78. at least one Source, but is neither pending
  79. nor current for any Source. The Buffer can
  80. be deleted as soon as it has been unqueued
  81. for all Sources it is queued with.
  82. </para>
  83. </listitem>
  84. <listitem>
  85. <para>
  86. PENDING: there is at least one Source for which the
  87. Buffer has been queued, for which the Buffer
  88. data has not yet been dereferenced. The Buffer
  89. can only be unqueued for those Sources that
  90. have dereferenced the data in the Buffer
  91. in its entirety, and cannot be deleted or
  92. changed.
  93. </para>
  94. </listitem>
  95. </itemizedlist>
  96. The Buffer state is dependent on the state of all Sources
  97. that is has been queued for.
  98. A single queue occurrence of a Buffer propagates the
  99. Buffer state (over all Sources) from UNUSED to PROCESSED
  100. or higher. Sources that are STOPPED or INITIAL still have
  101. queue entries that cause Buffers to be PROCESSED.
  102. </para>
  103. <para>
  104. A single queue entry
  105. with a single Source for which the Buffer is not yet
  106. PROCESSED propagates the buffer's queueing state to
  107. PENDING.
  108. </para>
  109. <para>
  110. Buffers that are PROCESSED for a given Source can be
  111. unqueued from that Source's queue. Buffers that have
  112. been unqueued from all Sources are UNUSED.
  113. Buffers that are UNUSED can be deleted, or changed by
  114. BufferData commands.
  115. </para>
  116. <![ %Annote [
  117. <note><title>Annotation (No CURRENT State)</title><para>
  118. For buffer queueing, it is not relevant whether
  119. the Buffer data is currently dereferenced by any
  120. Source or not. It is therefore not necessary to
  121. distinguish a CURRENT state (being referenced as
  122. current buffer by a single PLAYING or PAUSED Source).
  123. </para></note>
  124. ]]>
  125. <![ %Annote [
  126. <note><title>Annotation (State Query and Shared Buffers)</title><para>
  127. A buffer that is unused by one Source might be used
  128. by another. The Unqueue operation is determined by
  129. the number of queue entries already processed by the
  130. given Source.
  131. However, the application has to check whether the
  132. Buffer is still in use by other Sources. For now,
  133. applications have to maintain their own lists of
  134. buffer consumer (source) lists. If necessary, an
  135. explicit call to determine current buffer state
  136. with respect to all Sources might be added in
  137. future revisions.
  138. </para></note>
  139. ]]>
  140. <![ %RFC [
  141. <note id="rfc-bk000927-02"><title>RFC: IsBufferProcessed? </title><para>
  142. Instead of exposing the internal state, a simple boolean query
  143. whether a buffer can be deleted or refilled can be used.
  144. </para></note>
  145. ]]>
  146. <![ %RFC [
  147. <note id="rfc-bk000731-04"><title>RFC: BufferData on QUEUED</title><para>
  148. The error on using BufferData in QUEUED buffers is introduced
  149. because the implementation might not be able to guarantee when
  150. the Buffer is dereferenced. Applications have to account for the
  151. possibility that the Buffer is dereferenced at the latest possible
  152. moment, e.g. when it becomes CURRENT. As it is easier to relax
  153. this restricition at a later time (no effect on backwards
  154. compatibility) than doing the reverse, we are conserative here.
  155. </para></note>
  156. ]]>
  157. <![ %RFC [
  158. <note id="rfc-bk000731-05"><title>RFC: Buffer State Query</title><para>
  159. Buffer State could be queried using alBuffer(), but it can't be
  160. set. Prohibiting deferred deletion of buffers would make such a
  161. state query desirable.
  162. </para></note>
  163. ]]>
  164. </sect1>
  165. <sect1>
  166. <title>Managing Buffer Names</title>
  167. <para>
  168. &AL; provides calls to obtain Buffer names, to request
  169. deletion of a Buffer object associated with a valid Buffer name,
  170. and to validate a Buffer name. Calls to control Buffer attributes
  171. are also provided.
  172. </para>
  173. <sect2>
  174. <title>Requesting Buffers Names</title>
  175. <para>
  176. The application requests a number of Buffers using GenBuffers.
  177. <funcsynopsis><funcprototype>
  178. <funcdef> void <function> GenBuffers </function></funcdef>
  179. <paramdef> &sizei; <parameter> n </parameter></paramdef>
  180. <paramdef> &uint;* <parameter> bufferNames </parameter></paramdef>
  181. </funcprototype></funcsynopsis>
  182. </para>
  183. <![ %RFC [
  184. <note id="rfc-bk000803-02"><title>RFC: Buffer Name 0</title><para>
  185. NONE or 0 is a reserved buffer name. What properties does
  186. this buffer have? Does it have content? If there is no content,
  187. what is its duration? 0? 1 microsecond? Should we use this buffer
  188. to schedule a limited duration "silence"?
  189. </para></note>
  190. ]]>
  191. </sect2>
  192. <sect2>
  193. <title>Releasing Buffer Names</title>
  194. <para>
  195. The application requests deletion of a number of Buffers
  196. by calling DeleteBuffers.
  197. </para>
  198. <para>
  199. Once deleted, Names are no longer valid for use with AL
  200. function calls. Any such use will cause an INVALID_NAME
  201. error. The implementation is free to defer actual
  202. release of resources.
  203. <funcsynopsis><funcprototype>
  204. <funcdef> &void; <function> DeleteBuffers </function></funcdef>
  205. <paramdef> &sizei; <parameter> n </parameter></paramdef>
  206. <paramdef> &uint;* <parameter> bufferNames </parameter></paramdef>
  207. </funcprototype></funcsynopsis>
  208. IsBuffer(bname) can be used to verify deletion of a buffer.
  209. Deleting bufferName 0 is a legal NOP in both scalar and
  210. vector forms of the command. The same is true for unused
  211. buffer names, e.g. such as not allocated yet, or as
  212. released already.
  213. </para>
  214. <![ %RFC [
  215. <note id="rfc-bk000803-01"><title>RFC: Force Deletion</title><para>
  216. If a buffer name is deleted, we could replace all occurences
  217. in queues with bname 0. This is the GL behavior for deleting
  218. the texture currently bound.
  219. </para></note>
  220. ]]>
  221. <![ %RFC [
  222. <note id="rfc-bk000731-07"><title>RFC: Relasing used Buffers</title><para>
  223. If a Buffer is USED or QUEUED, it cannot be deleted, and the operation
  224. should fail. We have three possible responses: throw an error, deferr
  225. deletion, or force deletion by replacing every use
  226. of the buffer in question with bname zero.
  227. Throwing an error requires that we lock, verify that all specified
  228. buffers can be deleted, then perform deletion, then unlock. If there
  229. is one buffer that can not be deleted we have to throw an error and
  230. make the entire operation a NOP.
  231. Deferred deletion has its own set of problems (see other RFC).
  232. Forcing deletion makes the mistake obvious to the application
  233. for current buffers (sound artifacts) but still doesn't expose
  234. errors for queued buffers. It also requires complete consumer
  235. book-keeping for each buffer. GL uses this approach for textures
  236. at little expense because it only has one current texture.
  237. </para></note>
  238. ]]>
  239. <![ %RFC [
  240. <note id="rfc-bk000731-06"><title>RFC: Deferred Buffer Release</title><para>
  241. Buffer deletion could be performed as a deferred operation.
  242. In this case actual deletion would be deferred until a Buffer is
  243. unused, i.e. not QUEUED or CURRENT anymore. The specification
  244. would not guarantee that they are deleted as soon as possible.
  245. However, such a deferred execution would be muddying the borders
  246. between immediate and deferred execution in general (as we
  247. might want to add scheduling and deferred commands at a later time).
  248. Introduced as the default it makes impossible for the application
  249. to force deletion or errors. Errors caused by improper use of
  250. &AL; will be triggered at some distance from the original mistaken
  251. command. Debugging such conditions is usually expensive. This approach
  252. also does not take into account sharing of buffers among contexts.
  253. It might be possible to introduce this behavior as a Hint()
  254. in case that it is not desirable to explicitely introduce
  255. deferred commands.
  256. </para></note>
  257. ]]>
  258. <![ %RFC [
  259. <note id="rfc-bk000927-03"><title>RFC: sourceName 0 </title><para>
  260. Is there a useful application for this? Do we mark that this
  261. is reserved?
  262. </para></note>
  263. ]]>
  264. </sect2>
  265. <sect2>
  266. <title>Validating a Buffer Name</title>
  267. <para>
  268. The application can verify whether a buffer Name is valid
  269. using the IsBuffer query.
  270. <funcsynopsis><funcprototype>
  271. <funcdef> &bool; <function> IsBuffer </function></funcdef>
  272. <paramdef> &uint; <parameter> bufferName</parameter></paramdef>
  273. </funcprototype></funcsynopsis>
  274. </para>
  275. </sect2>
  276. </sect1>
  277. <sect1>
  278. <title>Manipulating Buffer Attributes</title>
  279. <sect2>
  280. <title>Buffer Attributes</title>
  281. <para>
  282. This section lists the attributes that can be set, or
  283. queried, per Buffer. Note that some of these attributes
  284. can not be set using the Buffer commands, but are set
  285. using commands like BufferData.
  286. </para>
  287. <para>
  288. Querying the attributes of a Buffer with a buffer name that
  289. is not valid throws an INVALID_OPERATION. Passing in an
  290. attribute name that is invalid throws an INVALID_VALUE error.
  291. </para>
  292. <para>
  293. <table>
  294. <title>Buffer FREQUENCY Attribute</title>
  295. <tgroup cols="4" align="left" colsep=1 rowsep=1>
  296. <thead>
  297. <row>
  298. <entry>&Par;</>
  299. <entry>&Sig;</>
  300. <entry>&Val</>
  301. <entry>&Def;</>
  302. </row>
  303. </thead>
  304. <tbody>
  305. <row>
  306. <entry> FREQUENCY </>
  307. <entry> float </>
  308. <entry> none </>
  309. <entry> (0, any]</>
  310. </row>
  311. </tbody>
  312. </tgroup>
  313. </table>
  314. Description: Frequency, specified in samples per second,
  315. i.e. units of Hertz [Hz].
  316. Query by GetBuffer. The frequency state of a buffer is set by
  317. BufferData calls.
  318. </para>
  319. <![ %Annote [
  320. <note><title>Annotation (No Frequency enumeration)</title><para>
  321. As the implementation has to support conversion from
  322. one frequency to another to implement pitch, it is
  323. feasible to offer support for arbitrary sample
  324. frequencies, instead of restricting the application
  325. to an enumeration of supported sample frequencies.
  326. Another reason not to limit frequency to an enumerated
  327. set is that future hardware might support variable
  328. frequencies as well (it might be preferable to choose
  329. the sampling frequency according to the PSD of the
  330. signal then).
  331. </para><para>
  332. However, it is desirable to avoid conversions due
  333. to differences between the sample frequency used in
  334. the original data, the frequency supported during the
  335. mixing, and the frequency expected by the output device.
  336. </para></note>
  337. ]]>
  338. <![ %Annote [
  339. <note><title>Annotation (Implied Frequency)</title><para>
  340. To account for the possibility of future AL implementations
  341. supporting encoding formats for the application might
  342. not want, or be able, to retrieve the actual frequency
  343. from the encoded sample, the specification will be
  344. amended to guarantee the following behavior: If a nonzero
  345. frequency is specified, it will force a conversion from
  346. the actual to the requested frequency. If the application
  347. specifies a 0 frequency, AL will use the actual frequency.
  348. If there is no frequency information implied by the format
  349. or contained in the encoded data, specifying a 0 frequency
  350. will yield INVALID_VALUE. It is recommended that applications
  351. use NONE instead of the literal value.
  352. </para></note>
  353. ]]>
  354. <![ %RFC [
  355. <note id="rfc-bk000806-01"><title>RFC: BITS not needed </title><para>
  356. This is not a setter. As a state query it doesn't provide useful
  357. information about the internal canonical format (which could be
  358. queried independent of the buffer).
  359. </para></note>
  360. <para>
  361. <table>
  362. <title>Buffer BITS Attribute</title>
  363. <tgroup cols="4" align="left" colsep=1 rowsep=1>
  364. <thead>
  365. <row>
  366. <entry>&Par;</>
  367. <entry>&Sig;</>
  368. <entry>&Val</>
  369. <entry>&Def;</>
  370. </row>
  371. </thead>
  372. <tbody>
  373. <row>
  374. <entry>BITS</>
  375. <entry>ui</>
  376. <entry>8,16</>
  377. <entry>0</>
  378. </row>
  379. </tbody>
  380. </tgroup>
  381. </table>
  382. Description:
  383. Bits per sample. This is a query-only attribute. The
  384. default value for an (empty) buffer is zero.
  385. </para>
  386. ]]>
  387. <![ %Annote [
  388. <note><title>Annotation (No Format query)</title><para>
  389. As of this time there is no query for FORMAT, or format
  390. related state information. Query of the channels or
  391. bits of a given buffer make little sense if the query
  392. the internal (canonical, not buffer specific) format.
  393. Query of the original sample data format makes little
  394. sense unless the implementation is obliged to preserve
  395. the original data.
  396. </para></note>
  397. ]]>
  398. <![ %RFC [
  399. <note id="rfc-bk000806-02"><title>RFC: CHANNELS needed?</title><para>
  400. No setter. Does this indicate the channels in the original data,
  401. or those in the (canonical) format internally used? Redundant to
  402. querying the buffer type. Should be enums as speaker configurations
  403. might have to be destribed by two integers: 5.1.
  404. </para></note>
  405. <para>
  406. <table>
  407. <title>Buffer CHANNELS Attribute</title>
  408. <tgroup cols="4" align="left" colsep="1" rowsep="1">
  409. <thead>
  410. <row>
  411. <entry>&Par;</>
  412. <entry>&Sig;</>
  413. <entry>&Val;</>
  414. <entry>&Def;</>
  415. </row>
  416. </thead>
  417. <tbody>
  418. <row>
  419. <entry>CHANNELS</>
  420. <entry>ui</>
  421. <entry>RFC: enums or N/A?</>
  422. <entry>0</>
  423. </row>
  424. </tbody>
  425. </tgroup>
  426. </table>
  427. Description: Channels that buffer stores. Query only
  428. attribute. This is almost
  429. always 1, as applications using spatialized sound always
  430. downsample to mono. This depends on the purpose of the
  431. buffer: buffers used for spatialization have to provide
  432. single-channel data. The default value for an (empty)
  433. buffer is zero.
  434. </para>
  435. ]]>
  436. <para>
  437. <table>
  438. <title>Buffer SIZE Attribute</title>
  439. <tgroup cols="4" align="left" colsep="1" rowsep="1">
  440. <thead>
  441. <row>
  442. <entry>&Par;</>
  443. <entry>&Sig;</>
  444. <entry>&Val;</>
  445. <entry>&Def;</>
  446. </row>
  447. </thead>
  448. <tbody>
  449. <row>
  450. <entry>SIZE</>
  451. <entry> &sizei; </>
  452. <entry> [0, MAX_UINT]</>
  453. <entry> 0 </>
  454. </row>
  455. </tbody>
  456. </tgroup>
  457. </table>
  458. Description: Size in bytes of the buffer data. Query through
  459. GetBuffer, can be set only using BufferData calls.
  460. Setting a SIZE of 0 is a legal NOP. The number of bytes does
  461. not necessarily equal the number of samples (e.g. for compressed data).
  462. </para>
  463. <![ %RFC [
  464. <note id="rfc-bk000724-15"><title>RFC: buffer overflow/underflow</title><para>
  465. If a SIZE is specified for a buffer and an attempt is made to
  466. write less or more data to the buffer, is this an error? Do we
  467. have SubData updates? Is trying to write data to a zero size buffer
  468. an error? Which error?
  469. </para></note>
  470. ]]>
  471. <![ %RFC [
  472. <note id="rfc-bk000619-16"><title>RFC: query for samples/duration?</title><para>
  473. Do we need a query for samples (which does not equal memory size)?
  474. Do we prefer a duration query? As integral, for precision? Which,
  475. combined with frequency, has to guarantee accurate sample number?
  476. </para></note>
  477. ]]>
  478. <![ %RFC [
  479. <note id="rfc-bk000724-01"><title>RFC: memory budgeting</title><para>
  480. SIZE comment said: Useful for memory budgeting with compressed data.
  481. Sounds bogus: the application can only announce how many bytes
  482. of data it intends to provide, it might not be able to estimate
  483. the uncompressed, decoded size in the internal format chosen by
  484. the implementation w/o decompressing, decoding, and querying for
  485. the internal format. Micromanaging memory is usually a bad idea.
  486. Using SIZE to configure a buffer might ge a mistake. Using the
  487. same enum to query the actual size internally (which might
  488. consists of two or more buffer areas and cached decoding state)
  489. will be confusing.
  490. </para></note>
  491. ]]>
  492. <![ %RFC [
  493. <note id="rfc-bk000724-02"><title>RFC: buffer initial state</title><para>
  494. MikeV added:
  495. "The default attribute values for a Buffer are nonsensical insofar
  496. as a Buffer is incomplete without data having been
  497. specified."
  498. This seems wrong. An AL object will always be complete and valid,
  499. albeit useless. A Buffer in its default state might not produce
  500. any useful outout, but it can be specified and used.
  501. </para></note>
  502. ]]>
  503. </sect2>
  504. <sect2>
  505. <title>Querying Buffer Attributes</title>
  506. <para>
  507. Buffer state is maintained inside the &AL; implementation and can be
  508. queried in full. The valid values for paramName are identical to the
  509. ones for Buffer*.
  510. <funcsynopsis><funcprototype>
  511. <funcdef> void <function> GetBuffer{n}{sifd}{v} </function></funcdef>
  512. <paramdef> &uint; <parameter>bufferName</parameter></paramdef>
  513. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  514. <paramdef> &type;* <parameter> values </parameter></paramdef>
  515. </funcprototype></funcsynopsis>
  516. </para>
  517. </sect2>
  518. <sect2>
  519. <title>Specifying Buffer Content</title>
  520. <para>
  521. A special case of Buffer state is the actual sound sample data stored
  522. in asociation with the Buffer. Applications can specify sample data using
  523. BufferData.
  524. <funcsynopsis><funcprototype>
  525. <funcdef> &void; <function> BufferData </function></funcdef>
  526. <paramdef> &uint; <parameter>bufferName</parameter></paramdef>
  527. <paramdef> &enum; <parameter>format</parameter></paramdef>
  528. <paramdef> &void;* <parameter> data </parameter></paramdef>
  529. <paramdef> &sizei; <parameter> size </parameter></paramdef>
  530. <paramdef> &sizei; <parameter>frequency</parameter></paramdef>
  531. </funcprototype></funcsynopsis>
  532. The data specified is copied to an internal software, or if possible,
  533. hardware buffer. The implementation is free to apply decompression,
  534. conversion, resampling, and filtering as needed. The internal format
  535. of the Buffer is not exposed to the application, and not
  536. accessible. Valid formats are FORMAT_MONO8, FORMAT_MONO16,
  537. FORMAT_STEREO8, and FORMAT_STEREO16. An implementation may
  538. expose other formats, see the chapter on Extensions for
  539. information on determining if additional formats are supported.
  540. </para>
  541. <para>
  542. Applications should always check for an error condition after attempting
  543. to specify buffer data in case an implementation has to generate an
  544. OUT_OF_MEMORY or conversion related INVALID_VALUE error. The application
  545. is free to reuse the memory specified by the data pointer once the
  546. call to BufferData returns. The implementation has to dereference,
  547. e.g. copy, the data during BufferData execution.
  548. </para>
  549. <![ %RFC [
  550. <note id="rfc-bk000724-04"><title>RFC: format enums</title><para>
  551. With the possible exception of sample frequency, all
  552. details of a sample (mono/stero, bit resolution, channels,
  553. encoding,compression) should be specified in a format parameter.
  554. In other words, I opt for an enumeration of formats. GL has a
  555. quite large number of those w/o suffering damage. Allowing
  556. parameters the way we do increases error cases and/or
  557. conversion load. The space is combinatorial to begin with,
  558. but an enumeration of valid formats seems better to impose
  559. restrictions. Using enums helps dealing with formats
  560. opaque to the application (compressed data with compressed
  561. header) where sample size and sampling frequency might not
  562. be available.
  563. There is the related issue of internal formats. A buffer used
  564. for spatialization will have to convert to mono. A buffer used
  565. to pass through to the output hardware will have to
  566. remap an n-channel format to an m-channel format (or let the
  567. hardware do it) including crosstalk handling depending on
  568. the output device (headphones vs. speaker). To prevent that
  569. every buffer has to do both AL needs to know the purpose of a
  570. buffer when dereferencing the data.
  571. </para></note>
  572. ]]>
  573. <![ %RFC [
  574. <note id="rfc-bk0000507-17"><title>RFC: Frequency woes</title><para>
  575. Frequency as a uint rises precision issues.
  576. Frequency might not be known for compressed data, we might need
  577. a (yuck) wildcard frequency specifier?
  578. We have a redundancy: frequency per context (mixing quality
  579. desired), frequency internally used by the implementation when
  580. storing the buffers, frequency provided in the data. We need
  581. to specify the latter in some cases and can't in others. Format
  582. enum or frequency enum again.
  583. </para></note>
  584. ]]>
  585. <![ %RFC [
  586. <note id="rfc-bk000504-01"><title>RFC: data mover mess</title><para>
  587. API to copy data from output buffer to a buffer?
  588. BufferWriteData to supersede BufferData, BufferReadData
  589. as later extensions for buffer readback for those who want it?
  590. Reading the output stream reverses the problems we have
  591. with appendData: the application provides a memory buffer
  592. into which AL copies as much data as available/as fits.
  593. </para></note>
  594. ]]>
  595. <![ %RFC [
  596. <note id="rfc-bk000724-11"><title>RFC: expose internal format</title><para>
  597. Implementations are free to use whatever internal data format is best
  598. suited for their hardware/software implementation, leaving the actual
  599. sample format and structure opaque to the application. Should applications
  600. be able to influence this? Through context creation? Per Buffer?
  601. Do we use Lowest Common Denominator or highest possible quality as a
  602. default?
  603. </para></note>
  604. ]]>
  605. <![ %RFC [
  606. <note id="rfc-bk000724-12"><title>RFC: memory management with compressed data</title><para>
  607. If we allow for mixing from compressed data (perfectly reasonable
  608. for hardware) then it seems even more unlikely the application could
  609. estimate memory usage.
  610. If a compressed format is supported by AL, do we require support for mixing from
  611. compressed data? I daresay not - some formats might not allow for
  612. cheap incremental decompression.
  613. </para></note>
  614. ]]>
  615. <![ %RFC [
  616. <note id="rfc-bk000724-21"><title>RFC: conversion and sample retrieval</title><para>
  617. To retrieve a sample, the size has to be queried first for allocating a
  618. properly sized memory segment as destination. This is dependent on the
  619. format. Conversion can be implemented as creating a buffer, and then
  620. requesting the data in a different format. Is this desirable? Even if
  621. we restrict reading from buffers to the same format they were written
  622. to, conversion from the internal format might be inevitable. Querying
  623. and setting the internal format however might be desirable for certain
  624. purposes.
  625. </para></note>
  626. ]]>
  627. </sect2>
  628. </sect1>
  629. </chapter>