CCodec: Delay stop using surface until the end of release()

Delay stop using surface until the end of release() in order not to
interfere internal Codec work.

Bug: 242685100
Test: atest android.media.codec.cts.MediaCodecTest
Test: atest android.media.decoder.cts.AdaptivePlaybackTest
Change-Id: I9a4639d5cfd58feb91655713191e4e75bae06b24
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 124a893..72301db 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1973,7 +1973,6 @@
     }
 
     mChannel->reset();
-    mChannel->stopUseOutputSurface();
     // thiz holds strong ref to this while the thread is running.
     sp<CCodec> thiz(this);
     std::thread([thiz, sendCallback] { thiz->release(sendCallback); }).detach();
@@ -1994,6 +1993,7 @@
         comp = state->comp;
     }
     comp->release();
+    mChannel->stopUseOutputSurface();
 
     {
         Mutexed<State>::Locked state(mState);