2 #include "sounddecoder.h"
10 Streamer::Streamer(Source &s):
19 for(list<Buffer *>::iterator i=buffers.begin(); i!=buffers.end(); ++i)
23 void Streamer::play(SoundDecoder &s)
38 if(unsigned n = src.get_buffers_processed())
40 for(unsigned i=0; i<n; ++i)
42 src.unqueue_buffer(*buffers.front());
43 delete buffers.front();
44 buffers.erase(buffers.begin());
51 if(src.get_state()!=PLAYING && src.get_state()!=PAUSED)
54 unsigned freq = decoder->get_frequency();
55 unsigned chunk_size = freq&~0xF;
56 unsigned queued = src.get_buffers_queued();
57 vector<char> data(chunk_size);
58 for(unsigned i=queued; i<4; ++i)
63 unsigned len = decoder->read(&data[0]+pos, chunk_size-pos);
71 Buffer *buf = new Buffer;
72 buf->data(decoder->get_format(), &data[0], pos, freq);
73 src.queue_buffer(*buf);
74 buffers.push_back(buf);