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

BOOL PSoundChannelSunAudio::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.

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 391 of file sound_sunaudio.cxx.

References PChannel::ConvertOSError(), PChannel::GetErrorCode(), PChannel::Interrupted, PChannel::lastReadCount, PChannel::NotOpen, and PChannel::SetErrorValues().

  int ret;
  if (os_handle < 0)
    return SetErrorValues(NotOpen, EBADF);

  PINDEX total = 0;
  while (total < length) {
    PINDEX bytes = 0;

    while (!ConvertOSError(bytes = ::read(os_handle, (void *)(((unsigned char *)buffer) + total), length-total))) {
      if ((GetErrorCode() != Interrupted) || (os_handle < 0)) {
        PTRACE(6, "SunAudio\tRead failed");
        return FALSE;
      PTRACE(6, "SunAudio\tRead interrupted");

    total += bytes;
    if (total != length)
      PTRACE(6, "SunAudio\tRead completed short - " << total << " vs " << length << ". Reading more data");

  lastReadCount = total;

  if (lastReadCount != length)
    PTRACE(6, "SunAudio\tRead completed short - " << lastReadCount << " vs " << length);
    PTRACE(6, "SunAudio\tRead completed");
  return TRUE;

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index