Qtopia Home - Classes - Hierachy - Annotated - Functions - Qt Embedded |

# AudioDevice Class Reference

The AudioDevice class abstracts accessing the audio hardware. More...

`#include <audiodevice.h>`

List of all member functions.

## Public Members

- AudioDevice ( QObject * parent = 0, const char * name = 0 )
- ~AudioDevice ()
- void open ( unsigned int f = 44000, unsigned int chs = 2, unsigned int bps = 2, bool needCompletedSignal = true )
- void close ()
- unsigned int canWrite () const
- bool write ( char * buffer, unsigned int length )
- int bytesWritten ()
- unsigned int channels () const
- unsigned int frequency () const
- unsigned int bytesPerSample () const
- unsigned int bufferSize () const

## Public Slots

- void volumeChanged ( bool muted )

## Signals

- void completedIO ()
- void deviceReady ()
- void deviceOpenError ()

## Static Public Members

- void volume ( int & left, int & right )
- void setVolume ( int left, int right )
- bool muted ()
- void setMuted ( bool m )
- void increaseVolume ()
- void decreaseVolume ()

## Detailed Description

The AudioDevice class abstracts accessing the audio hardware.

This class is now a loose wrapper around QWSSoundClient which is the more direct and recommended way to access the audio hardware in Qtopia.

This class is currently private to the music and videos applications, its API may change and binary compatibilty may change in later versions.

## Member Function Documentation

### AudioDevice::AudioDevice ( QObject * parent = 0, const char * name = 0 )

Constructs an AudioDevice with parent and name.

See also write() and open().

### AudioDevice::~AudioDevice ()

Destroys the AudioDevice. Volume settings are saved for the mediaplayer.

### unsigned int AudioDevice::bufferSize () const

Retruns a value which is reasonable to write at a time.

See also write().

### unsigned int AudioDevice::bytesPerSample () const

Returns the bytes per sample data is to be formatted in, as set in the constructor.

See also AudioDevice() and write().

### int AudioDevice::bytesWritten ()

Some implementations might be able to tell how much of the written data has been processed.

### unsigned int AudioDevice::canWrite () const

Some implementations might be able to tell when it is okay to write more.

### unsigned int AudioDevice::channels () const

Returns the number of channels data is to be formatted in, as set in the constructor.

See also AudioDevice() and write().

### unsigned int AudioDevice::frequency () const

Returns the frequency data is to be formatted in, as set in the constructor.

See also AudioDevice() and write().

### bool AudioDevice::muted ()`[static]`

Returns if muting is enabled.

See also setMuted().

### void AudioDevice::open ( unsigned int f = 44000, unsigned int chs = 2, unsigned int bps = 2, bool needCompletedSignal = true )

Opens the AudioDevice using f as the frequency, chs as the channels, and bps as the number of bytes per sample of data written. If needCompletedSignal then the completedIO() signal will be emitted when the AudioDevice is ready for more data. Volume for the mediaplayer is read in from its configuration file.

### void AudioDevice::setMuted ( bool m )`[static]`

Sets device to be muted if m is true.

See also muted().

### void AudioDevice::setVolume ( int left, int right )`[static]`

Sets the volume for the left and right channels. Volume ranges for setting are from 0 to 65536.

See also volume().

### void AudioDevice::volume ( int & left, int & right )`[static]`

Retrieves the volume for the left and right channels.

See also setVolume().

### void AudioDevice::volumeChanged ( bool muted )`[slot]`

Slot to notify AudioDevice of change in global mute setting. Device is muted if muted is true.

### bool AudioDevice::write ( char * buffer, unsigned int length )

Sends length bytes from buffer to the audio device. The data is to be formatted with the set frequency, channels and bytes per sample. The latency depends on implementation, currently QWSSoundClient has approximately a latency of 100ms.

See also AudioDevice(), channels(), frequency() and bytesPerSample().

This file is part of the Qtopia platform, copyright © 1995-2004 Trolltech, all rights reserved.