[DEV] correct some interface of android

This commit is contained in:
Edouard DUPIN 2015-06-23 21:09:57 +02:00
parent fbd6eceee6
commit 7aad6c26c4
28 changed files with 138 additions and 142 deletions

View File

@ -51,15 +51,7 @@ public class InterfaceOutput extends Thread implements Constants {
while (!m_stopAudioThreads) { while (!m_stopAudioThreads) {
// Fill buffer with PCM data from C++ // Fill buffer with PCM data from C++
// TODO : Set if back ... ORCHESTRA.audioPlayback(streamBuffer, BUFFER_SIZE, nbChannels); ORCHESTRA.playback(uid, streamBuffer, BUFFER_SIZE);
Log.i("audioEWOL", "new data ... ");
int xxx = BUFFER_SIZE;
/*
while (xxx>0) {
Log.e("audioEWOL", (BUFFER_SIZE-xxx) + " data : " + streamBuffer[BUFFER_SIZE-xxx]);
xxx--;
}
*/
// Stream PCM data into the music AudioTrack // Stream PCM data into the music AudioTrack
m_musicTrack.write(streamBuffer, 0, BUFFER_SIZE); m_musicTrack.write(streamBuffer, 0, BUFFER_SIZE);
} }

View File

@ -57,51 +57,25 @@ public class Manager implements ManagerCallback, Constants {
public boolean openDevice(int idDevice, int freq, int nbChannel, int format) { public boolean openDevice(int idDevice, int freq, int nbChannel, int format) {
InterfaceOutput iface = new InterfaceOutput(uid, orchestraHandle, idDevice, freq, nbChannel, format); InterfaceOutput iface = new InterfaceOutput(uid, orchestraHandle, idDevice, freq, nbChannel, format);
uid++; uid++;
Log.e("Manager", "Open device : " + idDevice);
if (iface != null) { if (iface != null) {
//outputList.add(iface); //outputList.add(iface);
test = iface; test = iface;
return true; return true;
} }
return false; return false;
/*
if (idDevice == 0) {
mAudioStarted = true;
mAudioThread = new Thread(mStreams);
if (mAudioThread != null) {
mAudioThread.start();
return true;
}
return false;
} else {
Log.e("Manager", "can not open : error unknow device ...");
return false;
}
*/
} }
public boolean closeDevice(int idDevice) { public boolean closeDevice(int idDevice) {
/* Log.e("Manager", "Close device : " + idDevice);
if (idDevice == 0) { if (idDevice == 0) {
if (mAudioThread != null) { test = null;
// request audio stop
mStreams.AutoStop();
// wait the thread ended ...
try {
mAudioThread.join();
} catch(InterruptedException e) { }
mAudioThread = null;
}
mAudioStarted = false;
return true;
} else {
Log.e("Manager", "can not close : error unknow device ...");
return false;
} }
*/
return false; return false;
} }
public boolean start(int idDevice) { public boolean start(int idDevice) {
Log.e("Manager", "start device : " + idDevice);
if (idDevice == 0) { if (idDevice == 0) {
if (test != null) { if (test != null) {
test.start(); test.start();
@ -112,6 +86,7 @@ public class Manager implements ManagerCallback, Constants {
} }
public boolean stop(int idDevice) { public boolean stop(int idDevice) {
Log.e("Manager", "stop device : " + idDevice);
if (idDevice == 0) { if (idDevice == 0) {
if (test != null) { if (test != null) {
// request audio stop // request audio stop

View File

@ -27,7 +27,12 @@ public class Orchestra {
NNsetJavaManagerRemove(); NNsetJavaManagerRemove();
} }
public void playback(int flowId, short[] bufferData, int nbChunk) {
NNPlayback(flowId, bufferData, nbChunk);
}
private native <T extends ManagerCallback> void NNsetJavaManager(T managerInstance); private native <T extends ManagerCallback> void NNsetJavaManager(T managerInstance);
private native void NNsetJavaManagerRemove(); private native void NNsetJavaManagerRemove();
private native void NNPlayback(int flowId, short[] bufferData, int nbChunk);
} }

View File

@ -15,6 +15,7 @@
#include <audio/orchestra/mode.h> #include <audio/orchestra/mode.h>
#include <audio/Time.h> #include <audio/Time.h>
#include <audio/Duration.h> #include <audio/Duration.h>
#include <memory>
namespace audio { namespace audio {
namespace orchestra { namespace orchestra {
@ -46,7 +47,7 @@ namespace audio {
std::vector<int> outOffset; std::vector<int> outOffset;
}; };
class Api { class Api : public std::enable_shared_from_this<Api>{
protected: protected:
std::string m_name; std::string m_name;
public: public:
@ -167,7 +168,7 @@ namespace audio {
uint32_t _firstChannel); uint32_t _firstChannel);
public: public:
virtual bool isMasterOf(audio::orchestra::Api* _api) { virtual bool isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api) {
return false; return false;
}; };
}; };

View File

@ -26,8 +26,7 @@ std::vector<std::string> audio::orchestra::Interface::getListApi() {
void audio::orchestra::Interface::openApi(const std::string& _api) { void audio::orchestra::Interface::openApi(const std::string& _api) {
delete m_api; m_api.reset();
m_api = nullptr;
for (size_t iii=0; iii<m_apiAvaillable.size(); ++iii) { for (size_t iii=0; iii<m_apiAvaillable.size(); ++iii) {
ATA_INFO("try open " << m_apiAvaillable[iii].first); ATA_INFO("try open " << m_apiAvaillable[iii].first);
if (_api == m_apiAvaillable[iii].first) { if (_api == m_apiAvaillable[iii].first) {
@ -78,8 +77,8 @@ audio::orchestra::Interface::Interface() :
#endif #endif
} }
void audio::orchestra::Interface::addInterface(const std::string& _api, Api* (*_callbackCreate)()) { void audio::orchestra::Interface::addInterface(const std::string& _api, std::shared_ptr<Api> (*_callbackCreate)()) {
m_apiAvaillable.push_back(std::pair<std::string, Api* (*)()>(_api, _callbackCreate)); m_apiAvaillable.push_back(std::pair<std::string, std::shared_ptr<Api> (*)()>(_api, _callbackCreate));
} }
enum audio::orchestra::error audio::orchestra::Interface::clear() { enum audio::orchestra::error audio::orchestra::Interface::clear() {
@ -88,8 +87,7 @@ enum audio::orchestra::error audio::orchestra::Interface::clear() {
ATA_WARNING("Interface NOT started!"); ATA_WARNING("Interface NOT started!");
return audio::orchestra::error_none; return audio::orchestra::error_none;
} }
delete m_api; m_api.reset();
m_api = nullptr;
return audio::orchestra::error_none; return audio::orchestra::error_none;
} }
@ -140,8 +138,7 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(const std:
audio::orchestra::Interface::~Interface() { audio::orchestra::Interface::~Interface() {
ATA_INFO("Remove interface"); ATA_INFO("Remove interface");
delete m_api; m_api.reset();
m_api = nullptr;
} }
enum audio::orchestra::error audio::orchestra::Interface::openStream(audio::orchestra::StreamParameters* _outputParameters, enum audio::orchestra::error audio::orchestra::Interface::openStream(audio::orchestra::StreamParameters* _outputParameters,

View File

@ -38,13 +38,12 @@ namespace audio {
*/ */
class Interface { class Interface {
protected: protected:
std::vector<std::pair<std::string, Api* (*)()> > m_apiAvaillable; std::vector<std::pair<std::string, std::shared_ptr<Api> (*)()> > m_apiAvaillable;
protected: protected:
audio::orchestra::Api *m_api; std::shared_ptr<audio::orchestra::Api> m_api;
public: public:
void setName(const std::string& _name) { void setName(const std::string& _name) {
if (m_api == nullptr) { if (m_api == nullptr) {
return; return;
} }
m_api->setName(_name); m_api->setName(_name);
@ -59,7 +58,7 @@ namespace audio {
* @param[in] _api Type of the interface. * @param[in] _api Type of the interface.
* @param[in] _callbackCreate API creation callback. * @param[in] _callbackCreate API creation callback.
*/ */
void addInterface(const std::string& _api, Api* (*_callbackCreate)()); void addInterface(const std::string& _api, std::shared_ptr<Api> (*_callbackCreate)());
/** /**
* @brief The class constructor. * @brief The class constructor.
* @note the creating of the basic instance is done by Instanciate * @note the creating of the basic instance is done by Instanciate

View File

@ -30,8 +30,8 @@ extern "C" {
#undef __class__ #undef __class__
#define __class__ "api::Alsa" #define __class__ "api::Alsa"
audio::orchestra::Api* audio::orchestra::api::Alsa::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Alsa::create() {
return new audio::orchestra::api::Alsa(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Alsa());
} }
namespace audio { namespace audio {
@ -1563,8 +1563,8 @@ unlock:
} }
bool audio::orchestra::api::Alsa::isMasterOf(audio::orchestra::Api* _api) { bool audio::orchestra::api::Alsa::isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api) {
audio::orchestra::api::Alsa* slave = dynamic_cast<audio::orchestra::api::Alsa*>(_api); std11::shared_ptr<audio::orchestra::api::Alsa> slave = dynamic_pointer_cast<audio::orchestra::api::Alsa>(_api);
if (slave == nullptr) { if (slave == nullptr) {
ATA_ERROR("NULL ptr API (not ALSA ...)"); ATA_ERROR("NULL ptr API (not ALSA ...)");
return false; return false;

View File

@ -14,7 +14,7 @@ namespace audio {
class AlsaPrivate; class AlsaPrivate;
class Alsa: public audio::orchestra::Api { class Alsa: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Alsa(); Alsa();
virtual ~Alsa(); virtual ~Alsa();
@ -72,7 +72,7 @@ namespace audio {
const audio::orchestra::StreamOptions& _options); const audio::orchestra::StreamOptions& _options);
virtual audio::Time getStreamTime(); virtual audio::Time getStreamTime();
public: public:
bool isMasterOf(audio::orchestra::Api* _api); bool isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api);
}; };
} }
} }

View File

@ -17,13 +17,14 @@
#undef __class__ #undef __class__
#define __class__ "api::Android" #define __class__ "api::Android"
audio::orchestra::Api* audio::orchestra::api::Android::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Android::create() {
ATA_INFO("Create Android device ... "); ATA_INFO("Create Android device ... ");
return new audio::orchestra::api::Android(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Android());
} }
audio::orchestra::api::Android::Android() { audio::orchestra::api::Android::Android() :
m_uid(-1) {
ATA_INFO("Create Android interface"); ATA_INFO("Create Android interface");
} }
@ -52,7 +53,7 @@ enum audio::orchestra::error audio::orchestra::api::Android::startStream() {
// TODO : Check return ... // TODO : Check return ...
audio::orchestra::Api::startStream(); audio::orchestra::Api::startStream();
// Can not close the stream now... // Can not close the stream now...
return audio::orchestra::api::android::startStream(0); return audio::orchestra::api::android::startStream(m_uid);
} }
enum audio::orchestra::error audio::orchestra::api::Android::stopStream() { enum audio::orchestra::error audio::orchestra::api::Android::stopStream() {
@ -62,7 +63,7 @@ enum audio::orchestra::error audio::orchestra::api::Android::stopStream() {
tmpContext.audioCloseDevice(0); tmpContext.audioCloseDevice(0);
#endif #endif
// Can not close the stream now... // Can not close the stream now...
return audio::orchestra::api::android::stopStream(0); return audio::orchestra::api::android::stopStream(m_uid);
} }
enum audio::orchestra::error audio::orchestra::api::Android::abortStream() { enum audio::orchestra::error audio::orchestra::api::Android::abortStream() {
@ -75,47 +76,24 @@ enum audio::orchestra::error audio::orchestra::api::Android::abortStream() {
return audio::orchestra::error_none; return audio::orchestra::error_none;
} }
void audio::orchestra::api::Android::callBackEvent(void* _data,
int32_t _frameRate) { void audio::orchestra::api::Android::playback(int16_t* _dst, int32_t _nbChunk) {
#if 0
int32_t doStopStream = 0; int32_t doStopStream = 0;
audio::Time streamTime = getStreamTime(); audio::Time streamTime = getStreamTime();
std::vector<enum audio::orchestra::status> status; std::vector<enum audio::orchestra::status> status;
if (m_doConvertBuffer[audio::orchestra::mode_output] == true) { ATA_INFO("Need playback data " << int32_t(_nbChunk));
doStopStream = m_callback(nullptr, doStopStream = m_callback(nullptr,
audio::Time(), audio::Time(),
m_userBuffer[audio::orchestra::mode_output], &m_userBuffer[audio::orchestra::mode_output][0],
streamTime, streamTime,
_frameRate, uint32_t(_nbChunk),
status); status);
convertBuffer((char*)_data, (char*)m_userBuffer[audio::orchestra::mode_output], m_convertInfo[audio::orchestra::mode_output]); convertBuffer((char*)_dst, (char*)&m_userBuffer[audio::orchestra::mode_output][0], m_convertInfo[audio::orchestra::mode_output]);
} else {
doStopStream = m_callback(_data,
streamTime,
nullptr,
audio::Time(),
_frameRate,
status);
}
if (doStopStream == 2) { if (doStopStream == 2) {
abortStream(); abortStream();
return; return;
} }
audio::orchestra::Api::tickStreamTime(); audio::orchestra::Api::tickStreamTime();
#endif
}
void audio::orchestra::api::Android::androidCallBackEvent(void* _data,
int32_t _frameRate,
void* _userData) {
#if 0
if (_userData == nullptr) {
ATA_INFO("callback event ... nullptr pointer");
return;
}
audio::orchestra::api::Android* myClass = static_cast<audio::orchestra::api::Android*>(_userData);
myClass->callBackEvent(_data, _frameRate/2);
#endif
} }
bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device, bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
@ -128,26 +106,26 @@ bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
const audio::orchestra::StreamOptions& _options) { const audio::orchestra::StreamOptions& _options) {
bool ret = false; bool ret = false;
ATA_INFO("Probe : device=" << _device << " channels=" << _channels << " firstChannel=" << _firstChannel << " sampleRate=" << _sampleRate); ATA_INFO("Probe : device=" << _device << " channels=" << _channels << " firstChannel=" << _firstChannel << " sampleRate=" << _sampleRate);
ret = audio::orchestra::api::android::open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options);
#if 0
if (_mode != audio::orchestra::mode_output) { if (_mode != audio::orchestra::mode_output) {
ATA_ERROR("Can not start a device input or duplex for Android ..."); ATA_ERROR("Can not start a device input or duplex for Android ...");
return false; return false;
} }
m_userFormat = _format; m_userFormat = _format;
m_nUserChannels[modeToIdTable(_mode)] = _channels; m_nUserChannels[modeToIdTable(_mode)] = _channels;
ewol::Context& tmpContext = ewol::getContext();
if (_format == SINT8) { m_uid = audio::orchestra::api::android::open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, std11::static_pointer_cast<audio::orchestra::api::Android>(shared_from_this()));
ret = tmpContext.audioOpenDevice(_device, _sampleRate, _channels, 0, androidCallBackEvent, this); if (m_uid < 0) {
ret = false;
} else { } else {
ret = tmpContext.audioOpenDevice(_device, _sampleRate, _channels, 1, androidCallBackEvent, this); ret = true;
} }
m_bufferSize = 256; m_bufferSize = 256;
m_sampleRate = _sampleRate; m_sampleRate = _sampleRate;
m_doByteSwap[modeToIdTable(_mode)] = false; // for endienness ... m_doByteSwap[modeToIdTable(_mode)] = false; // for endienness ...
// TODO : For now, we write it in hard ==> to bu update later ... // TODO : For now, we write it in hard ==> to bu update later ...
m_deviceFormat[modeToIdTable(_mode)] = SINT16; m_deviceFormat[modeToIdTable(_mode)] = audio::format_int16;
m_nDeviceChannels[modeToIdTable(_mode)] = 2; m_nDeviceChannels[modeToIdTable(_mode)] = 2;
m_deviceInterleaved[modeToIdTable(_mode)] = true; m_deviceInterleaved[modeToIdTable(_mode)] = true;
@ -165,8 +143,8 @@ bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
if (m_doConvertBuffer[modeToIdTable(_mode)] == true) { if (m_doConvertBuffer[modeToIdTable(_mode)] == true) {
// Allocate necessary internal buffers. // Allocate necessary internal buffers.
uint64_t bufferBytes = m_nUserChannels[modeToIdTable(_mode)] * m_bufferSize * audio::getFormatBytes(m_userFormat); uint64_t bufferBytes = m_nUserChannels[modeToIdTable(_mode)] * m_bufferSize * audio::getFormatBytes(m_userFormat);
m_userBuffer[modeToIdTable(_mode)] = (char *) calloc(bufferBytes, 1); m_userBuffer[modeToIdTable(_mode)].resize(bufferBytes);
if (m_userBuffer[modeToIdTable(_mode)] == nullptr) { if (m_userBuffer[modeToIdTable(_mode)].size() == 0) {
ATA_ERROR("audio::orchestra::api::Android::probeDeviceOpen: error allocating user buffer memory."); ATA_ERROR("audio::orchestra::api::Android::probeDeviceOpen: error allocating user buffer memory.");
} }
setConvertInfo(_mode, _firstChannel); setConvertInfo(_mode, _firstChannel);
@ -177,7 +155,6 @@ bool audio::orchestra::api::Android::probeDeviceOpen(uint32_t _device,
if (ret == false) { if (ret == false) {
ATA_ERROR("Can not open device."); ATA_ERROR("Can not open device.");
} }
#endif
return ret; return ret;
} }

View File

@ -7,12 +7,14 @@
#if !defined(__AUDIO_ORCHESTRA_API_ANDROID_H__) && defined(ORCHESTRA_BUILD_JAVA) #if !defined(__AUDIO_ORCHESTRA_API_ANDROID_H__) && defined(ORCHESTRA_BUILD_JAVA)
#define __AUDIO_ORCHESTRA_API_ANDROID_H__ #define __AUDIO_ORCHESTRA_API_ANDROID_H__
#include <audio/orchestra/Interface.h>
namespace audio { namespace audio {
namespace orchestra { namespace orchestra {
namespace api { namespace api {
class Android: public audio::orchestra::Api { class Android: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Android(); Android();
virtual ~Android(); virtual ~Android();
@ -30,6 +32,12 @@ namespace audio {
// which is not a member of RtAudio. External use of this function // which is not a member of RtAudio. External use of this function
// will most likely produce highly undesireable results! // will most likely produce highly undesireable results!
void callbackEvent(); void callbackEvent();
private:
int32_t m_uid;
public:
int32_t getUId() {
return m_uid;
}
private: private:
std::vector<audio::orchestra::DeviceInfo> m_devices; std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo(); void saveDeviceInfo();
@ -41,12 +49,8 @@ namespace audio {
audio::format _format, audio::format _format,
uint32_t *_bufferSize, uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options); const audio::orchestra::StreamOptions& _options);
private: public:
void callBackEvent(void* _data, void playback(int16_t* _dst, int32_t _nbChunk);
int32_t _frameRate);
static void androidCallBackEvent(void* _data,
int32_t _frameRate,
void* _userData);
}; };
} }
} }

View File

@ -10,6 +10,7 @@
#include <audio/orchestra/debug.h> #include <audio/orchestra/debug.h>
#include <audio/orchestra/error.h> #include <audio/orchestra/error.h>
#include <audio/orchestra/api/AndroidNativeInterface.h> #include <audio/orchestra/api/AndroidNativeInterface.h>
#include <audio/orchestra/api/Android.h>
/* include auto generated file */ /* include auto generated file */
#include <org_musicdsp_orchestra_Constants.h> #include <org_musicdsp_orchestra_Constants.h>
#include <jvm-basics/jvm-basics.h> #include <jvm-basics/jvm-basics.h>
@ -268,6 +269,7 @@ class AndroidOrchestraContext {
return info; return info;
} }
private: private:
std::vector<std11::weak_ptr<audio::orchestra::api::Android> > m_instanceList; // list of connected handle ...
//AndroidAudioCallback m_audioCallBack; //AndroidAudioCallback m_audioCallBack;
//void* m_audioCallBackUserData; //void* m_audioCallBackUserData;
public: public:
@ -278,7 +280,8 @@ class AndroidOrchestraContext {
uint32_t _sampleRate, uint32_t _sampleRate,
audio::format _format, audio::format _format,
uint32_t *_bufferSize, uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) { const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance) {
ATA_DEBUG("C->java : audio open device"); ATA_DEBUG("C->java : audio open device");
int status; int status;
if(!java_attach_current_thread(&status)) { if(!java_attach_current_thread(&status)) {
@ -290,6 +293,7 @@ class AndroidOrchestraContext {
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer); jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status); java_detach_current_thread(status);
if (bool(ret) == true) { if (bool(ret) == true) {
m_instanceList.push_back(_instance);
return 0; return 0;
} }
return -1; return -1;
@ -348,6 +352,21 @@ class AndroidOrchestraContext {
enum audio::orchestra::error abortStream(int32_t _id) { enum audio::orchestra::error abortStream(int32_t _id) {
return audio::orchestra::error_fail; return audio::orchestra::error_fail;
} }
void playback(int32_t _id, int16_t* _dst, int32_t _nbChunk) {
auto it = m_instanceList.begin();
while (it != m_instanceList.end()) {
auto elem = it->lock();
if (elem == nullptr) {
it = m_instanceList.erase(it);
continue;
}
if (elem->getUId() == _id) {
elem->playback(_dst, _nbChunk);
}
++it;
}
}
}; };
static std::shared_ptr<AndroidOrchestraContext> s_localContext; static std::shared_ptr<AndroidOrchestraContext> s_localContext;
@ -375,11 +394,12 @@ int32_t audio::orchestra::api::android::open(uint32_t _device,
uint32_t _sampleRate, uint32_t _sampleRate,
audio::format _format, audio::format _format,
uint32_t *_bufferSize, uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options) { const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance) {
if (s_localContext == nullptr) { if (s_localContext == nullptr) {
return -1; return -1;
} }
return s_localContext->open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options); return s_localContext->open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, _instance);
} }
enum audio::orchestra::error audio::orchestra::api::android::closeStream(int32_t _id) { enum audio::orchestra::error audio::orchestra::api::android::closeStream(int32_t _id) {
@ -443,5 +463,28 @@ extern "C" {
s_localContext.reset(); s_localContext.reset();
} }
} }
void Java_org_musicdsp_orchestra_Orchestra_NNPlayback(JNIEnv* _env,
void* _reserved,
jint _id,
jshortArray _location,
jint _nbChunk) {
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM());
if (s_localContext == nullptr) {
ATA_ERROR("Call audio with no more Low level interface");
return;
}
// get the short* pointer from the Java array
jboolean isCopy;
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
if (dst != nullptr) {
//ATA_INFO("Need audioData " << int32_t(_nbChunk));
s_localContext->playback(int32_t(_id), static_cast<short*>(dst), int32_t(_nbChunk));
}
// TODO : Understand why it did not work corectly ...
//if (isCopy == JNI_TRUE) {
// release the short* pointer
_env->ReleaseShortArrayElements(_location, dst, 0);
//}
}
} }

View File

@ -12,10 +12,12 @@
#include <audio/orchestra/error.h> #include <audio/orchestra/error.h>
#include <audio/orchestra/StreamOptions.h> #include <audio/orchestra/StreamOptions.h>
#include <audio/format.h> #include <audio/format.h>
#include <etk/memory.h>
namespace audio { namespace audio {
namespace orchestra { namespace orchestra {
namespace api { namespace api {
class Android;
namespace android { namespace android {
uint32_t getDeviceCount(); uint32_t getDeviceCount();
audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device);
@ -26,7 +28,8 @@ namespace audio {
uint32_t _sampleRate, uint32_t _sampleRate,
audio::format _format, audio::format _format,
uint32_t *_bufferSize, uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options); const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance);
enum audio::orchestra::error closeStream(int32_t _id); enum audio::orchestra::error closeStream(int32_t _id);
enum audio::orchestra::error startStream(int32_t _id); enum audio::orchestra::error startStream(int32_t _id);
enum audio::orchestra::error stopStream(int32_t _id); enum audio::orchestra::error stopStream(int32_t _id);

View File

@ -11,8 +11,8 @@
#include <audio/orchestra/Interface.h> #include <audio/orchestra/Interface.h>
#include <audio/orchestra/debug.h> #include <audio/orchestra/debug.h>
audio::orchestra::Api* audio::orchestra::api::Asio::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Asio::create() {
return new audio::orchestra::api::Asio(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Asio());
} }

View File

@ -14,7 +14,7 @@ namespace audio {
class AsioPrivate: class AsioPrivate:
class Asio: public audio::orchestra::Api { class Asio: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Asio(); Asio();
virtual ~Asio(); virtual ~Asio();

View File

@ -19,8 +19,8 @@
#include <etk/thread.h> #include <etk/thread.h>
#include <etk/thread/tools.h> #include <etk/thread/tools.h>
audio::orchestra::Api* audio::orchestra::api::Core::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Core::create() {
return new audio::orchestra::api::Core(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Core());
} }
#undef __class__ #undef __class__

View File

@ -17,7 +17,7 @@ namespace audio {
class CorePrivate; class CorePrivate;
class Core: public audio::orchestra::Api { class Core: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Core(); Core();
virtual ~Core(); virtual ~Core();

View File

@ -15,7 +15,7 @@ namespace audio {
class CoreIosPrivate; class CoreIosPrivate;
class CoreIos: public audio::orchestra::Api { class CoreIos: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
CoreIos(); CoreIos();
virtual ~CoreIos(); virtual ~CoreIos();

View File

@ -18,9 +18,9 @@
#undef __class__ #undef __class__
#define __class__ "api::CoreIos" #define __class__ "api::CoreIos"
audio::orchestra::Api* audio::orchestra::api::CoreIos::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::CoreIos::create() {
ATA_INFO("Create CoreIos device ... "); ATA_INFO("Create CoreIos device ... ");
return new audio::orchestra::api::CoreIos(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::CoreIos());
} }
#define kOutputBus 0 #define kOutputBus 0

View File

@ -14,8 +14,8 @@
#undef __class__ #undef __class__
#define __class__ "api::Ds" #define __class__ "api::Ds"
audio::orchestra::Api* audio::orchestra::api::Ds::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Ds::create() {
return new audio::orchestra::api::Ds(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Ds());
} }

View File

@ -15,7 +15,7 @@ namespace audio {
class DsPrivate; class DsPrivate;
class Ds: public audio::orchestra::Api { class Ds: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Ds(); Ds();
virtual ~Ds(); virtual ~Ds();

View File

@ -12,8 +12,8 @@
#undef __class__ #undef __class__
#define __class__ "api::Dummy" #define __class__ "api::Dummy"
audio::orchestra::Api* audio::orchestra::api::Dummy::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Dummy::create() {
return new audio::orchestra::api::Dummy(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Dummy());
} }

View File

@ -16,7 +16,7 @@ namespace audio {
namespace api { namespace api {
class Dummy: public audio::orchestra::Api { class Dummy: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Dummy(); Dummy();
const std::string& getCurrentApi() { const std::string& getCurrentApi() {

View File

@ -18,8 +18,8 @@
#undef __class__ #undef __class__
#define __class__ "api::Jack" #define __class__ "api::Jack"
audio::orchestra::Api* audio::orchestra::api::Jack::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Jack::create() {
return new audio::orchestra::api::Jack(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Jack());
} }

View File

@ -16,7 +16,7 @@ namespace audio {
class JackPrivate; class JackPrivate;
class Jack: public audio::orchestra::Api { class Jack: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Jack(); Jack();
virtual ~Jack(); virtual ~Jack();

View File

@ -21,8 +21,8 @@
#undef __class__ #undef __class__
#define __class__ "api::Oss" #define __class__ "api::Oss"
audio::orchestra::Api* audio::orchestra::api::Oss::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Oss::create() {
return new audio::orchestra::api::Oss(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Oss());
} }
static void *ossCallbackHandler(void* _userData); static void *ossCallbackHandler(void* _userData);

View File

@ -15,7 +15,7 @@ namespace audio {
class OssPrivate; class OssPrivate;
class Oss: public audio::orchestra::Api { class Oss: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Oss(); Oss();
virtual ~Oss(); virtual ~Oss();

View File

@ -21,8 +21,8 @@
#undef __class__ #undef __class__
#define __class__ "api::Pulse" #define __class__ "api::Pulse"
audio::orchestra::Api* audio::orchestra::api::Pulse::create() { std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Pulse::create() {
return new audio::orchestra::api::Pulse(); return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Pulse());
} }

View File

@ -15,7 +15,7 @@ namespace audio {
class PulsePrivate; class PulsePrivate;
class Pulse: public audio::orchestra::Api { class Pulse: public audio::orchestra::Api {
public: public:
static audio::orchestra::Api* create(); static std::shared_ptr<audio::orchestra::Api> create();
public: public:
Pulse(); Pulse();
virtual ~Pulse(); virtual ~Pulse();