Browse Source

decoder: move device close callback

This moves the decoder device close callback to a dedicated
type-specific structure, to avoid type-unsafe variable-arguments
vlc_module_unload().
pull/94/head
Rémi Denis-Courmont 7 years ago
parent
commit
d1498ca548
  1. 9
      include/vlc_codec.h
  2. 7
      modules/hw/vaapi/decoder_device.c
  3. 5
      modules/video_output/opengl/converter_vdpau.c
  4. 11
      src/input/decoder_helpers.c

9
include/vlc_codec.h

@ -494,6 +494,11 @@ enum vlc_decoder_device_type
VLC_DECODER_DEVICE_MMAL,
};
struct vlc_decoder_device_operations
{
void (*close)(struct vlc_decoder_device *);
};
/**
* Decoder context struct
*/
@ -501,6 +506,8 @@ typedef struct vlc_decoder_device
{
struct vlc_object_t obj;
const struct vlc_decoder_device_operations *ops;
/** Private context that could be used by the "decoder device" module
* implementation */
void *sys;
@ -531,8 +538,6 @@ typedef struct vlc_decoder_device
**/
typedef int (*vlc_decoder_device_Open)(vlc_decoder_device *device,
vout_window_t *window);
/** "decoder device" module close entry point */
typedef void (*vlc_decoder_device_Close)(vlc_decoder_device *device);
/**
* Create a decoder device from a window

7
modules/hw/vaapi/decoder_device.c

@ -216,6 +216,10 @@ Close(vlc_decoder_device *device)
vaapi_DestroyInstance(device->sys);
}
static const struct vlc_decoder_device_operations ops = {
.close = Close,
};
static int
Open(vlc_decoder_device *device, vout_window_t *window)
{
@ -237,6 +241,7 @@ Open(vlc_decoder_device *device, vout_window_t *window)
return VLC_EGENERIC;
assert(vadpy != NULL);
device->ops = &ops;
device->sys = vainst;
device->type = VLC_DECODER_DEVICE_VAAPI;
device->opaque = vadpy;
@ -260,7 +265,7 @@ Open(vlc_decoder_device *device, vout_window_t *window)
vlc_module_begin ()
set_description("VA-API decoder device for " DESCRIPTION_SUFFIX)
set_capability("decoder device", PRIORITY)
set_callbacks(Open, Close)
set_callbacks(Open, NULL)
set_category(CAT_VIDEO)
set_subcategory(SUBCAT_VIDEO_VOUT)
add_shortcut("vaapi", SHORTCUT)

5
modules/video_output/opengl/converter_vdpau.c

@ -184,6 +184,10 @@ DecoderContextClose(vlc_decoder_device *device)
vdp_release_x11(device->opaque);
}
static const struct vlc_decoder_device_operations dev_ops = {
.close = DecoderContextClose,
};
static int
DecoderContextOpen(vlc_decoder_device *device, vout_window_t *window)
{
@ -196,6 +200,7 @@ DecoderContextOpen(vlc_decoder_device *device, vout_window_t *window)
if (vdp_get_x11(window->display.x11, -1, &vdp, &vdpdevice) != VDP_STATUS_OK)
return VLC_EGENERIC;
device->ops = &dev_ops;
device->type = VLC_DECODER_DEVICE_VDPAU;
device->opaque = vdp;
return VLC_SUCCESS;

11
src/input/decoder_helpers.c

@ -120,13 +120,6 @@ static int decoder_device_Open(void *func, bool forced, va_list ap)
return ret;
}
static void decoder_device_Close(void *func, va_list ap)
{
vlc_decoder_device_Close close = func;
vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
close(device);
}
vlc_decoder_device *
vlc_decoder_device_Create(vout_window_t *window)
{
@ -145,6 +138,7 @@ vlc_decoder_device_Create(vout_window_t *window)
vlc_object_delete(&priv->device);
return NULL;
}
assert(priv->device.ops != NULL);
vlc_atomic_rc_init(&priv->rc);
return &priv->device;
}
@ -165,7 +159,8 @@ vlc_decoder_device_Release(vlc_decoder_device *device)
container_of(device, struct vlc_decoder_device_priv, device);
if (vlc_atomic_rc_dec(&priv->rc))
{
vlc_module_unload(priv->module, decoder_device_Close, device);
if (device->ops->close != NULL)
device->ops->close(device);
vlc_objres_clear(VLC_OBJECT(device));
vlc_object_delete(device);
}

Loading…
Cancel
Save