Skip to content

Commit

Permalink
oboe: use oboe::flowgraph namespace
Browse files Browse the repository at this point in the history
to prevent AAudio from calling into the Oboe library
and causing memory corruption.

Pass in external namespace.

Fixes #930
  • Loading branch information
philburk committed Jul 15, 2020
1 parent 1ca05ea commit 9425ffd
Show file tree
Hide file tree
Showing 28 changed files with 55 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/flowgraph/ChannelCountConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "FlowGraphNode.h"
#include "ChannelCountConverter.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

ChannelCountConverter::ChannelCountConverter(
int32_t inputChannelCount,
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/ChannelCountConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -48,5 +49,6 @@ namespace flowgraph {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H
2 changes: 1 addition & 1 deletion src/flowgraph/ClipToRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "FlowGraphNode.h"
#include "ClipToRange.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

ClipToRange::ClipToRange(int32_t channelCount)
: FlowGraphFilter(channelCount) {
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/ClipToRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

// This is 3 dB, (10^(3/20)), to match the maximum headroom in AudioTrack for float data.
Expand Down Expand Up @@ -64,5 +65,6 @@ class ClipToRange : public FlowGraphFilter {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_CLIP_TO_RANGE_H
2 changes: 1 addition & 1 deletion src/flowgraph/FlowGraphNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <sys/types.h>
#include "FlowGraphNode.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

/***************************************************************************/
int32_t FlowGraphNode::pullData(int32_t numFrames, int64_t callCount) {
Expand Down
9 changes: 9 additions & 0 deletions src/flowgraph/FlowGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@

// Set this to 1 if using it inside the Android framework.
// This code is kept here so that it can be moved easily between Oboe and AAudio.
#ifndef FLOWGRAPH_ANDROID_INTERNAL
#define FLOWGRAPH_ANDROID_INTERNAL 0
#endif

// Set this to a name that will prevent AAudio from calling into Oboe.
#ifndef FLOWGRAPH_OUTER_NAMESPACE
#define FLOWGRAPH_OUTER_NAMESPACE oboe
#endif

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

// Default block size that can be overridden when the FlowGraphPortFloat is created.
Expand Down Expand Up @@ -429,5 +437,6 @@ class FlowGraphFilter : public FlowGraphNode {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif /* FLOWGRAPH_FLOW_GRAPH_NODE_H */
2 changes: 1 addition & 1 deletion src/flowgraph/ManyToMultiConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "ManyToMultiConverter.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

ManyToMultiConverter::ManyToMultiConverter(int32_t channelCount)
: inputs(channelCount)
Expand Down
6 changes: 6 additions & 0 deletions src/flowgraph/ManyToMultiConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
* Combine multiple mono inputs into one interleaved multi-channel output.
*/
Expand All @@ -46,4 +49,7 @@ class ManyToMultiConverter : public flowgraph::FlowGraphNode {
private:
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_MANY_TO_MULTI_CONVERTER_H
2 changes: 1 addition & 1 deletion src/flowgraph/MonoToMultiConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "FlowGraphNode.h"
#include "MonoToMultiConverter.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

MonoToMultiConverter::MonoToMultiConverter(int32_t outputChannelCount)
: input(*this, 1)
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/MonoToMultiConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -45,5 +46,6 @@ class MonoToMultiConverter : public FlowGraphNode {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_MONO_TO_MULTI_CONVERTER_H
2 changes: 1 addition & 1 deletion src/flowgraph/MultiToMonoConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "FlowGraphNode.h"
#include "MultiToMonoConverter.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

MultiToMonoConverter::MultiToMonoConverter(int32_t inputChannelCount)
: input(*this, inputChannelCount)
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/MultiToMonoConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -45,5 +46,6 @@ namespace flowgraph {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_MULTI_TO_MONO_CONVERTER_H
2 changes: 1 addition & 1 deletion src/flowgraph/RampLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "FlowGraphNode.h"
#include "RampLinear.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

RampLinear::RampLinear(int32_t channelCount)
: FlowGraphFilter(channelCount) {
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/RampLinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand Down Expand Up @@ -92,5 +93,6 @@ class RampLinear : public FlowGraphFilter {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_RAMP_LINEAR_H
2 changes: 1 addition & 1 deletion src/flowgraph/SampleRateConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "SampleRateConverter.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;
using namespace resampler;

SampleRateConverter::SampleRateConverter(int32_t channelCount, MultiChannelResampler &resampler)
Expand Down
4 changes: 4 additions & 0 deletions src/flowgraph/SampleRateConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "FlowGraphNode.h"
#include "resampler/MultiChannelResampler.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

class SampleRateConverter : public FlowGraphFilter {
Expand Down Expand Up @@ -52,5 +53,8 @@ class SampleRateConverter : public FlowGraphFilter {
int64_t mInputFramePosition = 0; // monotonic counter of input frames used for pullData

};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //OBOE_SAMPLE_RATE_CONVERTER_H
2 changes: 1 addition & 1 deletion src/flowgraph/SinkFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "FlowGraphNode.h"
#include "SinkFloat.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

SinkFloat::SinkFloat(int32_t channelCount)
: FlowGraphSink(channelCount) {
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SinkFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -40,5 +41,6 @@ class SinkFloat : public FlowGraphSink {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SINK_FLOAT_H
2 changes: 1 addition & 1 deletion src/flowgraph/SinkI16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <audio_utils/primitives.h>
#endif

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

SinkI16::SinkI16(int32_t channelCount)
: FlowGraphSink(channelCount) {}
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SinkI16.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -39,5 +40,6 @@ class SinkI16 : public FlowGraphSink {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SINK_I16_H
2 changes: 1 addition & 1 deletion src/flowgraph/SinkI24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <audio_utils/primitives.h>
#endif

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

SinkI24::SinkI24(int32_t channelCount)
: FlowGraphSink(channelCount) {}
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SinkI24.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -40,5 +41,6 @@ class SinkI24 : public FlowGraphSink {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SINK_I24_H
2 changes: 1 addition & 1 deletion src/flowgraph/SourceFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "FlowGraphNode.h"
#include "SourceFloat.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

SourceFloat::SourceFloat(int32_t channelCount)
: FlowGraphSourceBuffered(channelCount) {
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SourceFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -39,5 +40,6 @@ class SourceFloat : public FlowGraphSourceBuffered {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SOURCE_FLOAT_H
2 changes: 1 addition & 1 deletion src/flowgraph/SourceI16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <audio_utils/primitives.h>
#endif

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

SourceI16::SourceI16(int32_t channelCount)
: FlowGraphSourceBuffered(channelCount) {
Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SourceI16.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {
/**
* AudioSource that reads a block of pre-defined 16-bit integer data.
Expand All @@ -38,5 +39,6 @@ class SourceI16 : public FlowGraphSourceBuffered {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SOURCE_I16_H
2 changes: 1 addition & 1 deletion src/flowgraph/SourceI24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "FlowGraphNode.h"
#include "SourceI24.h"

using namespace flowgraph;
using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;

constexpr int kBytesPerI24Packed = 3;

Expand Down
2 changes: 2 additions & 0 deletions src/flowgraph/SourceI24.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "FlowGraphNode.h"

namespace FLOWGRAPH_OUTER_NAMESPACE {
namespace flowgraph {

/**
Expand All @@ -39,5 +40,6 @@ class SourceI24 : public FlowGraphSourceBuffered {
};

} /* namespace flowgraph */
} /* namespace oboe */

#endif //FLOWGRAPH_SOURCE_I24_H

0 comments on commit 9425ffd

Please sign in to comment.