|
vdr-plugin-softhddevice-drm-gles 1.6.7
|
Alsa Interface. More...
#include <alsadevice.h>
Public Member Functions | |
| cAlsaDevice (cSoftHdConfig *) | |
| bool | Init (void) |
| Initialize the ALSA audio output module. | |
| void | Exit (void) |
| Cleanup the ALSA audio output module. | |
| int | Setup (int, int, bool, int) |
| Setup ALSA audio for requested format. | |
| int | Write (const void *, int) |
| Write data to the output device. | |
| void | FlushBuffers (bool) |
| Flush ALSA buffers internally. | |
| bool | HandleError (int) |
| Handle an alsa error. | |
| void | SetVolume (int) |
| Set alsa mixer volume (0-1000) | |
| int | WaitUntilReady (void) |
| Wait until data can be written or read to/from the device (Timeout is 150ms currently) | |
| bool | CheckWrittenFrames (int, int) |
| Check, if all frames have been written. | |
| int | GetHwDelayFrames (void) |
| Return the current hardware audio delay in frames. | |
| int | GetAvailableBufferFrames (bool) |
| Get the number of frames that could be written to the device. | |
| std::vector< std::string > | GetChannelLayoutAsArray (void) |
| Put ALSA channel layout in a dynamic array of strings. | |
| int | GetBufferSizeFrames (void) |
| int | GetDownmix (void) |
| int | GetHwNumChannels (void) |
| int | GetHwSampleRate (void) |
| bool | IsRunning (void) |
| bool | IsPassthroughActive (void) |
| void | SetPassthroughMask (int mask) |
| int | GetPassthroughMask (void) const |
| void | SetAutoAES (bool appendAes) |
| void | SetDownmix (int downMix) |
| size_t | FramesToBytes (int frames) |
| int | BytesToFrames (size_t bytes) |
| int64_t | PtsToMs (int64_t pts, double timebase) |
| int64_t | MsToPts (int64_t ptsMs, double timebase) |
| int | MsToFrames (int milliseconds) |
| int | FramesToMs (int frames) |
| int64_t | FramesToPts (int frames, double timebase) |
| double | FramesToMsDouble (int frames) |
Private Member Functions | |
| bool | ShouldAppendAES (void) |
| char * | OpenDevice (const char *) |
| Open an ALSA device. | |
| char * | FindDevice (const char *, const char *) |
| Find alsa device giving some search hints. | |
| bool | InitDevice (void) |
| Search for an alsa pcm device and open it. | |
| void | InitMixer (void) |
| Initialize the ALSA mixer. | |
Private Attributes | |
| const char * | m_pPCMDevice |
| Alsa PCM device name. | |
| snd_pcm_t * | m_pPCMHandle = nullptr |
| alsa pcm handle | |
| const char * | m_pMixerDevice = nullptr |
| mixer device name (not used) | |
| const char * | m_pMixerChannel |
| mixer channel name | |
| snd_mixer_t * | m_pMixer = nullptr |
| alsa mixer handle | |
| snd_mixer_elem_t * | m_pMixerElem = nullptr |
| alsa mixer element | |
| snd_pcm_uframes_t | m_bufferSizeFrames = 0 |
| alsa buffer size in frames | |
| int | m_ratio |
| internal -> mixer ratio * 1000 | |
| bool | m_appendAES |
| flag to automatic append AES | |
| int | m_passthroughMask |
| passthrough mask | |
| std::atomic< bool > | m_passthroughActive = false |
| set, if passthrough is active | |
| unsigned int | m_hwSampleRate = 0 |
| hardware sample rate in Hz | |
| unsigned int | m_hwNumChannels = 0 |
| number of hardware channels | |
| int | m_downmix |
| set stereo downmix | |
| bool | m_useMmap |
| use mmap | |
Alsa Interface.
Definition at line 36 of file alsadevice.h.
| cAlsaDevice::cAlsaDevice | ( | cSoftHdConfig * | m_pConfig | ) |
Definition at line 39 of file alsadevice.cpp.
Definition at line 68 of file alsadevice.h.
References m_pPCMHandle.
Referenced by cSoftHdAudio::Enqueue(), cSoftHdAudio::GetOutputPtsMsInternal(), cSoftHdAudio::GetUsedRingbufferMs(), cSoftHdAudio::SendAudio(), and cSoftHdAudio::SendPause().
Check, if all frames have been written.
| true,if | all frames have been written or we should try again later |
| false,if | not all frames have been written or an error occured |
Definition at line 454 of file alsadevice.cpp.
References LOGERROR, LOGWARNING, and m_pPCMHandle.
Referenced by cSoftHdAudio::SendAudio(), and cSoftHdAudio::SendPause().
Cleanup the ALSA audio output module.
Definition at line 73 of file alsadevice.cpp.
References m_pMixer, m_pMixerElem, and m_pPCMHandle.
Referenced by cSoftHdAudio::Exit().
Find alsa device giving some search hints.
| devname | interface identification (e.g. "pcm") |
| hint | string to compare with device name hints |
Definition at line 141 of file alsadevice.cpp.
References LOGWARNING, and OpenDevice().
Referenced by InitDevice().
Flush ALSA buffers internally.
| drop | force a snd_pcm_drop of the audio frames already in the kernel |
Definition at line 479 of file alsadevice.cpp.
References L_SOUND, LOGDEBUG2, LOGERROR, m_passthroughActive, and m_pPCMHandle.
Referenced by cSoftHdAudio::DropAlsaBuffers(), and cSoftHdAudio::FlushAlsaBuffers().
Definition at line 67 of file alsadevice.h.
References m_pPCMHandle.
Referenced by cSoftHdAudio::CyclicCall(), cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::Enqueue(), and cSoftHdAudio::SendAudio().
Definition at line 72 of file alsadevice.h.
References m_hwSampleRate.
Referenced by cSoftHdAudio::GetHardwareOutputDelayMs(), cSoftHdAudio::GetHardwareOutputPtsMs(), cSoftHdAudio::GetOutputPtsMsInternal(), cSoftHdAudio::GetUsedRingbufferMs(), and cSoftHdAudio::SetHwDelayBaseline().
Definition at line 74 of file alsadevice.h.
References m_hwSampleRate.
Referenced by cSoftHdAudio::ClockDriftCompensation().
Definition at line 73 of file alsadevice.h.
References m_hwSampleRate, and MsToPts().
Referenced by cSoftHdAudio::Enqueue().
Get the number of frames that could be written to the device.
| sync | synchronize with hardware first |
Definition at line 554 of file alsadevice.cpp.
References L_SOUND, LOGDEBUG2, LOGWARNING, and m_pPCMHandle.
Referenced by cSoftHdAudio::ClockDriftCompensation(), and cSoftHdAudio::CyclicCall().
Definition at line 55 of file alsadevice.h.
References m_bufferSizeFrames.
Referenced by cSoftHdAudio::ClockDriftCompensation().
Definition at line 56 of file alsadevice.h.
References m_downmix.
Referenced by cSoftHdAudio::InitFilter(), and cSoftHdAudio::Setup().
Return the current hardware audio delay in frames.
Definition at line 516 of file alsadevice.cpp.
References m_pPCMHandle.
Referenced by cSoftHdAudio::GetHardwareOutputDelayMs(), cSoftHdAudio::GetHardwareOutputPtsMs(), and cSoftHdAudio::SetHwDelayBaseline().
Definition at line 57 of file alsadevice.h.
References m_hwNumChannels.
Referenced by cSoftHdAudio::InitFilter(), cSoftHdAudio::Setup(), and cSoftHdAudio::SetVolume().
Definition at line 58 of file alsadevice.h.
References m_hwSampleRate.
Referenced by cSoftHdAudio::InitFilter(), and cSoftHdAudio::Setup().
Definition at line 62 of file alsadevice.h.
References m_passthroughMask.
Referenced by cSoftHdAudio::GetPassthroughMask().
Handle an alsa error.
Definition at line 531 of file alsadevice.cpp.
References LOGERROR, m_passthroughActive, and m_pPCMHandle.
Referenced by cSoftHdAudio::CyclicCall().
Initialize the ALSA audio output module.
Definition at line 53 of file alsadevice.cpp.
References AlsaNoopCallback(), InitDevice(), and InitMixer().
Referenced by cSoftHdAudio::LazyInit().
Search for an alsa pcm device and open it.
Definition at line 179 of file alsadevice.cpp.
References FindDevice(), L_SOUND, LOGDEBUG2, LOGERROR, LOGINFO, LOGWARNING, m_pPCMDevice, m_pPCMHandle, and OpenDevice().
Referenced by Init().
Initialize the ALSA mixer.
Definition at line 248 of file alsadevice.cpp.
References L_SOUND, LOGDEBUG2, LOGERROR, m_pMixer, m_pMixerChannel, m_pMixerDevice, m_pMixerElem, and m_ratio.
Referenced by Init().
Definition at line 60 of file alsadevice.h.
References m_passthroughActive.
Referenced by cSoftHdAudio::ClockDriftCompensation(), cSoftHdAudio::CyclicCall(), cSoftHdAudio::Enqueue(), cSoftHdAudio::SendAudio(), cSoftHdAudio::SetHwDelayBaseline(), cSoftHdAudio::Setup(), and cSoftHdAudio::SetVolume().
Definition at line 59 of file alsadevice.h.
References m_hwSampleRate, and m_pPCMHandle.
Referenced by cSoftHdAudio::GetHardwareOutputDelayMs(), and cSoftHdAudio::GetHardwareOutputPtsMs().
Definition at line 71 of file alsadevice.h.
References m_hwSampleRate.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs().
Definition at line 70 of file alsadevice.h.
Referenced by FramesToPts(), and cSoftHdAudio::GetHardwareOutputPtsTimebaseUnits().
Open an ALSA device.
| device | alsa device to be opened |
Definition at line 93 of file alsadevice.cpp.
References L_SOUND, LOGDEBUG2, LOGWARNING, m_pPCMHandle, and ShouldAppendAES().
Referenced by FindDevice(), and InitDevice().
Definition at line 69 of file alsadevice.h.
Referenced by cSoftHdAudio::Enqueue(), cSoftHdAudio::GetInputPtsMs(), and cSoftHdAudio::GetOutputPtsMsInternal().
Definition at line 63 of file alsadevice.h.
References m_appendAES.
Referenced by cSoftHdAudio::SetAutoAES().
Definition at line 64 of file alsadevice.h.
References m_downmix.
Referenced by cSoftHdAudio::SetDownmix().
Definition at line 61 of file alsadevice.h.
References m_passthroughMask.
Referenced by cSoftHdAudio::SetPassthroughMask().
Setup ALSA audio for requested format.
| channels | Channels requested |
| sample_rate | SampleRate requested |
| passthrough | use pass-through (AC-3, ...) device |
| 0 | everything ok |
| -1 | something gone wrong |
Definition at line 307 of file alsadevice.cpp.
References GetChannelLayoutAsArray(), L_SOUND, LOGDEBUG2, LOGERROR, LOGINFO, LOGWARNING, m_bufferSizeFrames, m_downmix, m_hwNumChannels, m_hwSampleRate, m_passthroughActive, m_pPCMHandle, and m_useMmap.
Referenced by cSoftHdAudio::Setup().
Set alsa mixer volume (0-1000)
| volume | volume (0 .. 1000) |
Definition at line 577 of file alsadevice.cpp.
References m_pMixer, m_pMixerElem, and m_ratio.
Referenced by cSoftHdAudio::SetVolume().
Definition at line 96 of file alsadevice.h.
References m_appendAES, and m_passthroughMask.
Referenced by OpenDevice().
Wait until data can be written or read to/from the device (Timeout is 150ms currently)
Definition at line 417 of file alsadevice.cpp.
References L_SOUND, LOGDEBUG2, LOGERROR, and m_pPCMHandle.
Referenced by cSoftHdAudio::CyclicCall().
Write data to the output device.
Definition at line 440 of file alsadevice.cpp.
References m_pPCMHandle, and m_useMmap.
Referenced by cSoftHdAudio::SendAudio(), and cSoftHdAudio::SendPause().
|
private |
flag to automatic append AES
Definition at line 88 of file alsadevice.h.
Referenced by SetAutoAES(), and ShouldAppendAES().
|
private |
alsa buffer size in frames
Definition at line 86 of file alsadevice.h.
Referenced by GetBufferSizeFrames(), and Setup().
|
private |
set stereo downmix
Definition at line 93 of file alsadevice.h.
Referenced by GetDownmix(), SetDownmix(), and Setup().
number of hardware channels
Definition at line 92 of file alsadevice.h.
Referenced by GetHwNumChannels(), and Setup().
hardware sample rate in Hz
Definition at line 91 of file alsadevice.h.
Referenced by FramesToMs(), FramesToMsDouble(), FramesToPts(), GetHwSampleRate(), IsRunning(), MsToFrames(), and Setup().
set, if passthrough is active
Definition at line 90 of file alsadevice.h.
Referenced by FlushBuffers(), HandleError(), IsPassthroughActive(), and Setup().
|
private |
passthrough mask
Definition at line 89 of file alsadevice.h.
Referenced by GetPassthroughMask(), SetPassthroughMask(), and ShouldAppendAES().
|
private |
alsa mixer handle
Definition at line 83 of file alsadevice.h.
Referenced by Exit(), InitMixer(), and SetVolume().
|
private |
alsa mixer element
Definition at line 84 of file alsadevice.h.
Referenced by Exit(), InitMixer(), and SetVolume().
alsa pcm handle
Definition at line 78 of file alsadevice.h.
Referenced by BytesToFrames(), CheckWrittenFrames(), Exit(), FlushBuffers(), FramesToBytes(), GetAvailableBufferFrames(), GetChannelLayoutAsArray(), GetHwDelayFrames(), HandleError(), InitDevice(), IsRunning(), OpenDevice(), Setup(), WaitUntilReady(), and Write().
|
private |
internal -> mixer ratio * 1000
Definition at line 87 of file alsadevice.h.
Referenced by InitMixer(), and SetVolume().
|
private |