|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
-
-
- #include "play_queue.h"
- #include "utility/dspinst.h"
-
-
- int16_t * AudioPlayQueue::getBuffer(void)
- {
- while (1) {
- userblock = allocate();
- if (userblock) return userblock->data;
- yield();
- }
- }
-
- void AudioPlayQueue::playBuffer(void)
- {
- uint32_t h;
-
- if (!userblock) return;
- h = head + 1;
- if (h >= 32) h = 0;
- while (tail == h) ;
- queue[h] = userblock;
- head = h;
- userblock = NULL;
- }
-
- void AudioPlayQueue::update(void)
- {
- audio_block_t *block;
- uint32_t t;
-
- t = tail;
- if (t != head) {
- if (++t >= 32) t = 0;
- block = queue[t];
- tail = t;
- transmit(block);
- release(block);
- }
- }
-
|