Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CAudioDevice Class Reference

Base class for audio capturing/playback from and to an audio card. More...

#include <AudioDevice.h>

Inheritance diagram for CAudioDevice:

CAudioDeviceLinux List of all members.

Public Types

Signals

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

Base class for audio capturing/playback from and to an audio card.

This class is meant as a basis for OS/hardware specific audio card 'drivers'. Examples are ALSA & OSS for Linux, or Window's support for audio devices.

General design
... AudioReader/Writer ... ... image ...

How to implement
In order to make this class useful, you must subclass it and implement 8 pure virtual functions. 6 Of them are directly related to the sound supprt; they are Init(), Exit(), StartCapture(), StopCapture(), StartPlayback() and StopPlayback().

2 Other functions are GetPlaybackPointer() and ShowMixerControls(). They are described below.
Finally, since CAudioDevice is derived from QThread, the subclass must implement the run() function; this should be written as a tight loop where reading and writing to the actual device handle is done.
...timeline diagram


Member Enumeration Documentation

enum CAudioDevice::Mode
 

Enumeration values:
Capture 
Playback 


Constructor & Destructor Documentation

CAudioDevice::CAudioDevice  ) 
 

CAudioDevice::~CAudioDevice  )  [virtual]
 


Member Function Documentation

void CAudioDevice::Close  ) 
 

void CAudioDevice::Closed  )  [signal]
 

CAudioRingBufferReader * CAudioDevice::CreateReader  ) 
 

CRingBufferWriter * CAudioDevice::CreateWriter  ) 
 

virtual void CAudioDevice::Exit  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.

int CAudioDevice::GetCaptureCount  )  const [inline, protected]
 

QString CAudioDevice::GetLongName  )  const
 

virtual void CAudioDevice::GetMixerSettings QDomNode &   )  const [pure virtual]
 

Implemented in CAudioDeviceLinux.

Mode CAudioDevice::GetMode  )  const [inline, protected]
 

QString CAudioDevice::GetName  )  const
 

QString CAudioDevice::GetNodeName  )  const
 

int CAudioDevice::GetPlaybackCount  )  const [inline, protected]
 

virtual unsigned long CAudioDevice::GetPlaybackPointer  )  const [pure virtual]
 

Implemented in CAudioDeviceLinux.

SoundAttributes CAudioDevice::GetSoundAttributes  )  const
 

virtual bool CAudioDevice::Init  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.

bool CAudioDevice::IsOpen  )  const
 

bool CAudioDevice::IsValid  )  const
 

bool CAudioDevice::Open Mode  m  ) 
 

void CAudioDevice::Opened  )  [signal]
 

virtual void CAudioDevice::SetBufferLength unsigned int  len,
unsigned int  chunk_length = 0
[pure virtual]
 

Implemented in CAudioDeviceLinux.

virtual void CAudioDevice::SetBufferTime unsigned int  ms,
unsigned int  chunk_length = 0
[pure virtual]
 

Implemented in CAudioDeviceLinux.

virtual void CAudioDevice::SetMixerSettings const QDomNode &   )  const [pure virtual]
 

Implemented in CAudioDeviceLinux.

bool CAudioDevice::SetSoundAttributes const SoundAttributes attr  ) 
 

Change parameters of capture/playback.

Parameters:
attr Struct with new settings
Returns:
A boolean indicating success or not
This function will set the card to different hardware parameters for capture or playback (or both). It returns true when it was succesful in doing so.

If the new sound attributes are the same as the current ones, the function immediately returns true and does not emit a signal.

In case no stream is being captured or played back, nothing really happens; it just sets the initial parameters, emits the SoundAttributesChanged signal and returns true.

Otherwise, the following happens:

  • capture and playback are stopped
  • we wait until all buffers of all readers are drained
  • the new attributes are set
  • capture or playback is restarted
  • if that fails, we reset the old attributes and try again
  • if that fails too, the driver is left in an idle state

Changes to the sound attributes are emit()ted between stopping and starting the audio stream(s). It is possible multiple emits are generated with no audio data in between, for example when the (hardware) driver rejects the new attributes. Because of this, the receiver always knows the exact format of the audio stream when reading from its CAudioRingBufferReader.

virtual void CAudioDevice::ShowMixerControls  )  [pure virtual]
 

virtual void ShowSettingsDialog() = 0;

Implemented in CAudioDeviceLinux.

void CAudioDevice::SoundAttributesChanged const SoundAttributes  )  [signal]
 

Let the world know we (are about to) change the sound attributes.

This signal is emitted when the new attributes are set in the device. This signal can be emitted multiple times in a row between stop and start of capture/playback, depending on whether the new SoundAttributes are accepted. See also SetSoundAttributes()

virtual int CAudioDevice::StartCapture  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.

virtual int CAudioDevice::StartPlayback  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.

virtual void CAudioDevice::StopCapture  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.

virtual void CAudioDevice::StopPlayback  )  [protected, pure virtual]
 

Implemented in CAudioDeviceLinux.


Member Data Documentation

CRingBuffer CAudioDevice::m_CaptureBuffer [protected]
 

SoundAttributes CAudioDevice::m_CurrentSoundAttr [protected]
 

QString CAudioDevice::m_LongName [protected]
 

QString CAudioDevice::m_NodeName [protected]
 

CRingBuffer CAudioDevice::m_PlaybackBuffer [protected]
 

QString CAudioDevice::m_ShortName [protected]
 

bool CAudioDevice::m_Validated [protected]
 


The documentation for this class was generated from the following files:
Generated on Wed Dec 13 23:38:47 2006 for CamStream by doxygen 1.3.7