mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 17:05:37 +00:00
Deltacast-dvi: implement dispose function
This commit is contained in:
@@ -84,17 +84,15 @@ extern "C" {
|
||||
#include <VideoMasterHD_Dvi.h>
|
||||
|
||||
struct vidcap_deltacast_dvi_state {
|
||||
struct video_frame *frame;
|
||||
struct tile *tile;
|
||||
ULONG BoardType;
|
||||
HANDLE BoardHandle, StreamHandle;
|
||||
HANDLE SlotHandle;
|
||||
|
||||
struct timeval t, t0;
|
||||
int frames;
|
||||
|
||||
codec_t codec;
|
||||
bool configured;
|
||||
struct video_desc desc;
|
||||
};
|
||||
|
||||
#define EEDDIDOK 0
|
||||
@@ -449,16 +447,12 @@ static bool wait_for_channel_locked(struct vidcap_deltacast_dvi_state *s, bool h
|
||||
return false;
|
||||
}
|
||||
|
||||
struct video_desc desc;
|
||||
desc.color_spec = s->codec;
|
||||
desc.width = Width;
|
||||
desc.height = Height;
|
||||
desc.fps = RefreshRate;
|
||||
desc.interlacing = Interlaced_B ? INTERLACED_MERGED : PROGRESSIVE;
|
||||
desc.tile_count = 1;
|
||||
|
||||
s->frame = vf_alloc_desc(desc);
|
||||
s->tile = vf_get_tile(s->frame, 0);
|
||||
s->desc.color_spec = s->codec;
|
||||
s->desc.width = Width;
|
||||
s->desc.height = Height;
|
||||
s->desc.fps = RefreshRate;
|
||||
s->desc.interlacing = Interlaced_B ? INTERLACED_MERGED : PROGRESSIVE;
|
||||
s->desc.tile_count = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -492,7 +486,7 @@ vidcap_deltacast_dvi_init(const struct vidcap_params *params)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->BoardHandle = s->StreamHandle = s->SlotHandle = NULL;
|
||||
s->BoardHandle = s->StreamHandle = NULL;
|
||||
|
||||
char *init_fmt = NULL;
|
||||
if (vidcap_params_get_fmt(params) != NULL)
|
||||
@@ -705,18 +699,21 @@ vidcap_deltacast_dvi_done(void *state)
|
||||
|
||||
assert(s != NULL);
|
||||
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
VHD_StopStream(s->StreamHandle);
|
||||
VHD_CloseStreamHandle(s->StreamHandle);
|
||||
/* Re-establish RX0-TX0 by-pass relay loopthrough */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,TRUE);
|
||||
VHD_CloseBoardHandle(s->BoardHandle);
|
||||
|
||||
vf_free(s->frame);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void vidcap_deltacast_dvi_dispose(struct video_frame *f)
|
||||
{
|
||||
VHD_UnlockSlotHandle((HANDLE) f->dispose_udata);
|
||||
vf_free(f);
|
||||
}
|
||||
|
||||
struct video_frame *
|
||||
vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio)
|
||||
{
|
||||
@@ -725,6 +722,7 @@ vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio)
|
||||
ULONG /*SlotsCount, SlotsDropped,*/BufferSize;
|
||||
ULONG Result;
|
||||
BYTE *pBuffer=NULL;
|
||||
HANDLE SlotHandle;
|
||||
|
||||
if(!s->configured) {
|
||||
s->configured = wait_for_channel_locked(s, false, NB_VHD_DVI_MODES, 0, 0, 0);
|
||||
@@ -734,10 +732,8 @@ vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio)
|
||||
}
|
||||
|
||||
*audio = NULL;
|
||||
/* Unlock slot */
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
Result = VHD_LockSlotHandle(s->StreamHandle,&s->SlotHandle);
|
||||
|
||||
Result = VHD_LockSlotHandle(s->StreamHandle, &SlotHandle);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
if (Result != VHDERR_TIMEOUT) {
|
||||
fprintf(stderr, "ERROR : Cannot lock slot on RX0 stream. Result = 0x%08X\n",Result);
|
||||
@@ -748,19 +744,22 @@ vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Result = VHD_GetSlotBuffer(s->SlotHandle, VHD_DVI_BT_VIDEO, &pBuffer, &BufferSize);
|
||||
Result = VHD_GetSlotBuffer(SlotHandle, VHD_DVI_BT_VIDEO, &pBuffer, &BufferSize);
|
||||
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "\nERROR : Cannot get slot buffer. Result = 0x%08X\n",Result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(s->frame->color_spec == RGBA) {
|
||||
if(s->desc.color_spec == RGBA) {
|
||||
vc_copylineRGBA(pBuffer, pBuffer, BufferSize, 16, 8, 0);
|
||||
}
|
||||
|
||||
s->tile->data = (char*) pBuffer;
|
||||
s->tile->data_len = BufferSize;
|
||||
struct video_frame *out = vf_alloc_desc(s->desc);
|
||||
out->tiles[0].data = (char*) pBuffer;
|
||||
out->tiles[0].data_len = BufferSize;
|
||||
out->dispose_udata = SlotHandle;
|
||||
out->dispose = vidcap_deltacast_dvi_dispose;
|
||||
|
||||
/* Print some statistics */
|
||||
/*VHD_GetStreamProperty(s->StreamHandle,VHD_CORE_SP_SLOTS_COUNT,&SlotsCount);
|
||||
@@ -776,6 +775,6 @@ vidcap_deltacast_dvi_grab(void *state, struct audio_frame **audio)
|
||||
}
|
||||
s->frames++;
|
||||
|
||||
return s->frame;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user