[DEV] update new AirTAudio

This commit is contained in:
Edouard DUPIN 2014-03-11 21:54:43 +01:00
parent d274d793ba
commit baf70033f3
7 changed files with 27 additions and 29 deletions

View File

@ -62,7 +62,7 @@ int32_t eaudiofx::GeneratorFile::init(void) {
EAUDIOFX_ERROR("Can not open the input file ...");
return eaudiofx::ERR_FAIL;
}
return eaudiofx::ERR_NONE;
}
@ -74,7 +74,7 @@ int32_t eaudiofx::GeneratorFile::unInit(void) {
EAUDIOFX_ERROR("Can not close the input file ...");
return eaudiofx::ERR_FAIL;
}
return eaudiofx::ERR_NONE;
}

View File

@ -8,7 +8,7 @@
#include <eaudiofx/base/GeneratorRtAudio.h>
#include <eaudiofx/core/BufferAudioRaw.h>
#include <rtaudio/RtAudio.h>
#include <airtaudio/Interface.h>
eaudiofx::GeneratorRtAudio::GeneratorRtAudio(void) {
setLive(true);

View File

@ -9,13 +9,13 @@
#include <eaudiofx/base/ReceiverRtAudio.h>
#include <eaudiofx/core/BufferAudioRaw.h>
#include <eaudiofx/debug.h>
#include <rtaudio/RtAudio.h>
#include <airtaudio/Interface.h>
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
void *_inputBuffer,
unsigned int _nBufferFrames,
double _streamTime,
RtAudioStreamStatus _status,
airtaudio::streamStatus _status,
void* _userData) {
if (_userData == NULL) {
EAUDIOFX_ERROR("Null class pointer");
@ -37,7 +37,7 @@ int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
size_t _nBufferFrames,
double _streamTime,
RtAudioStreamStatus _status) {
airtaudio::streamStatus _status) {
// Request block input:
int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f);
if (ret != eaudiofx::ERR_NONE) {
@ -85,40 +85,35 @@ eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) {
int32_t eaudiofx::ReceiverRtAudio::init(void) {
m_dac.instanciate();
EAUDIOFX_DEBUG("Create RTAudio generator ...");
if ( m_dac.getDeviceCount() < 1 ) {
EAUDIOFX_ERROR("No audio devices found!");
exit( 0 );
}
EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice());
RtAudio::StreamParameters parameters;
m_parameters.deviceId = m_dac.getDefaultOutputDevice();
m_parameters.nChannels = 2;
m_parameters.firstChannel = 0;
unsigned int bufferFrames = 256;
try {
EAUDIOFX_DEBUG("OPEN Stream ...");
m_dac.openStream(&m_parameters, NULL, RTAUDIO_FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this);
m_dac.startStream();
}catch ( RtError& e ) {
e.printMessage();
exit( 0 );
}
EAUDIOFX_DEBUG("OPEN Stream ...");
// TODO : Check return error
m_dac.openStream(&m_parameters, NULL, airtaudio::FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this);
// TODO : Check return error
m_dac.startStream();
return eaudiofx::ERR_NONE;
};
int32_t eaudiofx::ReceiverRtAudio::unInit(void) {
try {
EAUDIOFX_DEBUG("STOP Stream ...");
// Stop the stream
m_dac.stopStream();
} catch (RtError& e) {
e.printMessage();
return eaudiofx::ERR_NONE;
}
EAUDIOFX_DEBUG("STOP Stream ...");
// Stop the stream
m_dac.stopStream();
// TODO : Check return error
if ( m_dac.isStreamOpen() ) {
m_dac.closeStream();
}
return eaudiofx::ERR_NONE;
};

View File

@ -10,7 +10,7 @@
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
#include <eaudiofx/core/BlockReceiver.h>
#include <rtaudio/RtAudio.h>
#include <airtaudio/Interface.h>
namespace eaudiofx {
class ReceiverRtAudio : public eaudiofx::BlockReceiver {
@ -19,13 +19,13 @@ namespace eaudiofx {
void *_inputBuffer,
unsigned int _nBufferFrames,
double _streamTime,
RtAudioStreamStatus _status,
airtaudio::streamStatus _status,
void* _userData);
// class callback
int32_t needData(float* _outputBuffer,
size_t _nBufferFrames,
double _streamTime,
RtAudioStreamStatus _status);
airtaudio::streamStatus _status);
public:
ReceiverRtAudio(void);
virtual ~ReceiverRtAudio(void) {};
@ -33,8 +33,8 @@ namespace eaudiofx {
virtual int32_t init(void);
virtual int32_t unInit(void);
protected:
RtAudio m_dac;
RtAudio::StreamParameters m_parameters;
airtaudio::Interface m_dac;
airtaudio::StreamParameters m_parameters;
};
};

View File

@ -102,6 +102,7 @@ int32_t eaudiofx::Block::unLinkBuffer(const eaudiofx::Buffer* _buffer) {
it.second.m_buffer = NULL;
}
}
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Block::unLinkBuffer(const std::string& _name) {

View File

@ -125,11 +125,13 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa
int32_t eaudiofx::BlockDecoder::init(void) {
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::BlockDecoder::unInit(void) {
return eaudiofx::ERR_NONE;
}

View File

@ -38,7 +38,7 @@ def create(target):
])
# name of the dependency
myModule.add_module_depend(['ewol', 'rtaudio'])
myModule.add_module_depend(['ewol', 'airtaudio'])
myModule.add_export_path(tools.get_current_path(__file__))