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

BOOL PSoundChannelDirectSound::Open ( const PString device,
Directions  dir,
unsigned  numChannels,
unsigned  sampleRate,
unsigned  bitsPerSample 
) [virtual]

Open the specified device for playing or recording. The device name is platform specific and is as returned in the GetDevices() function.

Returns:
TRUE if the sound device is valid for playing/recording.

Reimplemented from PSoundChannel.

Definition at line 133 of file sound_directsound.cxx.

References Close(), and SetFormat().

{
  mDirection = _dir;
  mNumChannels = _numChannels;
  mSampleRate = _sampleRate;
  mBitsPerSample = _bitsPerSample;
 
  GUID deviceGUID;

  if (!GetDeviceID (_device, &deviceGUID))
    return false;
  
  PTRACE (4, "PSoundChannelDirectSound:: Open " << ((mDirection == Player) ? "Playback" : "Recording") << " Channel");
  PTRACE (4, "PSoundChannelDirectSound  --> mNumChannels " << mNumChannels);
  PTRACE (4, "PSoundChannelDirectSound  --> mSampleRate" << mSampleRate);
  PTRACE (4, "PSoundChannelDirectSound  --> mBitsPerSample" << mBitsPerSample);
  
  Close();

  SetFormat (_numChannels,
             _sampleRate,
             _bitsPerSample);

  BOOL result = (mDirection == Recorder) ? 
                        InitCaptureDevice (&deviceGUID) : 
                        InitPlaybackDevice (&deviceGUID);

  if (!result) 
    PTRACE (4, "PSoundChannelDirectSound Could not open device " << ((mDirection == Player) ? "Playback" : "Recording") << " failed");

  return result;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index