2017-04-17 20:57:07 +02:00
|
|
|
//
|
|
|
|
// libtgvoip is free and unencumbered public domain software.
|
|
|
|
// For more information, see http://unlicense.org or the UNLICENSE file
|
|
|
|
// you should have received with this source code distribution.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LIBTGVOIP_AUDIOOUTPUTALSA_H
|
|
|
|
#define LIBTGVOIP_AUDIOOUTPUTALSA_H
|
|
|
|
|
|
|
|
#include "../../audio/AudioOutput.h"
|
|
|
|
#include "../../threading.h"
|
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
|
|
|
|
namespace tgvoip{
|
|
|
|
namespace audio{
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
class AudioOutputALSA : public AudioOutput{
|
2017-04-17 20:57:07 +02:00
|
|
|
public:
|
2017-05-04 23:44:23 +02:00
|
|
|
AudioOutputALSA(std::string devID);
|
2017-04-17 20:57:07 +02:00
|
|
|
virtual ~AudioOutputALSA();
|
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
|
|
|
virtual bool IsPlaying();
|
2017-05-04 23:44:23 +02:00
|
|
|
virtual void SetCurrentDevice(std::string devID);
|
|
|
|
static void EnumerateDevices(std::vector<AudioOutputDevice>& devs);
|
2017-04-17 20:57:07 +02:00
|
|
|
|
|
|
|
private:
|
2018-11-09 18:23:18 +01:00
|
|
|
void RunThread();
|
2017-04-17 20:57:07 +02:00
|
|
|
|
|
|
|
int (*_snd_pcm_open)(snd_pcm_t** pcm, const char* name, snd_pcm_stream_t stream, int mode);
|
|
|
|
int (*_snd_pcm_set_params)(snd_pcm_t* pcm, snd_pcm_format_t format, snd_pcm_access_t access, unsigned int channels, unsigned int rate, int soft_resample, unsigned int latency);
|
|
|
|
int (*_snd_pcm_close)(snd_pcm_t* pcm);
|
|
|
|
snd_pcm_sframes_t (*_snd_pcm_writei)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
|
|
|
|
int (*_snd_pcm_recover)(snd_pcm_t* pcm, int err, int silent);
|
|
|
|
const char* (*_snd_strerror)(int errnum);
|
|
|
|
void* lib;
|
|
|
|
|
|
|
|
snd_pcm_t* handle;
|
2018-05-15 20:23:46 +02:00
|
|
|
Thread* thread;
|
2017-04-17 20:57:07 +02:00
|
|
|
bool isPlaying;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //LIBTGVOIP_AUDIOOUTPUTALSA_H
|