[vlc-devel] [PATCH 4/4] decoder: get the new i_spu_channel earlier under lock
Steve Lhomme
robux4 at ycbcr.xyz
Tue Sep 3 11:59:34 CEST 2019
This way the p_vout in p_owner is always coherent with i_spu_channel outside
of the lock.
---
src/input/decoder.c | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 1a1778e662..72ea6b8941 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -610,8 +610,24 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
vlc_mutex_lock( &p_owner->lock );
ssize_t i_deleted_spu_channel = p_owner->i_spu_channel;
vout_thread_t *p_old_vout = p_owner->p_vout;
+ enum vlc_vout_order channel_order;
- p_owner->i_spu_channel = VOUT_SPU_CHANNEL_INVALID;
+ if (p_vout == NULL)
+ p_owner->i_spu_channel = VOUT_SPU_CHANNEL_INVALID;
+ else if ( p_old_vout != p_vout )
+ {
+ p_owner->i_spu_channel =
+ vout_RegisterSubpictureChannelInternal(p_vout, p_owner->p_clock,
+ &channel_order);
+ p_owner->i_spu_order = 0;
+
+ if (p_owner->i_spu_channel == VOUT_SPU_CHANNEL_INVALID)
+ {
+ /* The new vout doesn't support SPU, aborting... */
+ vout_Release(p_vout);
+ p_vout = NULL;
+ }
+ }
p_owner->p_vout = p_vout;
vlc_mutex_unlock( &p_owner->lock );
@@ -634,25 +650,6 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
if( p_old_vout != p_vout )
{
- vlc_mutex_lock(&p_owner->lock);
-
- enum vlc_vout_order channel_order;
- p_owner->i_spu_channel =
- vout_RegisterSubpictureChannelInternal(p_vout, p_owner->p_clock,
- &channel_order);
- p_owner->i_spu_order = 0;
-
- if (p_owner->i_spu_channel == VOUT_SPU_CHANNEL_INVALID)
- {
- /* The new vout doesn't support SPU, aborting... */
- p_owner->p_vout = NULL;
- vlc_mutex_unlock(&p_owner->lock);
- vout_Release(p_vout);
- return NULL;
- }
-
- vlc_mutex_unlock(&p_owner->lock);
-
assert(channel_order != VLC_VOUT_ORDER_NONE);
decoder_Notify(p_owner, on_vout_added, p_vout, channel_order);
}
--
2.17.1
More information about the vlc-devel
mailing list