Commit 012bff54 authored by Simon Morlat's avatar Simon Morlat

make native sound api detection to be only one by keeping the AudioRecordImpl...

make native sound api detection to be only one by keeping the AudioRecordImpl and AudioTrackImpl singletons.
parent 673dc10a
......@@ -142,46 +142,49 @@ void *AudioRecord::getRealThis()const{
bool AudioRecordImpl::init(Library *lib){
bool fail=false;
AudioRecordImpl *impl=new AudioRecordImpl(lib);
if (!impl->mCtorBeforeAPI17.isFound() && !impl->mCtor.isFound()) {
fail=true;
ms_error("AudioRecord::AudioRecord(...) not found.");
}
if (!impl->mDtor.isFound()) {
fail=true;
ms_error("AudioRecord::~AudioRecord() dtor not found.");
}
if (!impl->mInitCheck.isFound()) {
ms_warning("AudioRecord::initCheck() not found (normal on Android 4.4)");
}
if (!impl->mStop.isFound()) {
fail=true;
ms_error("AudioRecord::stop() not found.");
}
if (!impl->mStart.isFound()) {
fail=true;
ms_error("AudioRecord::start() not found.");
}
if (impl->mApiVersion>=19 && !impl->mDefaultCtor.isFound()){
fail=true;
ms_error("AudioRecord::AudioRecord() not found.");
}
if (fail){
delete impl;
return false;
}
sImpl=impl;
if (impl->mApiVersion>=19){
AudioRecord *test=new AudioRecord();
//dumpMemory(test->getRealThis(),AudioRecordImpl::sObjSize);
if (findRefbaseOffset(test->getRealThis(),AudioRecordImpl::sObjSize)>(ptrdiff_t)sizeof(void*)){
ms_message("AudioRecord does not need refcounting despite it is 4.4");
impl->mUseRefcount=false;
}else{
ms_message("AudioRecord needs refcounting.");
impl->mUseRefcount=true;
if (!sImpl){
AudioRecordImpl *impl=new AudioRecordImpl(lib);
if (!impl->mCtorBeforeAPI17.isFound() && !impl->mCtor.isFound()) {
fail=true;
ms_error("AudioRecord::AudioRecord(...) not found.");
}
if (!impl->mDtor.isFound()) {
fail=true;
ms_error("AudioRecord::~AudioRecord() dtor not found.");
}
if (!impl->mInitCheck.isFound()) {
ms_warning("AudioRecord::initCheck() not found (normal on Android 4.4)");
}
if (!impl->mStop.isFound()) {
fail=true;
ms_error("AudioRecord::stop() not found.");
}
if (!impl->mStart.isFound()) {
fail=true;
ms_error("AudioRecord::start() not found.");
}
if (impl->mApiVersion>=19 && !impl->mDefaultCtor.isFound()){
fail=true;
ms_error("AudioRecord::AudioRecord() not found.");
}
if (fail){
delete impl;
return false;
}
if (impl->mApiVersion>=19){
AudioRecord *test=new AudioRecord();
//dumpMemory(test->getRealThis(),AudioRecordImpl::sObjSize);
if (findRefbaseOffset(test->getRealThis(),AudioRecordImpl::sObjSize)>(ptrdiff_t)sizeof(void*)){
ms_message("AudioRecord does not need refcounting despite it is 4.4");
impl->mUseRefcount=false;
}else{
ms_message("AudioRecord needs refcounting.");
impl->mUseRefcount=true;
}
sp<AudioRecord> st(test);
}
sp<AudioRecord> st(test);
sImpl=impl;
}
return true;
}
......
......@@ -210,64 +210,68 @@ namespace fake_android{
bool AudioTrackImpl::init(Library *lib){
bool fail=false;
AudioTrackImpl *impl=new AudioTrackImpl(lib);
if (!impl->mCtor.isFound()) {
ms_error("AudioTrack::AudioTrack(...) not found");
fail=true;
}
if (!impl->mDtor.isFound()) {
ms_error("AudioTrack::~AudioTrack() not found");
fail=true;
}
if (!impl->mStart.isFound()) {
ms_error("AudioTrack::start() not found");
fail=true;
}
if (!impl->mStop.isFound()) {
ms_error("AudioTrack::stop() not found");
fail=true;
}
if (!impl->mInitCheck.isFound()) {
ms_warning("AudioTrack::initCheck() not found (normal in android 4.3)");
}
if (!impl->mFlush.isFound()) {
ms_error("AudioTrack::flush() not found");
fail=true;
}
if (!impl->mLatency.isFound()) {
ms_warning("AudioTrack::latency() not found (normal in android 4.3)");
}
if (!impl->mGetPosition.isFound()) {
ms_error("AudioTrack::getPosition() not found");
fail=true;
}
if (impl->mSdkVersion>=19 && !impl->mDefaultCtor.isFound()) {
ms_error("AudioTrack::AudioTrack() not found");
fail=true;
}
if (!fail){
sImpl=impl;
if (impl->mSdkVersion>=19){
impl->mUseRefCount=true;
AudioTrack *test=new AudioTrack();
//dumpMemory(test->getRealThis(),AudioTrackImpl::sObjSize);
ptrdiff_t offset=findRefbaseOffset(test->getRealThis(),AudioTrackImpl::sObjSize);
if (offset>(ptrdiff_t)sizeof(void*)){
ms_message("AudioTrack uses virtual RefBase despite it is 4.4");
impl->mRefBaseOffset=offset;
}else{
ms_message("AudioTrack needs refcounting.");
if (sImpl==NULL){
AudioTrackImpl *impl=new AudioTrackImpl(lib);
if (!impl->mCtor.isFound()) {
ms_error("AudioTrack::AudioTrack(...) not found");
fail=true;
}
if (!impl->mDtor.isFound()) {
ms_error("AudioTrack::~AudioTrack() not found");
fail=true;
}
if (!impl->mStart.isFound()) {
ms_error("AudioTrack::start() not found");
fail=true;
}
if (!impl->mStop.isFound()) {
ms_error("AudioTrack::stop() not found");
fail=true;
}
if (!impl->mInitCheck.isFound()) {
ms_warning("AudioTrack::initCheck() not found (normal in android 4.3)");
}
if (!impl->mFlush.isFound()) {
ms_error("AudioTrack::flush() not found");
fail=true;
}
if (!impl->mLatency.isFound()) {
ms_warning("AudioTrack::latency() not found (normal in android 4.3)");
}
if (!impl->mGetPosition.isFound()) {
ms_error("AudioTrack::getPosition() not found");
fail=true;
}
if (impl->mSdkVersion>=19 && !impl->mDefaultCtor.isFound()) {
ms_error("AudioTrack::AudioTrack() not found");
fail=true;
}
if (!fail){
if (impl->mSdkVersion>=19){
impl->mUseRefCount=true;
AudioTrack *test=new AudioTrack();
//dumpMemory(test->getRealThis(),AudioTrackImpl::sObjSize);
ptrdiff_t offset=findRefbaseOffset(test->getRealThis(),AudioTrackImpl::sObjSize);
if (offset>(ptrdiff_t)sizeof(void*)){
ms_message("AudioTrack uses virtual RefBase despite it is 4.4");
impl->mRefBaseOffset=offset;
}else{
ms_message("AudioTrack needs refcounting.");
}
sp<AudioTrack> st(test);
}
sp<AudioTrack> st(test);
sImpl=impl;
return true;
}else{
delete impl;
return false;
}
return true;
}else{
delete impl;
return false;
}
return true;
}
AudioTrackImpl * AudioTrackImpl::sImpl=NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment