Merge "pal: Use increase/decrease StreamUserCounter to protect getTimestamp"
diff --git a/Pal.cpp b/Pal.cpp
index 46b3b86..e0fc84f 100644
--- a/Pal.cpp
+++ b/Pal.cpp
@@ -892,13 +892,19 @@
}
rm->lockActiveStream();
- if (rm->isActiveStream(stream_handle)) {
- s = reinterpret_cast<Stream *>(stream_handle);
- status = s->getTimestamp(stime);
- } else {
- PAL_ERR(LOG_TAG, "stream handle in stale state.\n");
+ s = reinterpret_cast<Stream *>(stream_handle);
+ status = rm->increaseStreamUserCounter(s);
+ if (0 != status) {
+ rm->unlockActiveStream();
+ PAL_ERR(LOG_TAG, "failed to increase stream user count");
+ return status;
}
rm->unlockActiveStream();
+ status = s->getTimestamp(stime);
+
+ rm->lockActiveStream();
+ rm->decreaseStreamUserCounter(s);
+ rm->unlockActiveStream();
if (0 != status) {
PAL_ERR(LOG_TAG, "pal_get_timestamp failed with status %d\n", status);