summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-11-08 00:33:46 -0600
committerMisael Lopez Cruz2013-11-11 13:01:16 -0600
commit9da7b006e3a17b97815a86d8487c2b9dc7b374cf (patch)
tree793f668c37b03dc9d5924812d8bf6bc2bfc4279a
parent50db622848f29e112a98ef910dbaa3e82fe3be28 (diff)
downloaddevice-ti-common-open-9da7b006e3a17b97815a86d8487c2b9dc7b374cf.tar.gz
device-ti-common-open-9da7b006e3a17b97815a86d8487c2b9dc7b374cf.tar.xz
device-ti-common-open-9da7b006e3a17b97815a86d8487c2b9dc7b374cf.zip
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.h18
-rw-r--r--audio/utils/include/tiaudioutils/Stream.h18
-rw-r--r--audio/utils/src/SimpleStream.cpp12
-rw-r--r--audio/utils/src/Stream.cpp12
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 {
298 */ 298 */
299 virtual void unregisterStream(SimpleInStream *stream); 299 virtual void unregisterStream(SimpleInStream *stream);
300 300
301 /**
302 * \brief Check if an input stream is registered
303 *
304 * Tests if an input stream is currently registered with the PCM reader.
305 *
306 * \return true if the stream is registered, false otherwise
307 */
308 virtual bool isStreamRegistered(SimpleInStream *stream);
309
301 friend class SimpleInStream; 310 friend class SimpleInStream;
302 311
303 private: 312 private:
@@ -460,6 +469,15 @@ class SimpleWriter {
460 */ 469 */
461 virtual void unregisterStream(SimpleOutStream *stream); 470 virtual void unregisterStream(SimpleOutStream *stream);
462 471
472 /**
473 * \brief Check if an output stream is registered
474 *
475 * Tests if an output stream is currently registered with the PCM writer.
476 *
477 * \return true if the stream is registered, false otherwise
478 */
479 virtual bool isStreamRegistered(SimpleOutStream *stream);
480
463 friend class SimpleOutStream; 481 friend class SimpleOutStream;
464 482
465 private: 483 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 {
851 */ 851 */
852 virtual void unregisterStream(sp<InStream>& stream); 852 virtual void unregisterStream(sp<InStream>& stream);
853 853
854 /**
855 * \brief Check if an input stream is registered
856 *
857 * Tests if an input stream is currently registered with the PCM reader.
858 *
859 * \return true if the stream is registered, false otherwise
860 */
861 virtual bool isStreamRegistered(sp<InStream>& stream);
862
854 friend class InStream; 863 friend class InStream;
855 864
856 private: 865 private:
@@ -995,6 +1004,15 @@ class PcmWriter : protected ThreadBase {
995 */ 1004 */
996 virtual void unregisterStream(sp<OutStream>& stream); 1005 virtual void unregisterStream(sp<OutStream>& stream);
997 1006
1007 /**
1008 * \brief Check if an output stream is registered
1009 *
1010 * Tests if an output stream is currently registered with the PCM writer.
1011 *
1012 * \return true if the stream is registered, false otherwise
1013 */
1014 virtual bool isStreamRegistered(sp<OutStream>& stream);
1015
998 friend class OutStream; 1016 friend class OutStream;
999 1017
1000 private: 1018 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)
324 mStream = NULL; 324 mStream = NULL;
325} 325}
326 326
327bool SimpleReader::isStreamRegistered(SimpleInStream *stream)
328{
329 AutoMutex lock(mLock);
330 return (mStream == stream);
331}
332
327int SimpleReader::open() 333int SimpleReader::open()
328{ 334{
329 ALOGI("SimpleReader: open PCM port"); 335 ALOGI("SimpleReader: open PCM port");
@@ -540,6 +546,12 @@ void SimpleWriter::unregisterStream(SimpleOutStream *stream)
540 mStream = NULL; 546 mStream = NULL;
541} 547}
542 548
549bool SimpleWriter::isStreamRegistered(SimpleOutStream *stream)
550{
551 AutoMutex lock(mLock);
552 return (mStream == stream);
553}
554
543int SimpleWriter::open() 555int SimpleWriter::open()
544{ 556{
545 ALOGI("SimpleWriter: open PCM port"); 557 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)
754 } 754 }
755} 755}
756 756
757bool PcmReader::isStreamRegistered(sp<InStream>& stream)
758{
759 AutoMutex lock(mLock);
760 return (mStreams.find(stream) != mStreams.end());
761}
762
757int PcmReader::open() 763int PcmReader::open()
758{ 764{
759 AutoMutex lock(mLock); 765 AutoMutex lock(mLock);
@@ -992,6 +998,12 @@ void PcmWriter::unregisterStream(sp<OutStream>& stream)
992 } 998 }
993} 999}
994 1000
1001bool PcmWriter::isStreamRegistered(sp<OutStream>& stream)
1002{
1003 AutoMutex lock(mLock);
1004 return (mStreams.find(stream) != mStreams.end());
1005}
1006
995int PcmWriter::open() 1007int PcmWriter::open()
996{ 1008{
997 AutoMutex lock(mLock); 1009 AutoMutex lock(mLock);