From 1f226baeab76d405476a9bd06059eceff87b5ba7 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Fri, 15 Dec 2023 11:00:47 -0800 Subject: [PATCH] Prevent deprecation warning for shared openStream() call Call an internal method that does not print the warning. Fixes #1949 --- include/oboe/AudioStreamBuilder.h | 8 ++++++++ src/common/AudioStreamBuilder.cpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/oboe/AudioStreamBuilder.h b/include/oboe/AudioStreamBuilder.h index 89e1447ef..1574a3980 100644 --- a/include/oboe/AudioStreamBuilder.h +++ b/include/oboe/AudioStreamBuilder.h @@ -647,6 +647,14 @@ class AudioStreamBuilder : public AudioStreamBase { private: + /** + * Use this internally to implement opening with a shared_ptr. + * + * @param stream pointer to a variable to receive the stream address + * @return OBOE_OK if successful or a negative error code. + */ + Result openStreamInternal(AudioStream **streamPP); + /** * @param other * @return true if channels, format and sample rate match diff --git a/src/common/AudioStreamBuilder.cpp b/src/common/AudioStreamBuilder.cpp index 7e5e9468d..f655f9fc7 100644 --- a/src/common/AudioStreamBuilder.cpp +++ b/src/common/AudioStreamBuilder.cpp @@ -90,6 +90,10 @@ bool AudioStreamBuilder::isCompatible(AudioStreamBase &other) { Result AudioStreamBuilder::openStream(AudioStream **streamPP) { LOGW("Passing AudioStream pointer deprecated, Use openStream(std::shared_ptr &stream) instead."); + return openStreamInternal(streamPP); +} + +Result AudioStreamBuilder::openStreamInternal(AudioStream **streamPP) { auto result = isValidConfig(); if (result != Result::OK) { LOGW("%s() invalid config %d", __func__, result); @@ -214,7 +218,7 @@ Result AudioStreamBuilder::openManagedStream(oboe::ManagedStream &stream) { Result AudioStreamBuilder::openStream(std::shared_ptr &sharedStream) { sharedStream.reset(); AudioStream *streamptr; - auto result = openStream(&streamptr); + auto result = openStreamInternal(&streamptr); if (result == Result::OK) { sharedStream.reset(streamptr); // Save a weak_ptr in the stream for use with callbacks.