MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Data Structures | Public Types | Public Member Functions | Data Fields
AudioOutput Struct Reference

`#include <Internal.hxx>`

Collaboration diagram for AudioOutput:
[legend]

## Data Structures
struct | Request
| Additional data for command. More...

## Public Types
enum | Command { Command::NONE, Command::ENABLE, Command::DISABLE, Command::OPEN, Command::CLOSE, Command::PAUSE, Command::DRAIN, Command::CANCEL, Command::KILL }

## Public Member Functions
| AudioOutput (const AudioOutputPlugin &_plugin, const ConfigBlock &block)
| Throws #std::runtime_error on error. More...
| ~AudioOutput ()
void | Setup (EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, MixerListener &mixer_listener, const ConfigBlock &block)
void | StartThread ()
void | StopThread ()
void | BeginDestroy ()
void | FinishDestroy ()
const char * | GetName () const
bool | IsEnabled () const
| Caller must lock the mutex. More...
bool | IsOpen () const
| Caller must lock the mutex. More...
bool | IsCommandFinished () const
| Caller must lock the mutex. More...
const std::exception_ptr & | GetLastError () const
| Caller must lock the mutex. More...
void | WaitForCommand ()
| Waits for command completion. More...
void | CommandAsync (Command cmd)
| Sends a command, but does not wait for completion. More...
void | CommandWait (Command cmd)
| Sends a command to the AudioOutput object and waits for completion. More...
void | LockCommandWait (Command cmd)
| Lock the AudioOutput object and execute the command synchronously. More...
void | EnableAsync ()
| Enables the device, but don't wait for completion. More...
void | DisableAsync ()
| Disables the device, but don't wait for completion. More...
void | EnableDisableAsync ()
| Attempt to enable or disable the device as specified by the enabled attribute; attempt to sync it with really_enabled (wrapper for EnableAsync() or DisableAsync()). More...
void | LockPauseAsync ()
void | CloseWait ()
| Same LockCloseWait(), but expects the lock to be held by the caller. More...
void | LockCloseWait ()
void | LockRelease ()
| Closes the audio output, but if the "always_on" flag is set, put it into pause mode instead. More...
void | SetReplayGainMode (ReplayGainMode _mode)
bool | Open (const AudioFormat audio_format, const MusicPipe &mp)
| Caller must lock the mutex. More...
bool | LockUpdate (const AudioFormat audio_format, const MusicPipe &mp, bool force)
| Opens or closes the device, depending on the "enabled" flag. More...
void | LockPlay ()
void | LockDrainAsync ()
void | LockCancelAsync ()
| Clear the "allow_play" flag and send the "CANCEL" command asynchronously. More...
void | LockAllowPlay ()
| Set the "allow_play" and signal the thread. More...
gcc_pure bool | IsChunkConsumed (const MusicChunk &chunk) const
| Did we already consumed this chunk? More...
gcc_pure bool | LockIsChunkConsumed (const MusicChunk &chunk)
void | ClearTailChunk (const MusicChunk &chunk)

