diff options
author | gfan <gfan@google.com> | 2020-09-18 17:03:44 -0700 |
---|---|---|
committer | gfan <gfan@google.com> | 2020-09-23 10:41:46 -0700 |
commit | e6c40ab7fc6c9791fc1fd862a8c6cf548fd65cd0 (patch) | |
tree | 1c968ffe088834efbd29b800349bf1388872e862 /src | |
parent | 6d5a4f925bc6b8d9c5a0f01d7de6e53850a769ca (diff) | |
download | oboe-e6c40ab7fc6c9791fc1fd862a8c6cf548fd65cd0.tar.gz |
Fixing github issue #989: add parameter validation to AudioStreamBase
Diffstat (limited to 'src')
-rw-r--r-- | src/common/AudioStreamBuilder.cpp | 19 |
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. |