MythTV master
audiooutputalsa.h
Go to the documentation of this file.
1#ifndef AUDIOOUTPUTALSA
2#define AUDIOOUTPUTALSA
3
4#define ALSA_PCM_NEW_HW_PARAMS_API
5#define ALSA_PCM_NEW_SW_PARAMS_API
6#include <alsa/asoundlib.h>
7
8#include <QMap>
9
10#include "audiooutputbase.h"
11
13{
14 public:
15 explicit AudioOutputALSA(const AudioSettings &settings);
16 ~AudioOutputALSA() override;
17
18 static QMap<QString, QString> *GetDevices(const char *type);
19
20 protected:
21 // Volume control
22 int GetVolumeChannel(int channel) const override; // VolumeBase
23 void SetVolumeChannel(int channel, int volume) override; // VolumeBase
24
25 // You need to implement the following functions
26 bool OpenDevice(void) override; // AudioOutputBase
27 void CloseDevice(void) override; // AudioOutputBase
28 void WriteAudio(unsigned char *aubuf, int size) override; // AudioOutputBase
29 int GetBufferedOnSoundcard(void) const override; // AudioOutputBase
30 AudioOutputSettings* GetOutputSettings(bool passthrough) override; // AudioOutputBase
31
32 private:
33 int TryOpenDevice(int open_mode, bool try_ac3);
34 int GetPCMInfo(int &card, int &device, int &subdevice);
35 bool IncPreallocBufferSize(int requested, int buffer_time);
36 inline int SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
37 uint channels, uint rate, uint buffer_time,
38 uint period_time);
39 static QByteArray *GetELD(int card, int device, int subdevice);
40 // Volume related
41 bool OpenMixer(void);
42
43 private:
45 int m_pbufSize {-1};
46 int m_card {-1};
47 int m_device {-1};
48 int m_subdevice {-1};
50 QString m_lastDevice;
51
52 struct {
53 QString device;
54 QString control;
55 snd_mixer_t* handle { nullptr };
56 snd_mixer_elem_t* elem { nullptr };
57 long volmin { 0L };
58 long volmax { 0L };
59 long volrange { 0L };
61
62};
63#endif
int snd_pcm_t
int SetParameters(snd_pcm_t *handle, snd_pcm_format_t format, uint channels, uint rate, uint buffer_time, uint period_time)
Set the various ALSA audio parameters.
int TryOpenDevice(int open_mode, bool try_ac3)
struct AudioOutputALSA::@7 m_mixer
static QMap< QString, QString > * GetDevices(const char *type)
bool OpenDevice(void) override
int GetBufferedOnSoundcard(void) const override
Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback lat...
snd_mixer_t * handle
bool IncPreallocBufferSize(int requested, int buffer_time)
snd_mixer_elem_t * elem
void CloseDevice(void) override
~AudioOutputALSA() override
int GetVolumeChannel(int channel) const override
AudioOutputALSA(const AudioSettings &settings)
int GetPCMInfo(int &card, int &device, int &subdevice)
void WriteAudio(unsigned char *aubuf, int size) override
AudioOutputSettings * GetOutputSettings(bool passthrough) override
static QByteArray * GetELD(int card, int device, int subdevice)
void SetVolumeChannel(int channel, int volume) override
snd_pcm_t * m_pcmHandle
const int & channels() const
Definition: audiooutput.h:254
unsigned int uint
Definition: compat.h:60