## Data Fields
const char * | name
| The device's configured display name. More...
const AudioOutputPlugin & | plugin
| The plugin which implements this output device. More...
Mixer * | mixer = nullptr
| The mixer object associated with this audio output device. More...
bool | tags
| Will this output receive tags from the decoder? The default is true, but it may be configured to false to suppress sending tags to the output. More...
bool | always_on
| Shall this output always play something (i.e. More...
bool | enabled = true
| Has the user enabled this device? More...
bool | really_enabled = false
| Is this device actually enabled, i.e. More...
bool | open = false
| Is the device (already) open and functional? More...
bool | pause = false
| Is the device paused? i.e. More...
bool | allow_play = true
| When this flag is set, the output thread will not do any playback. More...
bool | in_playback_loop = false
| True while the OutputThread is inside ao_play(). More...
bool | woken_for_play = false
| Has the OutputThread been woken up to play more chunks? This is set by audio_output_play() and reset by ao_play() to reduce the number of duplicate wakeups. More...
PeriodClock | fail_timer
| If not nullptr, the device has failed, and this timer is used to estimate how long it should stay disabled (unless explicitly reopened with "play"). More...
AudioFormat | config_audio_format
| The configured audio format. More...
AudioFormat | filter_audio_format
| The AudioFormat which is emitted by the Filter, with config_audio_format already applied. More...
AudioFormat | out_audio_format
| The audio_format which is really sent to the device. More...
PreparedFilter * | prepared_filter = nullptr
| The filter object of this audio output. More...
FilterObserver | volume_filter
| The #VolumeFilter instance of this audio output. More...
PreparedFilter * | prepared_replay_gain_filter = nullptr
| The replay_gain_filter_plugin instance of this audio output. More...
PreparedFilter * | prepared_other_replay_gain_filter = nullptr
| The replay_gain_filter_plugin instance of this audio output, to be applied to the second chunk during cross-fading. More...
FilterObserver | convert_filter
| The convert_filter_plugin instance of this audio output. More...
Thread | thread
| The thread handle, or nullptr if the output thread isn't running. More...
Command | command = Command::NONE
| The next command to be performed by the output thread. More...
struct AudioOutput::Request | request
Mutex | mutex
| This mutex protects open, fail_timer, #pipe. More...
Cond | cond
| This condition object wakes up the output thread after command has been set. More...
AudioOutputClient * | client
| The PlayerControl object which "owns" this output. More...
AudioOutputSource | source
| Source of audio data. More...
std::exception_ptr | last_error
| The error that occurred in the output thread. More...

## Detailed Description

Definition at line 45 of file Internal.hxx.

## Member Enumeration Documentation

enum AudioOutput::Command
| strong

Enumerator
NONE |
ENABLE |
DISABLE |
OPEN | Open the output, or reopen it if it is already open, adjusting for input AudioFormat changes.
CLOSE |
PAUSE |
DRAIN | Drains the internal (hardware) buffers of the device. This operation may take a while to complete.
CANCEL |
KILL |

Definition at line 46 of file Internal.hxx.

## Constructor & Destructor Documentation

AudioOutput::AudioOutput | ( | const AudioOutputPlugin & | _plugin,
|  | const ConfigBlock & | block
| ) |  |

Throws #std::runtime_error on error.

AudioOutput::~AudioOutput | ( |  | ) |

## Member Function Documentation

void AudioOutput::BeginDestroy | ( |  | ) |

void AudioOutput::ClearTailChunk | ( | const MusicChunk & | chunk | ) |
| inline

Definition at line 447 of file Internal.hxx.

void AudioOutput::CloseWait | ( |  | ) |

Same LockCloseWait(), but expects the lock to be held by the caller.

void AudioOutput::CommandAsync | ( | Command | cmd | ) |

Sends a command, but does not wait for completion.

Caller must lock the mutex.

void AudioOutput::CommandWait | ( | Command | cmd | ) |

Sends a command to the AudioOutput object and waits for completion.

Caller must lock the mutex.

void AudioOutput::DisableAsync | ( |  | ) |

Disables the device, but don't wait for completion.

Caller must lock the mutex.

void AudioOutput::EnableAsync | ( |  | ) |

Enables the device, but don't wait for completion.

Caller must lock the mutex.

void AudioOutput::EnableDisableAsync | ( |  | ) |
| inline

Attempt to enable or disable the device as specified by the enabled attribute; attempt to sync it with really_enabled (wrapper for EnableAsync() or DisableAsync()).

Caller must lock the mutex.

Definition at line 372 of file Internal.hxx.

void AudioOutput::FinishDestroy | ( |  | ) |

const std::exception_ptr& AudioOutput::GetLastError | ( |  | ) | const
| inline

Caller must lock the mutex.

Definition at line 319 of file Internal.hxx.

const char* AudioOutput::GetName | ( |  | ) | const
| inline

Definition at line 291 of file Internal.hxx.

gcc_pure bool AudioOutput::IsChunkConsumed | ( | const MusicChunk & | chunk | ) | const

Did we already consumed this chunk?

Caller must lock the mutex.

bool AudioOutput::IsCommandFinished | ( |  | ) | const
| inline

Caller must lock the mutex.

Definition at line 312 of file Internal.hxx.

bool AudioOutput::IsEnabled | ( |  | ) | const
| inline

Caller must lock the mutex.

Definition at line 298 of file Internal.hxx.

bool AudioOutput::IsOpen | ( |  | ) | const
| inline

Caller must lock the mutex.

Definition at line 305 of file Internal.hxx.

void AudioOutput::LockAllowPlay | ( |  | ) |

Set the "allow_play" and signal the thread.

void AudioOutput::LockCancelAsync | ( |  | ) |

Clear the "allow_play" flag and send the "CANCEL" command asynchronously.

To finish the operation, the caller has to call LockAllowPlay().

void AudioOutput::LockCloseWait | ( |  | ) |

void AudioOutput::LockCommandWait | ( | Command | cmd | ) |

Lock the AudioOutput object and execute the command synchronously.

void AudioOutput::LockDrainAsync | ( |  | ) |

gcc_pure bool AudioOutput::LockIsChunkConsumed | ( | const MusicChunk & | chunk | ) |
| inline

Definition at line 442 of file Internal.hxx.

void AudioOutput::LockPauseAsync | ( |  | ) |

void AudioOutput::LockPlay | ( |  | ) |

void AudioOutput::LockRelease | ( |  | ) |

Closes the audio output, but if the "always_on" flag is set, put it into pause mode instead.

bool AudioOutput::LockUpdate | ( | const AudioFormat | audio_format,
|  | const MusicPipe & | mp,
|  | bool | force
| ) |  |

Opens or closes the device, depending on the "enabled" flag.

Parameters

  force | true to ignore the fail_timer

Returns
  true if the device is open

bool AudioOutput::Open | ( | const AudioFormat | audio_format,
|  | const MusicPipe & | mp
| ) |  |

Caller must lock the mutex.

void AudioOutput::SetReplayGainMode | ( | ReplayGainMode | _mode | ) |
| inline

Definition at line 397 of file Internal.hxx.

void AudioOutput::Setup | ( | EventLoop & | event_loop,
|  | const ReplayGainConfig & | replay_gain_config,
|  | MixerListener & | mixer_listener,
|  | const ConfigBlock & | block
| ) |  |

void AudioOutput::StartThread | ( |  | ) |

void AudioOutput::StopThread | ( |  | ) |

void AudioOutput::WaitForCommand | ( |  | ) |

Waits for command completion.

Caller must lock the mutex.

## Field Documentation

bool AudioOutput::allow_play = true

When this flag is set, the output thread will not do any playback.

It will wait until the flag is cleared.

This is used to synchronize the "clear" operation on the shared music pipe during the CANCEL command.

Definition at line 134 of file Internal.hxx.

bool AudioOutput::always_on

Shall this output always play something (i.e.

silence), even when playback is stopped?

Definition at line 98 of file Internal.hxx.

AudioOutputClient* AudioOutput::client

The PlayerControl object which "owns" this output.

This object is needed to signal command completion.

Definition at line 253 of file Internal.hxx.

Command AudioOutput::command = Command::NONE

The next command to be performed by the output thread.

Definition at line 221 of file Internal.hxx.

Cond AudioOutput::cond

This condition object wakes up the output thread after command has been set.

Definition at line 247 of file Internal.hxx.

AudioFormat AudioOutput::config_audio_format

The configured audio format.

Definition at line 161 of file Internal.hxx.

FilterObserver AudioOutput::convert_filter

The convert_filter_plugin instance of this audio output.

It is the last item in the filter chain, and is responsible for converting the input data into the appropriate format for this audio output.

Definition at line 210 of file Internal.hxx.

bool AudioOutput::enabled = true

Has the user enabled this device?

Definition at line 103 of file Internal.hxx.

PeriodClock AudioOutput::fail_timer

If not nullptr, the device has failed, and this timer is used to estimate how long it should stay disabled (unless explicitly reopened with "play").

Definition at line 156 of file Internal.hxx.

AudioFormat AudioOutput::filter_audio_format

The AudioFormat which is emitted by the Filter, with config_audio_format already applied.

This is used to decide whether this object needs to be closed and reopened upon AudioFormat changes.

Definition at line 169 of file Internal.hxx.

bool AudioOutput::in_playback_loop = false

True while the OutputThread is inside ao_play().

This means the PlayerThread does not need to wake up the OutputThread when new chunks are added to the MusicPipe, because the OutputThread is already watching that.

Definition at line 142 of file Internal.hxx.

std::exception_ptr AudioOutput::last_error

The error that occurred in the output thread.

It is cleared whenever the output is opened successfully.

Protected by mutex.

Definition at line 266 of file Internal.hxx.

Mixer* AudioOutput::mixer = nullptr

The mixer object associated with this audio output device.

May be nullptr if none is available, or if software volume is configured.

Definition at line 85 of file Internal.hxx.

Mutex AudioOutput::mutex
| mutable

This mutex protects open, fail_timer, #pipe.

Definition at line 241 of file Internal.hxx.

const char* AudioOutput::name

The device's configured display name.

Definition at line 73 of file Internal.hxx.

bool AudioOutput::open = false

Is the device (already) open and functional?

This attribute may only be modified by the output thread. It is protected with mutex: write accesses inside the output thread and read accesses outside of it may only be performed while the lock is held.

Definition at line 119 of file Internal.hxx.

AudioFormat AudioOutput::out_audio_format

The audio_format which is really sent to the device.

This is basically config_audio_format (if configured) or in_audio_format, but may have been modified by plugin->open().

Definition at line 177 of file Internal.hxx.

bool AudioOutput::pause = false

Is the device paused? i.e.

the output thread is in the ao_pause() loop.

Definition at line 125 of file Internal.hxx.

const AudioOutputPlugin& AudioOutput::plugin

The plugin which implements this output device.

Definition at line 78 of file Internal.hxx.

PreparedFilter* AudioOutput::prepared_filter = nullptr

The filter object of this audio output.

This is an instance of chain_filter_plugin.

Definition at line 183 of file Internal.hxx.

PreparedFilter* AudioOutput::prepared_other_replay_gain_filter = nullptr

The replay_gain_filter_plugin instance of this audio output, to be applied to the second chunk during cross-fading.

Definition at line 202 of file Internal.hxx.

PreparedFilter* AudioOutput::prepared_replay_gain_filter = nullptr

The replay_gain_filter_plugin instance of this audio output.

Definition at line 195 of file Internal.hxx.

bool AudioOutput::really_enabled = false

Is this device actually enabled, i.e.

the "enable" method has succeeded?

Definition at line 109 of file Internal.hxx.

struct AudioOutput::Request AudioOutput::request

AudioOutputSource AudioOutput::source

Source of audio data.

Definition at line 258 of file Internal.hxx.

bool AudioOutput::tags

Will this output receive tags from the decoder? The default is true, but it may be configured to false to suppress sending tags to the output.

Definition at line 92 of file Internal.hxx.

Thread AudioOutput::thread

The thread handle, or nullptr if the output thread isn't running.

Definition at line 216 of file Internal.hxx.

FilterObserver AudioOutput::volume_filter

The #VolumeFilter instance of this audio output.

It is used by the #SoftwareMixer.

Definition at line 189 of file Internal.hxx.

bool AudioOutput::woken_for_play = false

Has the OutputThread been woken up to play more chunks? This is set by audio_output_play() and reset by ao_play() to reduce the number of duplicate wakeups.

Definition at line 149 of file Internal.hxx.

The documentation for this struct was generated from the following file:

- output/Internal.hxx