aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgfan <gfan@google.com>2020-09-18 17:03:44 -0700
committergfan <gfan@google.com>2020-09-23 10:41:46 -0700
commite6c40ab7fc6c9791fc1fd862a8c6cf548fd65cd0 (patch)
tree1c968ffe088834efbd29b800349bf1388872e862 /src
parent6d5a4f925bc6b8d9c5a0f01d7de6e53850a769ca (diff)
downloadoboe-e6c40ab7fc6c9791fc1fd862a8c6cf548fd65cd0.tar.gz
Fixing github issue #989: add parameter validation to AudioStreamBase
Diffstat (limited to 'src')
-rw-r--r--src/common/AudioStreamBuilder.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/AudioStreamBuilder.cpp b/src/common/AudioStreamBuilder.cpp
index 69420cd1..9e277d69 100644
--- a/src/common/AudioStreamBuilder.cpp
+++ b/src/common/AudioStreamBuilder.cpp
@@ -87,7 +87,11 @@ bool AudioStreamBuilder::isCompatible(AudioStreamBase &other) {
}
Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
- Result result = Result::OK;
+ auto result = isValidConfig();
+ if (result != Result::OK) {
+ return result;
+ }
+
LOGI("%s() %s -------- %s --------",
__func__, getDirection() == Direction::Input ? "INPUT" : "OUTPUT", getVersionText());
@@ -183,17 +187,26 @@ Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
}
Result AudioStreamBuilder::openManagedStream(oboe::ManagedStream &stream) {
+ auto result = isValidConfig();
+ if (result != Result::OK) {
+ return result;
+ }
stream.reset();
AudioStream *streamptr;
- auto result = openStream(&streamptr);
+ result = openStream(&streamptr);
stream.reset(streamptr);
return result;
}
Result AudioStreamBuilder::openStream(std::shared_ptr<AudioStream> &sharedStream) {
+ auto result = isValidConfig();
+ if (result != Result::OK) {
+ return result;
+ }
+
sharedStream.reset();
AudioStream *streamptr;
- auto result = openStream(&streamptr);
+ result = openStream(&streamptr);
if (result == Result::OK) {
sharedStream.reset(streamptr);
// Save a weak_ptr in the stream for use with callbacks.