+/*****************************************************************************
+ * vout_RegisterOSDChannel: register an OSD channel
+ *****************************************************************************
+ * This function affects an ID to an OSD channel
+ *****************************************************************************/
+int vout_RegisterOSDChannel( vout_thread_t *p_vout )
+{
+ msg_Dbg( p_vout, "Registering OSD channel, ID: %i", p_vout->i_channel_count + 1 );
+ return ++p_vout->i_channel_count;
+}
+
+/*****************************************************************************
+ * vout_ClearOSDChannel: clear an OSD channel
+ *****************************************************************************
+ * This function destroys the subpictures which belong to the OSD channel
+ * corresponding to i_channel_id.
+ *****************************************************************************/
+void vout_ClearOSDChannel( vout_thread_t *p_vout, int i_channel )
+{
+ int i_subpic; /* subpicture index */
+ subpicture_t * p_subpic = NULL; /* first free subpicture */
+
+ if( i_channel == DEFAULT_CHAN )
+ {
+ if( p_vout->p_default_channel != NULL )
+ {
+ vout_DestroySubPicture( p_vout, p_vout->p_default_channel );
+ }
+ p_vout->p_default_channel = NULL;
+ return;
+ }
+
+ vlc_mutex_lock( &p_vout->subpicture_lock );
+
+ for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
+ {
+ p_subpic = &p_vout->p_subpicture[i_subpic];
+ if( p_subpic->i_status == FREE_SUBPICTURE
+ || ( p_subpic->i_status != RESERVED_SUBPICTURE
+ && p_subpic->i_status != READY_SUBPICTURE ) )
+ {
+ continue;
+ }
+ if( p_subpic->i_channel == i_channel )
+ {
+ if( p_subpic->pf_destroy )
+ {
+ p_subpic->pf_destroy( p_subpic );
+ }
+ p_subpic->i_status = FREE_SUBPICTURE;
+ }
+ }
+
+ vlc_mutex_unlock( &p_vout->subpicture_lock );
+}