Skip to content

Commit 66111e0

Browse files
authored
Add Full Duplex Stream to Oboe library (#1920)
1 parent 0f0d8b1 commit 66111e0

23 files changed

+702
-537
lines changed

apps/OboeTester/app/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
66

77
link_directories(${CMAKE_CURRENT_LIST_DIR}/..)
88

9-
# Increment this number when adding files to OboeTester => 103
9+
# Increment this number when adding files to OboeTester => 104
1010
# The change in this file will help Android Studio resync
1111
# and generate new build files that reference the new code.
1212
file(GLOB_RECURSE app_native_sources src/main/cpp/*)

apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ oboe::Result FullDuplexAnalyzer::start() {
2121
getLoopbackProcessor()->setSampleRate(getOutputStream()->getSampleRate());
2222
getLoopbackProcessor()->prepareToTest();
2323
mWriteReadDeltaValid = false;
24-
return FullDuplexStream::start();
24+
return FullDuplexStreamWithConversion::start();
2525
}
2626

27-
oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReady(
27+
oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReadyFloat(
2828
const float *inputData,
2929
int numInputFrames,
3030
float *outputData,
3131
int numOutputFrames) {
3232

3333
int32_t inputStride = getInputStream()->getChannelCount();
3434
int32_t outputStride = getOutputStream()->getChannelCount();
35-
const float *inputFloat = inputData;
35+
auto *inputFloat = static_cast<const float *>(inputData);
3636
float *outputFloat = outputData;
3737

3838
// Get atomic snapshot of the relative frame positions so they

apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
#include <sys/types.h>
2222

2323
#include "oboe/Oboe.h"
24-
#include "FullDuplexStream.h"
2524
#include "analyzer/LatencyAnalyzer.h"
25+
#include "FullDuplexStreamWithConversion.h"
2626
#include "MultiChannelRecording.h"
2727

28-
class FullDuplexAnalyzer : public FullDuplexStream {
28+
class FullDuplexAnalyzer : public FullDuplexStreamWithConversion {
2929
public:
3030
FullDuplexAnalyzer(LoopbackProcessor *processor)
3131
: mLoopbackProcessor(processor) {
32-
setMNumInputBurstsCushion(1);
32+
setNumInputBurstsCushion(1);
3333
}
3434

3535
/**
3636
* Called when data is available on both streams.
3737
* Caller should override this method.
3838
*/
39-
oboe::DataCallbackResult onBothStreamsReady(
39+
oboe::DataCallbackResult onBothStreamsReadyFloat(
4040
const float *inputData,
4141
int numInputFrames,
4242
float *outputData,

apps/OboeTester/app/src/main/cpp/FullDuplexEcho.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ oboe::Result FullDuplexEcho::start() {
2323
// Use peak detector for input streams
2424
mNumChannels = getInputStream()->getChannelCount();
2525
mPeakDetectors = std::make_unique<PeakDetector[]>(mNumChannels);
26-
return FullDuplexStream::start();
26+
return FullDuplexStreamWithConversion::start();
2727
}
2828

2929
double FullDuplexEcho::getPeakLevel(int index) {
@@ -37,14 +37,14 @@ double FullDuplexEcho::getPeakLevel(int index) {
3737
return mPeakDetectors[index].getLevel();
3838
}
3939

40-
oboe::DataCallbackResult FullDuplexEcho::onBothStreamsReady(
40+
oboe::DataCallbackResult FullDuplexEcho::onBothStreamsReadyFloat(
4141
const float *inputData,
4242
int numInputFrames,
4343
float *outputData,
4444
int numOutputFrames) {
4545
int32_t framesToEcho = std::min(numInputFrames, numOutputFrames);
46-
float *inputFloat = (float *)inputData;
47-
float *outputFloat = (float *)outputData;
46+
auto *inputFloat = const_cast<float *>(inputData);
47+
float *outputFloat = outputData;
4848
// zero out entire output array
4949
memset(outputFloat, 0, static_cast<size_t>(numOutputFrames)
5050
* static_cast<size_t>(getOutputStream()->getBytesPerFrame()));

apps/OboeTester/app/src/main/cpp/FullDuplexEcho.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
#include <sys/types.h>
2222

2323
#include "oboe/Oboe.h"
24-
#include "FullDuplexStream.h"
2524
#include "analyzer/LatencyAnalyzer.h"
25+
#include "FullDuplexStreamWithConversion.h"
2626
#include "InterpolatingDelayLine.h"
2727

28-
class FullDuplexEcho : public FullDuplexStream {
28+
class FullDuplexEcho : public FullDuplexStreamWithConversion {
2929
public:
3030
FullDuplexEcho() {
31-
setMNumInputBurstsCushion(0);
31+
setNumInputBurstsCushion(0);
3232
}
3333

3434
/**
3535
* Called when data is available on both streams.
3636
* Caller should override this method.
3737
*/
38-
oboe::DataCallbackResult onBothStreamsReady(
38+
oboe::DataCallbackResult onBothStreamsReadyFloat(
3939
const float *inputData,
4040
int numInputFrames,
4141
float *outputData,

apps/OboeTester/app/src/main/cpp/FullDuplexStream.cpp

Lines changed: 0 additions & 152 deletions
This file was deleted.

apps/OboeTester/app/src/main/cpp/FullDuplexStream.h

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)