Index: /trunk/src/VBox/Main/include/Recording.h
===================================================================
--- /trunk/src/VBox/Main/include/Recording.h	(revision 76892)
+++ /trunk/src/VBox/Main/include/Recording.h	(revision 76893)
@@ -35,5 +35,5 @@
 
 /**
- * Class for managing a capturing context.
+ * Class for managing a recording context.
  */
 class RecordingContext
@@ -52,5 +52,5 @@
 
     int Create(const settings::RecordingSettings &a_Settings);
-    int Destroy(void);
+    void Destroy(void);
 
     int Start(void);
@@ -65,5 +65,5 @@
 
     bool IsFeatureEnabled(RecordingFeature_T enmFeature);
-    bool IsReady(void) const;
+    bool IsReady(void);
     bool IsReady(uint32_t uScreen, uint64_t msTimestamp);
     bool IsStarted(void);
@@ -79,5 +79,5 @@
     int stopInternal(void);
 
-    int destroyInternal(void);
+    void destroyInternal(void);
 
     RecordingStream *getStreamInternal(unsigned uScreen) const;
Index: /trunk/src/VBox/Main/src-client/Recording.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/Recording.cpp	(revision 76892)
+++ /trunk/src/VBox/Main/src-client/Recording.cpp	(revision 76893)
@@ -217,8 +217,5 @@
 
     if (RT_FAILURE(rc))
-    {
-        int rc2 = destroyInternal();
-        AssertRC(rc2);
-    }
+        destroyInternal();
 
     return rc;
@@ -274,4 +271,6 @@
         rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
 
+    lock();
+
     if (RT_SUCCESS(rc))
     {
@@ -282,4 +281,6 @@
         Log(("Recording: Failed to stop (%Rrc)\n", rc));
 
+    unlock();
+
     LogFlowThisFunc(("%Rrc\n", rc));
     return rc;
@@ -289,49 +290,47 @@
  * Destroys a recording context, internal version.
  */
-int RecordingContext::destroyInternal(void)
-{
+void RecordingContext::destroyInternal(void)
+{
+    if (this->enmState == RECORDINGSTS_UNINITIALIZED)
+        return;
+
     int rc = stopInternal();
-    if (RT_FAILURE(rc))
-        return rc;
+    AssertRCReturnVoid(rc);
+
+    lock();
 
     rc = RTSemEventDestroy(this->WaitEvent);
-    AssertRC(rc);
+    AssertRCReturnVoid(rc);
 
     this->WaitEvent = NIL_RTSEMEVENT;
 
-    rc = RTCritSectEnter(&this->CritSect);
-    if (RT_SUCCESS(rc))
-    {
-        RecordingStreams::iterator it = this->vecStreams.begin();
-        while (it != this->vecStreams.end())
-        {
-            RecordingStream *pStream = (*it);
-
-            int rc2 = pStream->Uninit();
-            if (RT_SUCCESS(rc))
-                rc = rc2;
-
-            delete pStream;
-            pStream = NULL;
-
-            this->vecStreams.erase(it);
-            it = this->vecStreams.begin();
-
-            delete pStream;
-            pStream = NULL;
-        }
-
-        /* Sanity. */
-        Assert(this->vecStreams.empty());
-        Assert(this->mapBlocksCommon.size() == 0);
-
-        int rc2 = RTCritSectLeave(&this->CritSect);
-        AssertRC(rc2);
-
+    RecordingStreams::iterator it = this->vecStreams.begin();
+    while (it != this->vecStreams.end())
+    {
+        RecordingStream *pStream = (*it);
+
+        rc = pStream->Uninit();
+        AssertRC(rc);
+
+        delete pStream;
+        pStream = NULL;
+
+        this->vecStreams.erase(it);
+        it = this->vecStreams.begin();
+    }
+
+    /* Sanity. */
+    Assert(this->vecStreams.empty());
+    Assert(this->mapBlocksCommon.size() == 0);
+
+    unlock();
+
+    if (RTCritSectIsInitialized(&this->CritSect))
+    {
+        Assert(RTCritSectGetWaiters(&this->CritSect) == -1);
         RTCritSectDelete(&this->CritSect);
     }
 
-    LogFlowThisFunc(("%Rrc\n", rc));
-    return rc;
+    this->enmState = RECORDINGSTS_UNINITIALIZED;
 }
 
@@ -418,7 +417,7 @@
  * Destroys a recording context.
  */
-int RecordingContext::Destroy(void)
-{
-    return destroyInternal();
+void RecordingContext::Destroy(void)
+{
+    destroyInternal();
 }
 
@@ -474,7 +473,13 @@
  * @returns @c true if recording context is ready, @c false if not.
  */
-bool RecordingContext::IsReady(void) const
-{
-    return (this->enmState >= RECORDINGSTS_CREATED);
+bool RecordingContext::IsReady(void)
+{
+    lock();
+
+    const bool fIsReady = this->enmState >= RECORDINGSTS_CREATED;
+
+    unlock();
+
+    return fIsReady;
 }
 
@@ -624,7 +629,7 @@
     pBlock->msTimestamp = msTimestamp;
 
-    int rc = RTCritSectEnter(&this->CritSect);
-    if (RT_FAILURE(rc))
-        return rc;
+    lock();
+
+    int rc;
 
     try
@@ -640,4 +645,6 @@
         else
             itBlocks->second->List.push_back(pBlock);
+
+        rc = VINF_SUCCESS;
     }
     catch (const std::exception &ex)
@@ -647,6 +654,5 @@
     }
 
-    int rc2 = RTCritSectLeave(&this->CritSect);
-    AssertRC(rc2);
+    unlock();
 
     if (RT_SUCCESS(rc))
@@ -687,12 +693,10 @@
     AssertReturn(puSrcData,  VERR_INVALID_POINTER);
 
-    int rc = RTCritSectEnter(&this->CritSect);
-    AssertRC(rc);
+    lock();
 
     RecordingStream *pStream = GetStream(uScreen);
     if (!pStream)
     {
-        rc = RTCritSectLeave(&this->CritSect);
-        AssertRC(rc);
+        unlock();
 
         AssertFailed();
@@ -700,8 +704,7 @@
     }
 
-    rc = pStream->SendVideoFrame(x, y, uPixelFormat, uBPP, uBytesPerLine, uSrcWidth, uSrcHeight, puSrcData, msTimestamp);
-
-    int rc2 = RTCritSectLeave(&this->CritSect);
-    AssertRC(rc2);
+    int rc = pStream->SendVideoFrame(x, y, uPixelFormat, uBPP, uBytesPerLine, uSrcWidth, uSrcHeight, puSrcData, msTimestamp);
+
+    unlock();
 
     if (   RT_SUCCESS(rc)
