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

BOOL PSoundChannelDirectSound::PlayFile ( const PFilePath file,
BOOL  wait 
) [virtual]

Play a sound file to the open device. If the wait# parameter is TRUE then the function does not return until the file has been played. If FALSE then the sound play is begun asynchronously and the function returns immediately.

Note if the driver is closed of the object destroyed then the sound play is aborted.

Also note that not all possible sounds and sound files are playable by this library. No format conversions between sound object and driver are performed.

Returns:
TRUE if the sound is playing or has played.

Reimplemented from PSoundChannel.

Definition at line 885 of file sound_directsound.cxx.

References PFile::Close(), PChannel::GetLastReadCount(), PChannel::IsOpen(), PFile::Read(), PFile::ReadOnly, WaitForPlayCompletion(), and Write().

{
  BYTE buffer [512];
  mStreaming = false;

  PFile file (filename, PFile::ReadOnly);

  if (!file.IsOpen())
    return FALSE;

  for (;;) 
    {

    if (!file.Read (buffer, 512))
      break;

    PINDEX len = file.GetLastReadCount();
    if (len == 0)
      break;
    if (!Write(buffer, len))
      break;
  }

  file.Close();

  if (wait)
    return WaitForPlayCompletion();

  return TRUE;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index