Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PSoundChannelDirectSound::Read ( void *  buf,
PINDEX  len 
) [virtual]

Low level read from the channel. This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns FALSE to determine what caused the failure.

Returns:
TRUE indicates that at least one character was read from the channel. FALSE means no bytes were read due to timeout or some other I/O error.

Reimplemented from PSoundChannel.

Definition at line 486 of file sound_directsound.cxx.

References PChannel::lastReadCount.

{

  PINDEX read = 0, to_read = len;
  BYTE * output_buffer = (BYTE*) buf;
  
  PWaitAndSignal mutex(bufferMutex);

  if (!isInitialised) 
    {
      PTRACE (4, "PSoundChannelDirectSound::Read : Device not initialised ");
      return false;
    }
 
  lastReadCount = 0;

  while (to_read > mOutburst) 
    {
     
      /* Will read from device buffer minimum between the data left to read, and the available space */
      read = ReadFromDXBuffer (output_buffer,
                         MIN (GetDXBufferFreeSpace (), to_read));
      to_read -= read;
      lastReadCount += read;
      output_buffer += read; /* Increment the buffer pointer */
      
      /* Wait as buffer is being played */
      FlushBuffer ();
    }

  return true;
}

Generated by  Doxygen 1.6.0   Back to index