int WaveOut::IsPlaying() { while (_pending) { if (NextBuffer() == -1) return 1; } return 0; }
int WaveOut::Write(const char *buf, int len) { int pos = NextBuffer(); while (pos == -1) { WaitForSingleObject(_event,INFINITE); pos = NextBuffer(); } WAVEHDR *hdr = new WAVEHDR; memset(hdr,0,sizeof(*hdr)); hdr->dwBufferLength = len; hdr->lpData = (char *)malloc(len); memcpy(hdr->lpData,buf,len); waveOutPrepareHeader(_device,hdr,sizeof(*hdr)); waveOutWrite(_device,hdr,sizeof(*hdr)); _buffers[pos] = hdr; _pending++; _written += len; return 0; }
point_count_t PgReader::read(PointBuffer& buffer, point_count_t count) { if (eof()) return 0; log()->get(LogLevel::Debug) << "readBufferImpl called with " "PointBuffer filled to " << buffer.size() << " points" << std::endl; point_count_t totalNumRead = 0; while (totalNumRead < count) { if (m_patch.remaining == 0) if (!NextBuffer()) return totalNumRead; PointId bufBegin = buffer.size(); point_count_t numRead = readPgPatch(buffer, count - totalNumRead); PointId bufEnd = bufBegin + numRead; totalNumRead += numRead; } return totalNumRead; }
void WaveOut::Flush(int t) { waveOutReset(_device); while (_pending) NextBuffer(); }