I was just looking into this at this very moment and I am not sure if I use it 
well.

I was reading the [Thread 
coordination](https://nim-lang.org/docs/backends.html#memory-management-thread-coordination)
 section and this [forum entry](https://forum.nim-lang.org/t/3965#24714).

So I was implementing the following:
    
    
    proc callback( userData: pointer,
                f: ptr VSFrameRef,
                n: cint,
                a4: ptr VSNodeRef,
                errorMsg: cstring) {.cdecl.} =
    setupForeignThreadGc()     #<---------------------
    API.freeFrame( f )
    tearDownForeignThreadGc()    #<---------------------
    
    
    proc NullAsync*(vsmap:ptr VSMap):int =
    let node = getFirstNode(vsmap)
    #API.freeMap(vsmap)
    let vinfo = API.getVideoInfo(node) # video info pointer
    let nframes = vinfo.numFrames
    for i in 0..<nframes:
        API.getFrameAsync( i, node, callback, nil)     # getFrameAsync is part 
of the API and calls the callback.
    
    API.freeMap(vsmap)
    API.freeNode(node)
    return nframes
    
    Run

Right now it fails. I am compiling with \--threads:on.

I am not sure if I am not using it as I should or if I am not using properly 
the VapourSynth's API.

Reply via email to