Merge "Increase check to switch USB device to AOAP timeout" into rvc-qpr-dev
diff --git a/evs/manager/1.1/HalCamera.cpp b/evs/manager/1.1/HalCamera.cpp
index 38297bb..f4d2c49 100644
--- a/evs/manager/1.1/HalCamera.cpp
+++ b/evs/manager/1.1/HalCamera.cpp
@@ -236,6 +236,12 @@
 
     std::lock_guard<std::mutex> lock(mFrameMutex);
 
+    if (mTimelines.find(id) == mTimelines.end()) {
+        // Timeline for this client either does not exist or is deleted.
+        LOG(ERROR) << "Timeline for this client does not exist.";
+        return {};
+    }
+
     mTimelines[id]->BumpFenceEventCounter();
     UniqueFence fence = mTimelines[id]->CreateFence("FrameFence");
 
diff --git a/evs/manager/1.1/VirtualCamera.cpp b/evs/manager/1.1/VirtualCamera.cpp
index 6204a78..fda58d1 100644
--- a/evs/manager/1.1/VirtualCamera.cpp
+++ b/evs/manager/1.1/VirtualCamera.cpp
@@ -180,10 +180,13 @@
                 // Warn if we got an unexpected stream termination
                 LOG(WARNING) << "Stream unexpectedly stopped, current status "
                              << mStreamState;
-            }
 
-            // Mark the stream as stopped.
-            mStreamState = STOPPED;
+                // Clean up the resource and forward an event to the client
+                stopVideoStream();
+
+                // This event is handled properly.
+                return true;
+            }
 
             if (mStream_1_1 == nullptr) {
                 // Send a null frame instead, for v1.0 client