diff options
author | Phil Burk <philburk@mobileer.com> | 2020-04-22 12:10:40 -0700 |
---|---|---|
committer | Phil Burk <philburk@mobileer.com> | 2020-04-22 12:10:40 -0700 |
commit | df6d638ffc5afafbfa40c6c6ba58322e5adc14ef (patch) | |
tree | e482fac4b23cd81d92cc1e152e407e6e26f179eb /include/oboe/AudioStream.h | |
parent | c4556cc6fa309ae622817d7e0e17fbb81fc40fdc (diff) | |
download | oboe-df6d638ffc5afafbfa40c6c6ba58322e5adc14ef.tar.gz |
Oboe: openSharedStream uses ResultWithView
Also use a friend class to hide ssetWeakThis().
Diffstat (limited to 'include/oboe/AudioStream.h')
-rw-r--r-- | include/oboe/AudioStream.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/include/oboe/AudioStream.h b/include/oboe/AudioStream.h index f2452585..faee05b4 100644 --- a/include/oboe/AudioStream.h +++ b/include/oboe/AudioStream.h @@ -42,6 +42,7 @@ constexpr int64_t kDefaultTimeoutNanos = (2000 * kNanosPerMillisecond); * Base class for Oboe C++ audio stream. */ class AudioStream : public AudioStreamBase { + friend class AudioStreamBuilder; // allow access to setWeakThis() and lockWeakThis() public: AudioStream() {} @@ -418,22 +419,6 @@ public: ResultWithValue<int32_t> waitForAvailableFrames(int32_t numFrames, int64_t timeoutNanoseconds); - /* - * INTERNAL USE ONLY - * Set a weak_ptr to this stream from the shared_ptr so that we can - * later use a shared_ptr in the error callback. - */ - void setWeakThis(std::shared_ptr<oboe::AudioStream> &sharedStream) { - mWeakThis = sharedStream; - } - - /* - * Make a shared_ptr that will prevent this stream from being deleted. - */ - std::shared_ptr<oboe::AudioStream> lockWeakThis() { - return mWeakThis.lock(); - } - protected: /** @@ -495,6 +480,23 @@ protected: mDataCallbackEnabled = enabled; } + /* + * Set a weak_ptr to this stream from the shared_ptr so that we can + * later use a shared_ptr in the error callback. + */ + void setWeakThis(std::shared_ptr<oboe::AudioStream> &sharedStream) { + mWeakThis = sharedStream; + } + + /* + * Make a shared_ptr that will prevent this stream from being deleted. + */ + std::shared_ptr<oboe::AudioStream> lockWeakThis() { + return mWeakThis.lock(); + } + + std::weak_ptr<AudioStream> mWeakThis; // weak pointer to this object + /** * Number of frames which have been written into the stream * @@ -520,7 +522,6 @@ private: std::atomic<bool> mDataCallbackEnabled{false}; std::atomic<bool> mErrorCallbackCalled{false}; - std::weak_ptr<AudioStream> mWeakThis; }; /** |