[DEV] continue integration of audio interface
This commit is contained in:
parent
7d0a38e087
commit
fbd6eceee6
@ -52,6 +52,7 @@ public class InterfaceOutput extends Thread implements Constants {
|
||||
while (!m_stopAudioThreads) {
|
||||
// Fill buffer with PCM data from C++
|
||||
// TODO : Set if back ... ORCHESTRA.audioPlayback(streamBuffer, BUFFER_SIZE, nbChannels);
|
||||
Log.i("audioEWOL", "new data ... ");
|
||||
int xxx = BUFFER_SIZE;
|
||||
/*
|
||||
while (xxx>0) {
|
||||
|
@ -24,6 +24,7 @@ import org.musicdsp.orchestra.InterfaceInput;
|
||||
public class Manager implements ManagerCallback, Constants {
|
||||
private Orchestra orchestraHandle;
|
||||
private int uid = 0;
|
||||
private InterfaceOutput test;
|
||||
private Vector<InterfaceOutput> outputList;
|
||||
private Vector<InterfaceInput> inputList;
|
||||
|
||||
@ -57,7 +58,9 @@ public class Manager implements ManagerCallback, Constants {
|
||||
InterfaceOutput iface = new InterfaceOutput(uid, orchestraHandle, idDevice, freq, nbChannel, format);
|
||||
uid++;
|
||||
if (iface != null) {
|
||||
outputList.add(iface);
|
||||
//outputList.add(iface);
|
||||
test = iface;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
/*
|
||||
@ -97,5 +100,31 @@ public class Manager implements ManagerCallback, Constants {
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean start(int idDevice) {
|
||||
if (idDevice == 0) {
|
||||
if (test != null) {
|
||||
test.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean stop(int idDevice) {
|
||||
if (idDevice == 0) {
|
||||
if (test != null) {
|
||||
// request audio stop
|
||||
test.AutoStop();
|
||||
try {
|
||||
test.join();
|
||||
} catch(InterruptedException e) { }
|
||||
test = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -13,4 +13,6 @@ public interface ManagerCallback {
|
||||
public String getDeviceProperty(int idDevice);
|
||||
public boolean openDevice(int idDevice, int sampleRate, int nbChannel, int format);
|
||||
public boolean closeDevice(int idDevice);
|
||||
public boolean start(int idDevice);
|
||||
public boolean stop(int idDevice);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ enum audio::orchestra::error audio::orchestra::api::Android::startStream() {
|
||||
// TODO : Check return ...
|
||||
audio::orchestra::Api::startStream();
|
||||
// Can not close the stream now...
|
||||
return audio::orchestra::error_none;
|
||||
return audio::orchestra::api::android::startStream(0);
|
||||
}
|
||||
|
||||
enum audio::orchestra::error audio::orchestra::api::Android::stopStream() {
|
||||
@ -62,7 +62,7 @@ enum audio::orchestra::error audio::orchestra::api::Android::stopStream() {
|
||||
tmpContext.audioCloseDevice(0);
|
||||
#endif
|
||||
// Can not close the stream now...
|
||||
return audio::orchestra::error_none;
|
||||
return audio::orchestra::api::android::stopStream(0);
|
||||
}
|
||||
|
||||
enum audio::orchestra::error audio::orchestra::api::Android::abortStream() {
|
||||
|
@ -27,6 +27,8 @@ class AndroidOrchestraContext {
|
||||
jmethodID m_javaMethodOrchestraActivityAudioGetDeviceProperty;
|
||||
jmethodID m_javaMethodOrchestraActivityAudioOpenDevice;
|
||||
jmethodID m_javaMethodOrchestraActivityAudioCloseDevice;
|
||||
jmethodID m_javaMethodOrchestraActivityAudioStart;
|
||||
jmethodID m_javaMethodOrchestraActivityAudioStop;
|
||||
jclass m_javaDefaultClassString; //!< default string class
|
||||
private:
|
||||
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
|
||||
@ -80,6 +82,8 @@ class AndroidOrchestraContext {
|
||||
m_javaMethodOrchestraActivityAudioGetDeviceProperty(0),
|
||||
m_javaMethodOrchestraActivityAudioOpenDevice(0),
|
||||
m_javaMethodOrchestraActivityAudioCloseDevice(0),
|
||||
m_javaMethodOrchestraActivityAudioStart(0),
|
||||
m_javaMethodOrchestraActivityAudioStop(0),
|
||||
m_javaDefaultClassString(0) {
|
||||
ATA_DEBUG("*******************************************");
|
||||
ATA_DEBUG("** set JVM Pointer (orchestra) **");
|
||||
@ -146,6 +150,24 @@ class AndroidOrchestraContext {
|
||||
ATA_ERROR("system can not start without function : closeDevice");
|
||||
functionCallbackIsMissing = true;
|
||||
}
|
||||
ret = safeInitMethodID(m_javaMethodOrchestraActivityAudioStart,
|
||||
m_javaClassOrchestraCallback,
|
||||
"start",
|
||||
"(I)Z");
|
||||
if (ret == false) {
|
||||
jvm_basics::checkExceptionJavaVM(_env);
|
||||
ATA_ERROR("system can not start without function : start");
|
||||
functionCallbackIsMissing = true;
|
||||
}
|
||||
ret = safeInitMethodID(m_javaMethodOrchestraActivityAudioStop,
|
||||
m_javaClassOrchestraCallback,
|
||||
"stop",
|
||||
"(I)Z");
|
||||
if (ret == false) {
|
||||
jvm_basics::checkExceptionJavaVM(_env);
|
||||
ATA_ERROR("system can not start without function : stop");
|
||||
functionCallbackIsMissing = true;
|
||||
}
|
||||
|
||||
|
||||
m_javaObjectOrchestraCallback = _env->NewGlobalRef(_objCallback);
|
||||
@ -275,15 +297,15 @@ class AndroidOrchestraContext {
|
||||
public:
|
||||
enum audio::orchestra::error closeStream(int32_t _id) {
|
||||
ATA_DEBUG("C->java : audio close device");
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
//Call java ...
|
||||
jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioCloseDevice, _id);
|
||||
// manage execption :
|
||||
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
//Call java ...
|
||||
jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioCloseDevice, _id);
|
||||
// manage execption :
|
||||
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
if (bool(ret) == false) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
@ -291,10 +313,37 @@ class AndroidOrchestraContext {
|
||||
}
|
||||
|
||||
enum audio::orchestra::error startStream(int32_t _id) {
|
||||
return audio::orchestra::error_fail;
|
||||
ATA_DEBUG("C->java : audio start device");
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
//Call java ...
|
||||
jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioStart, _id);
|
||||
// manage execption :
|
||||
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
if (bool(ret) == false) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
return audio::orchestra::error_none;
|
||||
}
|
||||
enum audio::orchestra::error stopStream(int32_t _id) {
|
||||
return audio::orchestra::error_fail;
|
||||
|
||||
ATA_DEBUG("C->java : audio close device");
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
//Call java ...
|
||||
jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioStop, _id);
|
||||
// manage execption :
|
||||
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
if (bool(ret) == false) {
|
||||
return audio::orchestra::error_fail;
|
||||
}
|
||||
return audio::orchestra::error_none;
|
||||
}
|
||||
enum audio::orchestra::error abortStream(int32_t _id) {
|
||||
return audio::orchestra::error_fail;
|
||||
|
Loading…
x
Reference in New Issue
Block a user