}
wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer(
- wxFragBufPtr *list, wxUint8 max_queue)
+ xFragBufPtr *list, wxUint8 max_queue)
{
if (!list)
return NULL;
wxFragBufPtr *ptr;
char *raw_buf;
wxUint32 rawbuf_size;
+ wxSoundCodec *codec = buf->GetCurrentCodec();
if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT))
return FALSE;
if (!ptr)
return FALSE;
- // Find the end of the buffer
- raw_buf = ptr->data + ptr->ptr;
- rawbuf_size = ptr->size - ptr->ptr;
+ codec->SetOutStream(ptr->sndbuf);
+ codec->InitIO(m_drvformat);
// Fill it up
- buf->OnNeedOutputData(raw_buf, rawbuf_size);
+ codec->Decode();
// No data to fill the buffer: dequeue the current wxSndBuffer
- if (!rawbuf_size) {
+ if (!codec->Available()) {
if (buf->IsNotSet(wxSND_KEEPQUEUED)) {
buf->Set(wxSND_UNQUEUEING);
m_iodrv->m_buffers.DeleteObject(buf);
// Data: append it to the list
ptr->buffers->Append(buf);
- ptr->ptr += rawbuf_size;
-
// Output buffer full: send it to the driver
- if (ptr->ptr == ptr->size) {
+ if (ptr->sndbuf->GetDataLeft()) {
ptr->state = wxBUFFER_FFILLED;
OnBufferFilled(ptr, wxSND_OUTPUT);
}
bool wxFragmentBuffer::NotifyInputBuffer(wxSndBuffer *buf)
{
- wxFragBufPtr *ptr;
- char *raw_buf;
- wxUint32 rawbuf_size;
-
- if (!m_iodrv->OnSetupDriver(*buf, wxSND_INPUT))
- return FALSE;
-
- while (1) {
- ptr = FindFreeBuffer(m_lstiptrs, m_maxiq);
- if (!ptr)
+ /*
+ wxFragBufPtr *ptr;
+ char *raw_buf;
+ wxUint32 rawbuf_size;
+
+ if (!m_iodrv->OnSetupDriver(*buf, wxSND_INPUT))
return FALSE;
+ while (1) {
+ ptr = FindFreeBuffer(m_lstiptrs, m_maxiq);
+ if (!ptr)
+ return FALSE;
+
raw_buf = ptr->data + ptr->ptr;
rawbuf_size = ptr->size - ptr->ptr;
m_iodrv->m_buffers.DeleteObject(buf);
}
- // Get data now when there isn't anymore buffer in the queue
if (!LastBuffer() && ptr->ptr) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
ptr->ptr += rawbuf_size;
- // Input buffer full => get data
+
if (ptr->ptr == ptr->size) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
return FALSE;
}
}
+ */
+
return TRUE;
}
node = ptr->buffers->First();
}
- ptr->ptr = 0;
+ ptr->sndbuf->ResetBuffer();
ptr->state = wxBUFFER_FREE;
}