Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent deprecation warning for shared openStream() call #1950

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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