2017-07-04 15:50:02 +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.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "AudioOutputModule.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "../libtgvoip/logging.h"
|
|
|
|
|
|
|
|
using namespace tgvoip;
|
|
|
|
using namespace tgvoip::audio;
|
|
|
|
|
2017-07-06 18:12:49 +02:00
|
|
|
AudioOutputModule::AudioOutputModule(std::string deviceID, void *controller){
|
2017-07-04 15:50:02 +02:00
|
|
|
wrapper = (VoIP *)((VoIPController *)controller)->implData;
|
|
|
|
}
|
|
|
|
AudioOutputModule::~AudioOutputModule(){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AudioOutputModule::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){
|
|
|
|
wrapper->configureAudioOutput(sampleRate, bitsPerSample, channels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioOutputModule::Start(){
|
|
|
|
if(running)
|
|
|
|
return;
|
|
|
|
running = true;
|
|
|
|
wrapper->startOutput();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioOutputModule::Stop(){
|
|
|
|
if(!running)
|
|
|
|
return;
|
|
|
|
wrapper->stopOutput();
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AudioOutputModule::IsPlaying(){
|
|
|
|
return running;
|
|
|
|
}
|
|
|
|
|
|
|
|
float AudioOutputModule::GetLevel(){
|
|
|
|
return wrapper->getOutputLevel();
|
|
|
|
}
|
|
|
|
|
2017-07-06 18:12:49 +02:00
|
|
|
unsigned char * AudioOutputModule::readFrames() {
|
|
|
|
unsigned char *buf = (unsigned char *) emalloc(960*2);
|
2017-07-04 15:50:02 +02:00
|
|
|
InvokeCallback(buf, 960*2);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioOutputModule::EnumerateDevices(std::vector<AudioOutputDevice>& devs) {
|
|
|
|
}
|