[vlc-devel] [PATCH 2/3] sout: add an interrupt context
Thomas Guillem
thomas at gllm.fr
Mon Feb 12 18:13:25 CET 2018
In order to interrupt a sout_InputSendBuffer() call.
---
src/stream_output/stream_output.c | 15 +++++++++++++++
src/stream_output/stream_output.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 94f6c56cfe..de261f7187 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -163,6 +163,12 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
return NULL;
p_input->p_sout = p_sout;
+ p_input->interrupt_ctx = vlc_interrupt_create();
+ if( !p_input->interrupt_ctx )
+ {
+ free( p_input->interrupt_ctx );
+ return NULL;
+ }
msg_Dbg( p_sout, "adding a new sout input for `%4.4s` (sout_input: %p)",
(char*) &p_fmt->i_codec, (void *)p_input );
@@ -197,6 +203,8 @@ int sout_InputDelete( sout_packetizer_input_t *p_input )
sout_StreamIdDel( p_sout->p_stream, p_input->id );
vlc_mutex_unlock( &p_sout->lock );
+ vlc_interrupt_destroy( p_input->interrupt_ctx );
+
free( p_input );
return( VLC_SUCCESS);
@@ -233,12 +241,19 @@ int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
int i_ret;
vlc_mutex_lock( &p_sout->lock );
+ vlc_interrupt_set( p_input->interrupt_ctx );
i_ret = sout_StreamIdSend( p_sout->p_stream, p_input->id, p_buffer );
+ vlc_interrupt_set( NULL );
vlc_mutex_unlock( &p_sout->lock );
return i_ret;
}
+void sout_InputInterrupt( sout_packetizer_input_t *p_input )
+{
+ vlc_interrupt_kill( p_input->interrupt_ctx );
+}
+
#undef sout_AccessOutNew
/*****************************************************************************
* sout_AccessOutNew: allocate a new access out
diff --git a/src/stream_output/stream_output.h b/src/stream_output/stream_output.h
index c7ff95269d..c18509f4c1 100644
--- a/src/stream_output/stream_output.h
+++ b/src/stream_output/stream_output.h
@@ -29,6 +29,7 @@
# include <vlc_sout.h>
# include <vlc_network.h>
+# include <vlc_interrupt.h>
/****************************************************************************
* sout_packetizer_input_t: p_sout <-> p_packetizer
@@ -38,6 +39,7 @@ struct sout_packetizer_input_t
sout_instance_t *p_sout;
sout_stream_id_sys_t *id;
+ vlc_interrupt_t *interrupt_ctx;
};
sout_instance_t *sout_NewInstance( vlc_object_t *, const char * );
@@ -47,6 +49,7 @@ void sout_DeleteInstance( sout_instance_t * );
sout_packetizer_input_t *sout_InputNew( sout_instance_t *, const es_format_t * );
int sout_InputDelete( sout_packetizer_input_t * );
int sout_InputSendBuffer( sout_packetizer_input_t *, block_t* );
+void sout_InputInterrupt( sout_packetizer_input_t * );
bool sout_InputIsEmpty(sout_packetizer_input_t *);
void sout_InputFlush( sout_packetizer_input_t * );
--
2.11.0
More information about the vlc-devel
mailing list