Skip to content

Commit

Permalink
added some tests -> crash in Oboe: google/oboe#778
Browse files Browse the repository at this point in the history
  • Loading branch information
corrados committed Sep 13, 2020
1 parent dc6a1de commit 7955be2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ win32 {

LIBS += -lOpenSLES
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
ANDROID_ABIS = armeabi-v7a
OTHER_FILES += android/AndroidManifest.xml

# if compiling for android you need to use Oboe library which is included as a git submodule
Expand Down Expand Up @@ -1012,3 +1011,5 @@ contains(CONFIG, "opus_shared_lib") {
SOURCES += $$SOURCES_OPUS
DISTFILES += $$DISTFILES_OPUS
}

ANDROID_ABIS = armeabi-v7a
31 changes: 22 additions & 9 deletions android/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ void CSound::openStreams()
mCallback = this;

// Setup output stream
oboe::AudioStreamBuilder inBuilder, outBuilder;

outBuilder.setDirection ( oboe::Direction::Output );
setupCommonStreamParams ( &outBuilder );

// TEST
outBuilder.setFramesPerCallback ( 192 );

oboe::Result result = outBuilder.openManagedStream ( mPlayStream );

if ( result != oboe::Result::OK )
Expand All @@ -81,6 +82,9 @@ void CSound::openStreams()
inBuilder.setDirection ( oboe::Direction::Input );
setupCommonStreamParams ( &inBuilder );

// TEST
inBuilder.setFramesPerCallback ( 192 );

result = inBuilder.openManagedStream ( mRecordingStream );

if ( result != oboe::Result::OK )
Expand Down Expand Up @@ -164,22 +168,24 @@ void CSound::Stop()
int CSound::Init ( const int /* iNewPrefMonoBufferSize */ )
{
// get the preferred device frames per burst for input and output
// const int iInFramesPerBurst = mRecordingStream->getFramesPerBurst();
// const int iOutFramesPerBurst = mPlayStream->getFramesPerBurst();
const int iInFramesPerBurst = mRecordingStream->getFramesPerBurst();
const int iOutFramesPerBurst = mPlayStream->getFramesPerBurst();

// TEST
const int iInFramesPerBurst = mRecordingStream->getBufferSizeInFrames();
const int iOutFramesPerBurst = mPlayStream->getBufferSizeInFrames();
//// TEST
//const int iInFramesPerBurst = mRecordingStream->getBufferSizeInFrames();
//const int iOutFramesPerBurst = mPlayStream->getBufferSizeInFrames();


// now take the larger value of both for our buffer size
iOpenSLBufferSizeMono = std::max ( iInFramesPerBurst, iOutFramesPerBurst );

// apply the new frame size to the streams
mRecordingStream->setBufferSizeInFrames ( iOpenSLBufferSizeMono );

mPlayStream->setBufferSizeInFrames ( iOpenSLBufferSizeMono );

// TEST
inBuilder.setFramesPerCallback ( iOpenSLBufferSizeMono );
outBuilder.setFramesPerCallback ( iOpenSLBufferSizeMono );

// TEST for debugging
qInfo() << "iOpenSLBufferSizeMono: " << iOpenSLBufferSizeMono;
Expand Down Expand Up @@ -216,7 +222,14 @@ oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream,
// Buffer size can change regularly by android devices
int& iBufferSizeMono = pSound->iOpenSLBufferSizeMono;

qInfo() << oboeStream;
if ( oboeStream == pSound->mRecordingStream.get() )
{
qInfo() << "INPUT -------------";
}
else
{
qInfo() << "OUTPUT ************";
}
qInfo() << "iBufferSizeMono: " << iBufferSizeMono << ", numFrames: " << numFrames;

// perform the processing for input
Expand Down
8 changes: 5 additions & 3 deletions android/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback//, public IRe
void closeStreams();
void closeStream ( oboe::ManagedStream& stream );

oboe::ManagedStream mRecordingStream;
oboe::ManagedStream mPlayStream;
AudioStreamCallback* mCallback;
oboe::AudioStreamBuilder inBuilder;
oboe::AudioStreamBuilder outBuilder;
oboe::ManagedStream mRecordingStream;
oboe::ManagedStream mPlayStream;
AudioStreamCallback* mCallback;

// used to reach a state where the input buffer is
// empty and the garbage in the first 500ms or so is discarded
Expand Down

0 comments on commit 7955be2

Please sign in to comment.