summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau/mixer.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-03-01 23:03:09 +0100
committerChristian König <[email protected]>2012-03-05 16:51:32 +0100
commit05579339c0da442669ea75749651e8cf4f9ec39b (patch)
tree037f8eefbd874395d2dcb2b4c7b79a4498f1285f /src/gallium/state_trackers/vdpau/mixer.c
parent1d0c357a9733238985cbe029b174173ef927ac70 (diff)
st/vdpau: make the interface thread save
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/vdpau/mixer.c')
-rw-r--r--src/gallium/state_trackers/vdpau/mixer.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index cad577d16b0..e3c9349bfc4 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -62,6 +62,9 @@ vlVdpVideoMixerCreate(VdpDevice device,
return VDP_STATUS_RESOURCES;
vmixer->device = dev;
+
+ pipe_mutex_lock(dev->mutex);
+
vl_compositor_init_state(&vmixer->cstate, dev->context);
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &vmixer->csc);
@@ -143,6 +146,7 @@ vlVdpVideoMixerCreate(VdpDevice device,
}
vmixer->luma_key_min = 0.f;
vmixer->luma_key_max = 1.f;
+ pipe_mutex_unlock(dev->mutex);
return VDP_STATUS_OK;
@@ -151,6 +155,7 @@ no_params:
no_handle:
vl_compositor_cleanup_state(&vmixer->cstate);
+ pipe_mutex_unlock(dev->mutex);
FREE(vmixer);
return ret;
}
@@ -167,6 +172,8 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(vmixer->device->mutex);
+
vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
vlRemoveDataHTAB(mixer);
@@ -182,6 +189,7 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
vl_matrix_filter_cleanup(vmixer->sharpness.filter);
FREE(vmixer->sharpness.filter);
}
+ pipe_mutex_unlock(vmixer->device->mutex);
FREE(vmixer);
@@ -221,8 +229,6 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
- vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
-
compositor = &vmixer->device->compositor;
surf = vlGetDataHTAB(video_surface_current);
@@ -244,10 +250,14 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
if (!dst)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(vmixer->device->mutex);
+ vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
if (background_surface != VDP_INVALID_HANDLE) {
vlVdpOutputSurface *bg = vlGetDataHTAB(background_surface);
- if (!bg)
+ if (!bg) {
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_HANDLE;
+ }
vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer++, bg->sampler_view,
RectToPipe(background_source_rect, &rect), NULL, NULL);
}
@@ -268,6 +278,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
break;
default:
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
};
vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, surf->video_buffer,
@@ -276,8 +287,10 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
for (i = 0; i < layer_count; ++i) {
vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface);
- if (!src)
+ if (!src) {
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_HANDLE;
+ }
assert(layers->struct_version == VDP_LAYER_VERSION);
@@ -305,6 +318,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
vl_matrix_filter_render(vmixer->sharpness.filter,
dst->sampler_view, dst->surface);
}
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_OK;
}
@@ -452,6 +466,7 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(vmixer->device->mutex);
for (i = 0; i < feature_count; ++i) {
switch (features[i]) {
/* they are valid, but we doesn't support them */
@@ -481,9 +496,11 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
break;
default:
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
}
}
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_OK;
}
@@ -563,6 +580,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(vmixer->device->mutex);
for (i = 0; i < attribute_count; ++i) {
switch (attributes[i]) {
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
@@ -623,9 +641,11 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
vmixer->skip_chroma_deint = *(uint8_t*)attribute_values[i];
break;
default:
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
}
}
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_OK;
}
@@ -688,6 +708,7 @@ vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(vmixer->device->mutex);
for (i = 0; i < attribute_count; ++i) {
switch (attributes[i]) {
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
@@ -719,9 +740,11 @@ vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
*(uint8_t*)attribute_values[i] = vmixer->skip_chroma_deint;
break;
default:
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
}
}
+ pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_OK;
}