Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Full Duplex Stream to Oboe library #1920

Merged
merged 11 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/OboeTester/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")

link_directories(${CMAKE_CURRENT_LIST_DIR}/..)

# Increment this number when adding files to OboeTester => 103
# Increment this number when adding files to OboeTester => 104
# The change in this file will help Android Studio resync
# and generate new build files that reference the new code.
file(GLOB_RECURSE app_native_sources src/main/cpp/*)
Expand Down
6 changes: 3 additions & 3 deletions apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ oboe::Result FullDuplexAnalyzer::start() {
getLoopbackProcessor()->setSampleRate(getOutputStream()->getSampleRate());
getLoopbackProcessor()->prepareToTest();
mWriteReadDeltaValid = false;
return FullDuplexStream::start();
return FullDuplexStreamWithConversion::start();
}

oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReady(
oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReadyFloat(
const float *inputData,
int numInputFrames,
float *outputData,
int numOutputFrames) {

int32_t inputStride = getInputStream()->getChannelCount();
int32_t outputStride = getOutputStream()->getChannelCount();
const float *inputFloat = inputData;
auto *inputFloat = static_cast<const float *>(inputData);
float *outputFloat = outputData;

// Get atomic snapshot of the relative frame positions so they
Expand Down
8 changes: 4 additions & 4 deletions apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
#include <sys/types.h>

#include "oboe/Oboe.h"
#include "FullDuplexStream.h"
#include "analyzer/LatencyAnalyzer.h"
#include "FullDuplexStreamWithConversion.h"
#include "MultiChannelRecording.h"

class FullDuplexAnalyzer : public FullDuplexStream {
class FullDuplexAnalyzer : public FullDuplexStreamWithConversion {
public:
FullDuplexAnalyzer(LoopbackProcessor *processor)
: mLoopbackProcessor(processor) {
setMNumInputBurstsCushion(1);
setNumInputBurstsCushion(1);
}

/**
* Called when data is available on both streams.
* Caller should override this method.
*/
oboe::DataCallbackResult onBothStreamsReady(
oboe::DataCallbackResult onBothStreamsReadyFloat(
const float *inputData,
int numInputFrames,
float *outputData,
Expand Down
8 changes: 4 additions & 4 deletions apps/OboeTester/app/src/main/cpp/FullDuplexEcho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ oboe::Result FullDuplexEcho::start() {
// Use peak detector for input streams
mNumChannels = getInputStream()->getChannelCount();
mPeakDetectors = std::make_unique<PeakDetector[]>(mNumChannels);
return FullDuplexStream::start();
return FullDuplexStreamWithConversion::start();
}

double FullDuplexEcho::getPeakLevel(int index) {
Expand All @@ -37,14 +37,14 @@ double FullDuplexEcho::getPeakLevel(int index) {
return mPeakDetectors[index].getLevel();
}

oboe::DataCallbackResult FullDuplexEcho::onBothStreamsReady(
oboe::DataCallbackResult FullDuplexEcho::onBothStreamsReadyFloat(
const float *inputData,
int numInputFrames,
float *outputData,
int numOutputFrames) {
int32_t framesToEcho = std::min(numInputFrames, numOutputFrames);
float *inputFloat = (float *)inputData;
float *outputFloat = (float *)outputData;
auto *inputFloat = const_cast<float *>(inputData);
float *outputFloat = outputData;
// zero out entire output array
memset(outputFloat, 0, static_cast<size_t>(numOutputFrames)
* static_cast<size_t>(getOutputStream()->getBytesPerFrame()));
Expand Down
8 changes: 4 additions & 4 deletions apps/OboeTester/app/src/main/cpp/FullDuplexEcho.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
#include <sys/types.h>

#include "oboe/Oboe.h"
#include "FullDuplexStream.h"
#include "analyzer/LatencyAnalyzer.h"
#include "FullDuplexStreamWithConversion.h"
#include "InterpolatingDelayLine.h"

class FullDuplexEcho : public FullDuplexStream {
class FullDuplexEcho : public FullDuplexStreamWithConversion {
public:
FullDuplexEcho() {
setMNumInputBurstsCushion(0);
setNumInputBurstsCushion(0);
}

/**
* Called when data is available on both streams.
* Caller should override this method.
*/
oboe::DataCallbackResult onBothStreamsReady(
oboe::DataCallbackResult onBothStreamsReadyFloat(
const float *inputData,
int numInputFrames,
float *outputData,
Expand Down
152 changes: 0 additions & 152 deletions apps/OboeTester/app/src/main/cpp/FullDuplexStream.cpp

This file was deleted.

119 changes: 0 additions & 119 deletions apps/OboeTester/app/src/main/cpp/FullDuplexStream.h

This file was deleted.

Loading