Commit bbcd07ff authored by Steve Lhomme's avatar Steve Lhomme

directx_va: group the pool/device callbacks in a const structure

parent 393a7750
......@@ -341,14 +341,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
dx_sys = &sys->dx_sys;
dx_sys->va_pool.pf_create_device = D3dCreateDevice;
dx_sys->va_pool.pf_destroy_device = D3dDestroyDevice;
dx_sys->va_pool.pf_create_video_service = DxCreateVideoService;
dx_sys->va_pool.pf_destroy_video_service = DxDestroyVideoService;
dx_sys->va_pool.pf_create_decoder_surfaces = DxCreateDecoderSurfaces;
dx_sys->va_pool.pf_destroy_surfaces = DxDestroySurfaces;
dx_sys->va_pool.pf_setup_avcodec_ctx = SetupAVCodecContext;
dx_sys->va_pool.pf_new_surface_context = NewSurfacePicContext;
dx_sys->pf_get_input_list = DxGetInputList;
dx_sys->pf_setup_output = DxSetupOutput;
......@@ -387,7 +379,19 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
}
}
err = directx_va_Open(va, &sys->dx_sys);
static const struct va_pool_cfg pool_cfg = {
D3dCreateDevice,
D3dDestroyDevice,
NULL, NULL,
DxCreateVideoService,
DxDestroyVideoService,
DxCreateDecoderSurfaces,
DxDestroySurfaces,
SetupAVCodecContext,
NewSurfacePicContext,
};
err = directx_va_Open(va, &pool_cfg, &sys->dx_sys);
if (err!=VLC_SUCCESS)
goto error;
......
......@@ -339,9 +339,9 @@ void directx_va_Close(vlc_va_t *va, directx_sys_t *dx_sys)
va_pool_Close(va, &dx_sys->va_pool);
}
int directx_va_Open(vlc_va_t *va, directx_sys_t *dx_sys)
int directx_va_Open(vlc_va_t *va, const struct va_pool_cfg *cbs, directx_sys_t *dx_sys)
{
return va_pool_Open(va, &dx_sys->va_pool);
return va_pool_Open(va, cbs, &dx_sys->va_pool);
}
static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *fmt,
......
......@@ -77,7 +77,7 @@ typedef struct
} directx_sys_t;
int directx_va_Open(vlc_va_t *, directx_sys_t *);
int directx_va_Open(vlc_va_t *, const struct va_pool_cfg *, directx_sys_t *);
void directx_va_Close(vlc_va_t *, directx_sys_t *);
int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox);
char *directx_va_GetDecoderName(const GUID *guid);
......
......@@ -303,22 +303,25 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
dx_sys = &sys->dx_sys;
dx_sys->va_pool.pf_create_device = D3dCreateDevice;
dx_sys->va_pool.pf_destroy_device = D3dDestroyDevice;
dx_sys->va_pool.pf_create_device_manager = D3dCreateDeviceManager;
dx_sys->va_pool.pf_destroy_device_manager = D3dDestroyDeviceManager;
dx_sys->va_pool.pf_create_video_service = DxCreateVideoService;
dx_sys->va_pool.pf_destroy_video_service = DxDestroyVideoService;
dx_sys->va_pool.pf_create_decoder_surfaces = DxCreateVideoDecoder;
dx_sys->va_pool.pf_destroy_surfaces = DxDestroyVideoDecoder;
dx_sys->va_pool.pf_setup_avcodec_ctx = SetupAVCodecContext;
dx_sys->va_pool.pf_new_surface_context = NewSurfacePicContext;
static const struct va_pool_cfg pool_cfg = {
D3dCreateDevice,
D3dDestroyDevice,
D3dCreateDeviceManager,
D3dDestroyDeviceManager,
DxCreateVideoService,
DxDestroyVideoService,
DxCreateVideoDecoder,
DxDestroyVideoDecoder,
SetupAVCodecContext,
NewSurfacePicContext,
};
dx_sys->pf_get_input_list = DxGetInputList;
dx_sys->pf_setup_output = DxSetupOutput;
va->sys = sys;
err = directx_va_Open(va, &sys->dx_sys);
err = directx_va_Open(va, &pool_cfg, &sys->dx_sys);
if (err!=VLC_SUCCESS)
goto error;
......
......@@ -48,7 +48,7 @@ static void DestroyVideoDecoder(vlc_va_sys_t *sys, va_pool_t *va_pool)
{
for (unsigned i = 0; i < va_pool->surface_count; i++)
va_surface_Release(va_pool->surface[i]->va_surface);
va_pool->pf_destroy_surfaces(sys);
va_pool->callbacks->pf_destroy_surfaces(sys);
va_pool->surface_count = 0;
}
......@@ -97,7 +97,7 @@ int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext
fmt.i_frame_rate = avctx->framerate.num;
fmt.i_frame_rate_base = avctx->framerate.den;
err = va_pool->pf_create_decoder_surfaces(va, avctx->codec_id, &fmt, count);
err = va_pool->callbacks->pf_create_decoder_surfaces(va, avctx->codec_id, &fmt, count);
if (err == VLC_SUCCESS)
{
va_pool->surface_width = surface_width;
......@@ -107,7 +107,7 @@ int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext
done:
va_pool->surface_count = i;
if (err == VLC_SUCCESS)
va_pool->pf_setup_avcodec_ctx(va->sys);
va_pool->callbacks->pf_setup_avcodec_ctx(va->sys);
return err;
}
......@@ -121,7 +121,7 @@ int va_pool_SetupSurfaces(vlc_va_t *va, va_pool_t *va_pool, unsigned count)
struct vlc_va_surface_t *p_surface = malloc(sizeof(*p_surface));
if (unlikely(p_surface==NULL))
goto done;
va_pool->surface[i] = va_pool->pf_new_surface_context(va, i);
va_pool->surface[i] = va_pool->callbacks->pf_new_surface_context(va, i);
if (unlikely(va_pool->surface[i]==NULL))
{
free(p_surface);
......@@ -135,7 +135,7 @@ int va_pool_SetupSurfaces(vlc_va_t *va, va_pool_t *va_pool, unsigned count)
done:
va_pool->surface_count = i;
if (err == VLC_SUCCESS)
va_pool->pf_setup_avcodec_ctx(va->sys);
va_pool->callbacks->pf_setup_avcodec_ctx(va->sys);
return err;
}
......@@ -191,32 +191,34 @@ void va_surface_Release(vlc_va_surface_t *surface)
void va_pool_Close(vlc_va_t *va, va_pool_t *va_pool)
{
DestroyVideoDecoder(va->sys, va_pool);
va_pool->pf_destroy_video_service(va);
if (va_pool->pf_destroy_device_manager)
va_pool->pf_destroy_device_manager(va);
va_pool->pf_destroy_device(va->sys);
va_pool->callbacks->pf_destroy_video_service(va);
if (va_pool->callbacks->pf_destroy_device_manager)
va_pool->callbacks->pf_destroy_device_manager(va);
va_pool->callbacks->pf_destroy_device(va->sys);
}
int va_pool_Open(vlc_va_t *va, va_pool_t *va_pool)
int va_pool_Open(vlc_va_t *va, const struct va_pool_cfg *cbs, va_pool_t *va_pool)
{
/* */
if (va_pool->pf_create_device(va)) {
if (cbs->pf_create_device(va)) {
msg_Err(va, "Failed to create device");
goto error;
}
msg_Dbg(va, "CreateDevice succeed");
if (va_pool->pf_create_device_manager &&
va_pool->pf_create_device_manager(va) != VLC_SUCCESS) {
if (cbs->pf_create_device_manager &&
cbs->pf_create_device_manager(va) != VLC_SUCCESS) {
msg_Err(va, "CreateDeviceManager failed");
goto error;
}
if (va_pool->pf_create_video_service(va)) {
if (cbs->pf_create_video_service(va)) {
msg_Err(va, "CreateVideoService failed");
goto error;
}
va_pool->callbacks = cbs;
return VLC_SUCCESS;
error:
......
......@@ -43,6 +43,11 @@ typedef struct
struct va_pic_context *surface[MAX_SURFACE_COUNT];
const struct va_pool_cfg *callbacks;
} va_pool_t;
struct va_pool_cfg {
int (*pf_create_device)(vlc_va_t *);
void (*pf_destroy_device)(vlc_va_sys_t *);
......@@ -71,10 +76,9 @@ typedef struct
* Create a new context for the surface being acquired
*/
struct va_pic_context* (*pf_new_surface_context)(vlc_va_t *, int surface_index);
};
} va_pool_t;
int va_pool_Open(vlc_va_t *, va_pool_t *);
int va_pool_Open(vlc_va_t *, const struct va_pool_cfg *, va_pool_t *);
void va_pool_Close(vlc_va_t *va, va_pool_t *);
int va_pool_SetupDecoder(vlc_va_t *, va_pool_t *, const AVCodecContext *, unsigned count, int alignment);
int va_pool_SetupSurfaces(vlc_va_t *, va_pool_t *, unsigned count);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment