- /* 2 buffers / 512 bytes, giving 1/16 second resolution */
- /* (with stereo the effective buffer size will shrink to 256) */
- fragment_size = 0x00020009;
+ unsigned long fragment_spec = 0;
+
+ /* determine logarithm (log2) of the fragment size */
+ for (fragment_spec=0; (1 << fragment_spec) < fragment_size;
+ fragment_spec++);
+
+ /* use two fragments (play one fragment, prepare the other);
+ one fragment would result in interrupted audio output, more
+ than two fragments would raise audio output latency to much */
+ fragment_spec |= 0x00020000;
+
+ /* Example for fragment specification:
+ - 2 buffers / 512 bytes (giving 1/16 second resolution for 8 kHz)
+ - (with stereo the effective buffer size will shrink to 256)
+ => fragment_size = 0x00020009 */