avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia"
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
caca_outdev_deps="libcaca"
-decklink_indev_deps="decklink pthreads"
+decklink_indev_deps="decklink threads"
decklink_indev_extralibs="-lstdc++"
-decklink_outdev_deps="decklink pthreads"
+decklink_outdev_deps="decklink threads"
decklink_outdev_extralibs="-lstdc++"
dshow_indev_deps="IBaseFilter"
dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
#include <DeckLinkAPI.h>
-#include <pthread.h>
-#include <semaphore.h>
-
extern "C" {
#include "libavformat/avformat.h"
#include "libavformat/internal.h"
av_frame_unref(avframe);
- sem_post(&ctx->semaphore);
+ pthread_mutex_lock(&ctx->mutex);
+ ctx->frames_buffer_available_spots++;
+ pthread_cond_broadcast(&ctx->cond);
+ pthread_mutex_unlock(&ctx->mutex);
return S_OK;
}
ctx->output_callback = new decklink_output_callback();
ctx->dlo->SetScheduledFrameCompletionCallback(ctx->output_callback);
- /* Start video semaphore. */
ctx->frames_preroll = st->time_base.den * ctx->preroll;
if (st->time_base.den > 1000)
ctx->frames_preroll /= 1000;
/* Buffer twice as many frames as the preroll. */
ctx->frames_buffer = ctx->frames_preroll * 2;
ctx->frames_buffer = FFMIN(ctx->frames_buffer, 60);
- sem_init(&ctx->semaphore, 0, ctx->frames_buffer);
+ pthread_mutex_init(&ctx->mutex, NULL);
+ pthread_cond_init(&ctx->cond, NULL);
+ ctx->frames_buffer_available_spots = ctx->frames_buffer;
/* The device expects the framerate to be fixed. */
avpriv_set_pts_info(st, 64, st->time_base.num, st->time_base.den);
if (ctx->output_callback)
delete ctx->output_callback;
- sem_destroy(&ctx->semaphore);
+ pthread_mutex_destroy(&ctx->mutex);
+ pthread_cond_destroy(&ctx->cond);
av_freep(&cctx->ctx);
}
/* Always keep at most one second of frames buffered. */
- sem_wait(&ctx->semaphore);
+ pthread_mutex_lock(&ctx->mutex);
+ while (ctx->frames_buffer_available_spots == 0) {
+ pthread_cond_wait(&ctx->cond, &ctx->mutex);
+ }
+ ctx->frames_buffer_available_spots--;
+ pthread_mutex_unlock(&ctx->mutex);
/* Schedule frame for playback. */
hr = ctx->dlo->ScheduleVideoFrame((struct IDeckLinkVideoFrame *) frame,