Search code examples
swiftcmsamplebuffer

CMSampleBufferCreate causes Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)


I am trying to make a CMSampleBuffer out of a CMBlockBuffer and I am using CMSampleBufferCreate but whatever I try I always get Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

let status = CMSampleBufferCreate(kCFAllocatorDefault,
                                              buffer, //CMBlockBuffer cannot be nil
                                              true,
                                              nil,
                                              nil,
                                              nil,
                                              1,
                                              0,
                                              nil,
                                              1,
                                              nil,
                                              &sampleBuffer //sampleBuffer is nil
)

I do not know how to do this so if there is another way or if I am doing something wrong please tell me because there are not many examples of this. Thanks so much!


Solution

  • I got it I needed to change it to:

    let status = CMSampleBufferCreate(kCFAllocatorDefault,
                                                  buffer,
                                                  true,
                                                  nil,
                                                  nil,
                                                  nil,
                                                  1,
                                                  0,
                                                  nil,
                                                  0,
                                                  nil,
                                                  &sampleBuffer
    )