Skip to content

Commit

Permalink
Prevent deprecation warning for shared openStream() call (#1950)
Browse files Browse the repository at this point in the history
Call an internal method that does not print the warning.

Fixes #1949
  • Loading branch information
philburk authored Dec 15, 2023
1 parent 8d66ac5 commit cb4e5d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/oboe/AudioStreamBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/common/AudioStreamBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ bool AudioStreamBuilder::isCompatible(AudioStreamBase &other) {

Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
LOGW("Passing AudioStream pointer deprecated, Use openStream(std::shared_ptr<oboe::AudioStream> &stream) instead.");
return openStreamInternal(streamPP);
}

Result AudioStreamBuilder::openStreamInternal(AudioStream **streamPP) {
auto result = isValidConfig();
if (result != Result::OK) {
LOGW("%s() invalid config %d", __func__, result);
Expand Down Expand Up @@ -214,7 +218,7 @@ Result AudioStreamBuilder::openManagedStream(oboe::ManagedStream &stream) {
Result AudioStreamBuilder::openStream(std::shared_ptr<AudioStream> &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.
Expand Down

0 comments on commit cb4e5d2

Please sign in to comment.