diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2013-11-08 00:33:46 -0600 |
---|---|---|
committer | Misael Lopez Cruz <misael.lopez@ti.com> | 2013-11-11 13:01:16 -0600 |
commit | 9da7b006e3a17b97815a86d8487c2b9dc7b374cf (patch) | |
tree | 793f668c37b03dc9d5924812d8bf6bc2bfc4279a | |
parent | 50db622848f29e112a98ef910dbaa3e82fe3be28 (diff) | |
download | common-open-9da7b006e3a17b97815a86d8487c2b9dc7b374cf.tar.gz |
audio: utils: Add isStreamRegister() helper methods
Add a helper method to PCM reader/writer and simple reader/writer
to check if a given input/output stream is currently registered.
Change-Id: Ib818ea901a2c379b418196c5142f28cec57e9f60
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r-- | audio/utils/include/tiaudioutils/SimpleStream.h | 18 | ||||
-rw-r--r-- | audio/utils/include/tiaudioutils/Stream.h | 18 | ||||
-rw-r--r-- | audio/utils/src/SimpleStream.cpp | 12 | ||||
-rw-r--r-- | audio/utils/src/Stream.cpp | 12 |
4 files changed, 60 insertions, 0 deletions
diff --git a/audio/utils/include/tiaudioutils/SimpleStream.h b/audio/utils/include/tiaudioutils/SimpleStream.h index f9b6db7..9f8e16b 100644 --- a/audio/utils/include/tiaudioutils/SimpleStream.h +++ b/audio/utils/include/tiaudioutils/SimpleStream.h @@ -298,6 +298,15 @@ class SimpleReader { */ virtual void unregisterStream(SimpleInStream *stream); + /** + * \brief Check if an input stream is registered + * + * Tests if an input stream is currently registered with the PCM reader. + * + * \return true if the stream is registered, false otherwise + */ + virtual bool isStreamRegistered(SimpleInStream *stream); + friend class SimpleInStream; private: @@ -460,6 +469,15 @@ class SimpleWriter { */ virtual void unregisterStream(SimpleOutStream *stream); + /** + * \brief Check if an output stream is registered + * + * Tests if an output stream is currently registered with the PCM writer. + * + * \return true if the stream is registered, false otherwise + */ + virtual bool isStreamRegistered(SimpleOutStream *stream); + friend class SimpleOutStream; private: diff --git a/audio/utils/include/tiaudioutils/Stream.h b/audio/utils/include/tiaudioutils/Stream.h index e81bce9..c7cd39f 100644 --- a/audio/utils/include/tiaudioutils/Stream.h +++ b/audio/utils/include/tiaudioutils/Stream.h @@ -851,6 +851,15 @@ class PcmReader : protected ThreadBase { */ virtual void unregisterStream(sp<InStream>& stream); + /** + * \brief Check if an input stream is registered + * + * Tests if an input stream is currently registered with the PCM reader. + * + * \return true if the stream is registered, false otherwise + */ + virtual bool isStreamRegistered(sp<InStream>& stream); + friend class InStream; private: @@ -995,6 +1004,15 @@ class PcmWriter : protected ThreadBase { */ virtual void unregisterStream(sp<OutStream>& stream); + /** + * \brief Check if an output stream is registered + * + * Tests if an output stream is currently registered with the PCM writer. + * + * \return true if the stream is registered, false otherwise + */ + virtual bool isStreamRegistered(sp<OutStream>& stream); + friend class OutStream; private: diff --git a/audio/utils/src/SimpleStream.cpp b/audio/utils/src/SimpleStream.cpp index 5b1ddd5..c3f262f 100644 --- a/audio/utils/src/SimpleStream.cpp +++ b/audio/utils/src/SimpleStream.cpp @@ -324,6 +324,12 @@ void SimpleReader::unregisterStream(SimpleInStream *stream) mStream = NULL; } +bool SimpleReader::isStreamRegistered(SimpleInStream *stream) +{ + AutoMutex lock(mLock); + return (mStream == stream); +} + int SimpleReader::open() { ALOGI("SimpleReader: open PCM port"); @@ -540,6 +546,12 @@ void SimpleWriter::unregisterStream(SimpleOutStream *stream) mStream = NULL; } +bool SimpleWriter::isStreamRegistered(SimpleOutStream *stream) +{ + AutoMutex lock(mLock); + return (mStream == stream); +} + int SimpleWriter::open() { ALOGI("SimpleWriter: open PCM port"); diff --git a/audio/utils/src/Stream.cpp b/audio/utils/src/Stream.cpp index dad252d..402c3f7 100644 --- a/audio/utils/src/Stream.cpp +++ b/audio/utils/src/Stream.cpp @@ -754,6 +754,12 @@ void PcmReader::unregisterStream(sp<InStream>& stream) } } +bool PcmReader::isStreamRegistered(sp<InStream>& stream) +{ + AutoMutex lock(mLock); + return (mStreams.find(stream) != mStreams.end()); +} + int PcmReader::open() { AutoMutex lock(mLock); @@ -992,6 +998,12 @@ void PcmWriter::unregisterStream(sp<OutStream>& stream) } } +bool PcmWriter::isStreamRegistered(sp<OutStream>& stream) +{ + AutoMutex lock(mLock); + return (mStreams.find(stream) != mStreams.end()); +} + int PcmWriter::open() { AutoMutex lock(mLock); |