1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VTCompressionSessionEncodeFrame deadlock現象

Posted at

現象

動画のsample bufferを独自作成されたqueueでエンコードしてますが、たまにencoderリセットしたあとエンコード走るとVTCompressionSessionEncodeFrame
でdeadlockになって、statusも返ってこないまあまあ死んでしまう

code


-(void)append:(CMSampleBufferRef)sb
{
    CFRetain(sb);
    dispatch_async(queue, ^{
         .....

         // ここでdead lock,statusも返ってこない
         auto s = VTCompressionSessionEncodeFrame(mImpl.mSession, cr, CMSampleBufferGetPresentationTimeStamp(sb), CMSampleBufferGetDuration(sb),    nullptr, nullptr, &flags);
      if (s) {
         NSLog(@"encode status %d", (int)s);
      }
        // samplebuffer解放
        CFRelease(sb);
    });
}

原因

encoder session解放処理をエンコード処理と同じqueueで処理してなかったから。

修正


-(void)invalidateSession
{
    dispatch_async(queue, ^{
     if (mSession) {
            VTCompressionSessionInvalidate(mSession);
        }
   });
}


1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?