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 // Volume control
19 int GetVolumeChannel(int channel) const override; // VolumeBase
20 void SetVolumeChannel(int channel, int volume) override; // VolumeBase
21 static QMap<QString, QString> *GetDevices(const char *type);
22
23 protected:
24 // You need to implement the following functions
25 bool OpenDevice(void) override; // AudioOutputBase
26 void CloseDevice(void) override; // AudioOutputBase
27 void WriteAudio(unsigned char *aubuf, int size) override; // AudioOutputBase
28 int GetBufferedOnSoundcard(void) const override; // AudioOutputBase
29 AudioOutputSettings* GetOutputSettings(bool passthrough) override; // AudioOutputBase
30
31 private:
32 int TryOpenDevice(int open_mode, bool try_ac3);
33 int GetPCMInfo(int &card, int &device, int &subdevice);
34 bool IncPreallocBufferSize(int requested, int buffer_time);
35 inline int SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
36 uint channels, uint rate, uint buffer_time,
37 uint period_time);
38 static QByteArray *GetELD(int card, int device, int subdevice);
39 // Volume related
40 bool OpenMixer(void);
41
42 private:
44 int m_pbufSize {-1};
45 int m_card {-1};
46 int m_device {-1};
47 int m_subdevice {-1};
49 QString m_lastDevice;
50
51 struct {
52 QString device;
53 QString control;
54 snd_mixer_t* handle { nullptr };
55 snd_mixer_elem_t* elem { nullptr };
56 long volmin { 0L };
57 long volmax { 0L };
58 long volrange { 0L };
60
61};
62#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:68