oboe: fix sample rate converter
Change pullData indexing.
Add pullReset() to reset framePositions.
Add simple test.
diff --git a/src/flowgraph/AudioProcessorBase.h b/src/flowgraph/AudioProcessorBase.h
index d5875f4..b4097e5 100644
--- a/src/flowgraph/AudioProcessorBase.h
+++ b/src/flowgraph/AudioProcessorBase.h
@@ -79,6 +79,16 @@
*/
int32_t pullData(int64_t framePosition, int32_t numFrames);
+ /**
+ * Recursively reset all the nodes in the graph, starting from a Sink.
+ */
+ void pullReset();
+
+ /**
+ * Reset framePosition counters.
+ */
+ virtual void reset();
+
void addInputPort(AudioPort &port) {
mInputPorts.push_back(port);
}
@@ -100,14 +110,23 @@
mDataPulledAutomatically = automatic;
}
+ virtual const char *getName() {
+ return "AudioProcessorBase";
+ }
+
+ int64_t getLastFramePosition() {
+ return mLastFramePosition;
+ }
+
protected:
- int64_t mLastFramePosition = -1; // Start at -1 so that the first pull works.
+ int64_t mLastFramePosition = 0;
std::vector<std::reference_wrapper<AudioPort>> mInputPorts;
private:
- // FIXME int32_t mFramesValid = 0; // num valid frames in the block
bool mDataPulledAutomatically = true;
+ bool mBlockRecursion = false;
+ int32_t mLastFrameCount = 0;
};
@@ -136,6 +155,8 @@
virtual int32_t pullData(int64_t framePosition, int32_t numFrames) = 0;
+ virtual void pullReset() {}
+
protected:
AudioProcessorBase &mParent;
@@ -217,6 +238,9 @@
*/
int32_t pullData(int64_t framePosition, int32_t numFrames) override;
+
+ void pullReset() override;
+
};
/***************************************************************************/
@@ -283,6 +307,8 @@
*/
int32_t pullData(int64_t framePosition, int32_t numFrames) override;
+ void pullReset() override;
+
private:
AudioFloatOutputPort *mConnected = nullptr;
};