Commit 776b8264 authored by Laurent Aimar's avatar Laurent Aimar

Cleaned up a bit spu_t API.

parent a01d5d94
...@@ -46,7 +46,7 @@ extern "C" { ...@@ -46,7 +46,7 @@ extern "C" {
typedef struct spu_private_t spu_private_t; typedef struct spu_private_t spu_private_t;
/* Default subpicture channel ID */ /* Default subpicture channel ID */
#define DEFAULT_CHAN 1 #define SPU_DEFAULT_CHANNEL (1)
/** /**
* Subpicture unit descriptor * Subpicture unit descriptor
...@@ -55,36 +55,9 @@ struct spu_t ...@@ -55,36 +55,9 @@ struct spu_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
int (*pf_control)( spu_t *, int, va_list );
spu_private_t *p; spu_private_t *p;
}; };
enum spu_query_e
{
SPU_CHANNEL_REGISTER, /* arg1= int * res= */
SPU_CHANNEL_CLEAR /* arg1= int res= */
};
static inline int spu_vaControl( spu_t *p_spu, int i_query, va_list args )
{
if( p_spu->pf_control )
return p_spu->pf_control( p_spu, i_query, args );
else
return VLC_EGENERIC;
}
static inline int spu_Control( spu_t *p_spu, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = spu_vaControl( p_spu, i_query, args );
va_end( args );
return i_result;
}
VLC_EXPORT( spu_t *, spu_Create, ( vlc_object_t * ) ); VLC_EXPORT( spu_t *, spu_Create, ( vlc_object_t * ) );
#define spu_Create(a) spu_Create(VLC_OBJECT(a)) #define spu_Create(a) spu_Create(VLC_OBJECT(a))
VLC_EXPORT( int, spu_Init, ( spu_t * ) ); VLC_EXPORT( int, spu_Init, ( spu_t * ) );
...@@ -114,6 +87,16 @@ VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_subti ...@@ -114,6 +87,16 @@ VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_subti
*/ */
VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, picture_t *, const video_format_t *p_fmt_dst, subpicture_t *p_list, const video_format_t *p_fmt_src, mtime_t render_subtitle_date ) ); VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, picture_t *, const video_format_t *p_fmt_dst, subpicture_t *p_list, const video_format_t *p_fmt_src, mtime_t render_subtitle_date ) );
/**
* It registers a new SPU channel.
*/
VLC_EXPORT( int, spu_RegisterChannel, ( spu_t * ) );
/**
* It clears all subpictures associated to a SPU channel.
*/
VLC_EXPORT( void, spu_ClearChannel, ( spu_t *, int ) );
/** @}*/ /** @}*/
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -683,7 +683,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd, ...@@ -683,7 +683,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd,
if ( !vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x00 ) || vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x99 ) ) if ( !vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x00 ) || vbi_bcd_digits_greater( p_sys->i_wanted_subpage, 0x99 ) )
p_sys->i_wanted_subpage = VBI_ANY_SUBNO; p_sys->i_wanted_subpage = VBI_ANY_SUBNO;
else else
vout_OSDMessage( p_this, DEFAULT_CHAN, "%s: %d", _("Subpage"), vbi_bcd2dec( p_sys->i_wanted_subpage) ); vout_OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %d", _("Subpage"), vbi_bcd2dec( p_sys->i_wanted_subpage) );
p_sys->b_update = true; p_sys->b_update = true;
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
...@@ -697,7 +697,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd, ...@@ -697,7 +697,7 @@ static int EventKey( vlc_object_t *p_this, char const *psz_cmd,
p_sys->i_key[0] = p_sys->i_key[1]; p_sys->i_key[0] = p_sys->i_key[1];
p_sys->i_key[1] = p_sys->i_key[2]; p_sys->i_key[1] = p_sys->i_key[2];
p_sys->i_key[2] = (int)(newval.i_int - '0'); p_sys->i_key[2] = (int)(newval.i_int - '0');
vout_OSDMessage( p_this, DEFAULT_CHAN, "%s: %c%c%c", _("Page"), (char)(p_sys->i_key[0]+'0'), (char)(p_sys->i_key[1]+'0'), (char)(p_sys->i_key[2]+'0') ); vout_OSDMessage( p_this, SPU_DEFAULT_CHANNEL, "%s: %c%c%c", _("Page"), (char)(p_sys->i_key[0]+'0'), (char)(p_sys->i_key[1]+'0'), (char)(p_sys->i_key[2]+'0') );
int i_new_page = 0; int i_new_page = 0;
......
This diff is collapsed.
...@@ -211,12 +211,12 @@ ...@@ -211,12 +211,12 @@
var_Set( p_playlist, "random", val ); var_Set( p_playlist, "random", val );
if( val.b_bool ) if( val.b_bool )
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Random On" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random On" ) );
config_PutInt( p_playlist, "random", 1 ); config_PutInt( p_playlist, "random", 1 );
} }
else else
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Random Off" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
config_PutInt( p_playlist, "random", 0 ); config_PutInt( p_playlist, "random", 0 );
} }
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
config_PutInt( p_playlist, "loop", 0 ); config_PutInt( p_playlist, "loop", 0 );
/* show the change */ /* show the change */
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat One" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
} }
else if( repeating.b_bool && !looping.b_bool ) else if( repeating.b_bool && !looping.b_bool )
{ {
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
config_PutInt( p_playlist, "loop", 1 ); config_PutInt( p_playlist, "loop", 1 );
/* show the change */ /* show the change */
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat All" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
} }
else else
{ {
...@@ -310,7 +310,7 @@ ...@@ -310,7 +310,7 @@
config_PutInt( p_playlist, "loop", 0 ); config_PutInt( p_playlist, "loop", 0 );
/* show the change */ /* show the change */
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat Off" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
} }
/* communicate with core and the main intf loop */ /* communicate with core and the main intf loop */
...@@ -336,12 +336,12 @@ ...@@ -336,12 +336,12 @@
var_Set( p_playlist, "repeat", val ); var_Set( p_playlist, "repeat", val );
if( val.b_bool ) if( val.b_bool )
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat One" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
config_PutInt( p_playlist, "repeat", 1 ); config_PutInt( p_playlist, "repeat", 1 );
} }
else else
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat Off" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
config_PutInt( p_playlist, "repeat", 0 ); config_PutInt( p_playlist, "repeat", 0 );
} }
...@@ -364,12 +364,12 @@ ...@@ -364,12 +364,12 @@
var_Set( p_playlist, "loop", val ); var_Set( p_playlist, "loop", val );
if( val.b_bool ) if( val.b_bool )
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat All" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
config_PutInt( p_playlist, "loop", 1 ); config_PutInt( p_playlist, "loop", 1 );
} }
else else
{ {
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat Off" ) ); vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
config_PutInt( p_playlist, "loop", 0 ); config_PutInt( p_playlist, "loop", 0 );
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
void CmdQuit::execute() void CmdQuit::execute()
{ {
// Stop the playlist // Stop the playlist
vout_OSDMessage( getIntf(), DEFAULT_CHAN, "%s", _( "Quit" ) ); vout_OSDMessage( getIntf(), SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) );
// Kill libvlc // Kill libvlc
libvlc_Quit( getIntf()->p_libvlc ); libvlc_Quit( getIntf()->p_libvlc );
......
...@@ -69,7 +69,7 @@ static int vlclua_osd_icon( lua_State *L ) ...@@ -69,7 +69,7 @@ static int vlclua_osd_icon( lua_State *L )
{ {
const char *psz_icon = luaL_checkstring( L, 1 ); const char *psz_icon = luaL_checkstring( L, 1 );
int i_icon = vlc_osd_icon_from_string( psz_icon ); int i_icon = vlc_osd_icon_from_string( psz_icon );
int i_chan = luaL_optint( L, 2, DEFAULT_CHAN ); int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
if( !i_icon ) if( !i_icon )
return luaL_error( L, "\"%s\" is not a valid osd icon.", psz_icon ); return luaL_error( L, "\"%s\" is not a valid osd icon.", psz_icon );
else else
...@@ -83,7 +83,7 @@ static int vlclua_osd_icon( lua_State *L ) ...@@ -83,7 +83,7 @@ static int vlclua_osd_icon( lua_State *L )
static int vlclua_osd_message( lua_State *L ) static int vlclua_osd_message( lua_State *L )
{ {
const char *psz_message = luaL_checkstring( L, 1 ); const char *psz_message = luaL_checkstring( L, 1 );
int i_chan = luaL_optint( L, 2, DEFAULT_CHAN ); int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
vlc_object_t *p_this = vlclua_get_this( L ); vlc_object_t *p_this = vlclua_get_this( L );
vout_OSDMessage( p_this, i_chan, "%s", psz_message ); vout_OSDMessage( p_this, i_chan, "%s", psz_message );
return 0; return 0;
...@@ -113,7 +113,7 @@ static int vlclua_osd_slider( lua_State *L ) ...@@ -113,7 +113,7 @@ static int vlclua_osd_slider( lua_State *L )
int i_position = luaL_checkint( L, 1 ); int i_position = luaL_checkint( L, 1 );
const char *psz_type = luaL_checkstring( L, 2 ); const char *psz_type = luaL_checkstring( L, 2 );
int i_type = vlc_osd_slider_type_from_string( psz_type ); int i_type = vlc_osd_slider_type_from_string( psz_type );
int i_chan = luaL_optint( L, 3, DEFAULT_CHAN ); int i_chan = luaL_optint( L, 3, SPU_DEFAULT_CHANNEL );
if( !i_type ) if( !i_type )
return luaL_error( L, "\"%s\" is not a valid slider type.", return luaL_error( L, "\"%s\" is not a valid slider type.",
psz_type ); psz_type );
...@@ -134,7 +134,7 @@ static int vlclua_spu_channel_register( lua_State *L ) ...@@ -134,7 +134,7 @@ static int vlclua_spu_channel_register( lua_State *L )
if( !p_vout ) if( !p_vout )
return luaL_error( L, "Unable to find vout." ); return luaL_error( L, "Unable to find vout." );
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_REGISTER, &i_chan ); i_chan = spu_RegisterChannel( vout_GetSpu( p_vout ) );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
lua_pushinteger( L, i_chan ); lua_pushinteger( L, i_chan );
return 1; return 1;
...@@ -149,7 +149,7 @@ static int vlclua_spu_channel_clear( lua_State *L ) ...@@ -149,7 +149,7 @@ static int vlclua_spu_channel_clear( lua_State *L )
if( !p_vout ) if( !p_vout )
return luaL_error( L, "Unable to find vout." ); return luaL_error( L, "Unable to find vout." );
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_CLEAR, i_chan ); spu_ClearChannel( vout_GetSpu( p_vout ), i_chan );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
return 0; return 0;
} }
......
...@@ -1935,8 +1935,8 @@ static void DecoderProcessSpu( decoder_t *p_dec, block_t *p_block, bool b_flush ...@@ -1935,8 +1935,8 @@ static void DecoderProcessSpu( decoder_t *p_dec, block_t *p_block, bool b_flush
p_vout = input_resource_HoldVout( p_input->p->p_resource ); p_vout = input_resource_HoldVout( p_input->p->p_resource );
if( p_vout && p_owner->p_spu_vout == p_vout ) if( p_vout && p_owner->p_spu_vout == p_vout )
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_CLEAR, spu_ClearChannel( vout_GetSpu( p_vout ),
p_owner->i_spu_channel ); p_owner->i_spu_channel );
if( p_vout ) if( p_vout )
vlc_object_release( p_vout ); vlc_object_release( p_vout );
...@@ -2098,7 +2098,7 @@ static void DeleteDecoder( decoder_t * p_dec ) ...@@ -2098,7 +2098,7 @@ static void DeleteDecoder( decoder_t * p_dec )
if( p_vout ) if( p_vout )
{ {
if( p_owner->p_spu_vout == p_vout ) if( p_owner->p_spu_vout == p_vout )
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_CLEAR, p_owner->i_spu_channel ); spu_ClearChannel( vout_GetSpu( p_vout ), p_owner->i_spu_channel );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
} }
...@@ -2427,8 +2427,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec, ...@@ -2427,8 +2427,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_REGISTER, p_owner->i_spu_channel = spu_RegisterChannel( vout_GetSpu( p_vout ) );
&p_owner->i_spu_channel );
p_owner->i_spu_order = 0; p_owner->i_spu_order = 0;
p_owner->p_spu_vout = p_vout; p_owner->p_spu_vout = p_vout;
} }
......
...@@ -273,7 +273,7 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource, ...@@ -273,7 +273,7 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
{ {
msg_Dbg( p_resource->p_input, "saving a free vout" ); msg_Dbg( p_resource->p_input, "saving a free vout" );
vout_Flush( p_vout, 1 ); vout_Flush( p_vout, 1 );
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_CLEAR, -1 ); spu_ClearChannel( vout_GetSpu( p_vout ), -1 );
p_resource->p_vout_free = p_vout; p_resource->p_vout_free = p_vout;
} }
......
...@@ -390,6 +390,8 @@ spu_DisplaySubpicture ...@@ -390,6 +390,8 @@ spu_DisplaySubpicture
spu_Init spu_Init
spu_RenderSubpictures spu_RenderSubpictures
spu_SortSubpictures spu_SortSubpictures
spu_RegisterChannel
spu_ClearChannel
sql_Create sql_Create
sql_Destroy sql_Destroy
stats_TimerClean stats_TimerClean
......
...@@ -269,7 +269,7 @@ int vout_OSDEpg( vout_thread_t *p_vout, input_item_t *p_input ) ...@@ -269,7 +269,7 @@ int vout_OSDEpg( vout_thread_t *p_vout, input_item_t *p_input )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_spu->i_channel = DEFAULT_CHAN; p_spu->i_channel = SPU_DEFAULT_CHANNEL;
p_spu->i_start = i_now; p_spu->i_start = i_now;
p_spu->i_stop = i_now + 3000 * INT64_C(1000); p_spu->i_stop = i_now + 3000 * INT64_C(1000);
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
......
...@@ -873,7 +873,7 @@ static void ThreadDisplayOsdTitle(vout_thread_t *vout, const char *string) ...@@ -873,7 +873,7 @@ static void ThreadDisplayOsdTitle(vout_thread_t *vout, const char *string)
INT64_C(1000) * vout->p->title.timeout; INT64_C(1000) * vout->p->title.timeout;
if (stop > start) if (stop > start)
vout_ShowTextAbsolute(vout, DEFAULT_CHAN, vout_ShowTextAbsolute(vout, SPU_DEFAULT_CHANNEL,
string, NULL, string, NULL,
vout->p->title.position, vout->p->title.position,
30 + vout->p->fmt_in.i_width 30 + vout->p->fmt_in.i_width
......
...@@ -373,7 +373,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -373,7 +373,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic )
if( !p_subpic ) if( !p_subpic )
return VLC_EGENERIC; return VLC_EGENERIC;
/* FIXME DEFAULT_CHAN is not good (used by the text) but /* FIXME SPU_DEFAULT_CHANNEL is not good (used by the text) but
* hardcoded 0 doesn't seem right */ * hardcoded 0 doesn't seem right */
p_subpic->i_channel = 0; p_subpic->i_channel = 0;
p_subpic->i_start = mdate(); p_subpic->i_start = mdate();
...@@ -395,7 +395,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -395,7 +395,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic )
static void VoutOsdSnapshot( vout_thread_t *p_vout, picture_t *p_pic, const char *psz_filename ) static void VoutOsdSnapshot( vout_thread_t *p_vout, picture_t *p_pic, const char *psz_filename )
{ {
msg_Dbg( p_vout, "snapshot taken (%s)", psz_filename ); msg_Dbg( p_vout, "snapshot taken (%s)", psz_filename );
vout_OSDMessage( VLC_OBJECT( p_vout ), DEFAULT_CHAN, "%s", psz_filename ); vout_OSDMessage( VLC_OBJECT( p_vout ), SPU_DEFAULT_CHANNEL, "%s", psz_filename );
if( var_GetBool( p_vout, "snapshot-preview" ) ) if( var_GetBool( p_vout, "snapshot-preview" ) )
{ {
......
...@@ -164,10 +164,6 @@ static int CropCallback( vlc_object_t *, char const *, ...@@ -164,10 +164,6 @@ static int CropCallback( vlc_object_t *, char const *,
static int MarginCallback( vlc_object_t *, char const *, static int MarginCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int SpuControl( spu_t *, int, va_list );
static void SpuClearChannel( spu_t *p_spu, int i_channel );
/* Buffer allocation for SPU filter (blend, scale, ...) */ /* Buffer allocation for SPU filter (blend, scale, ...) */
static subpicture_t *spu_new_buffer( filter_t * ); static subpicture_t *spu_new_buffer( filter_t * );
static void spu_del_buffer( filter_t *, subpicture_t * ); static void spu_del_buffer( filter_t *, subpicture_t * );
...@@ -208,7 +204,6 @@ spu_t *spu_Create( vlc_object_t *p_this ) ...@@ -208,7 +204,6 @@ spu_t *spu_Create( vlc_object_t *p_this )
vlc_object_attach( p_spu, p_this ); vlc_object_attach( p_spu, p_this );
/* Initialize spu fields */ /* Initialize spu fields */
p_spu->pf_control = SpuControl;
p_spu->p = p_sys = (spu_private_t*)&p_spu[1]; p_spu->p = p_sys = (spu_private_t*)&p_spu[1];
/* Initialize private fields */ /* Initialize private fields */
...@@ -357,9 +352,9 @@ void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic ) ...@@ -357,9 +352,9 @@ void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
{ {
spu_private_t *p_sys = p_spu->p; spu_private_t *p_sys = p_spu->p;
/* DEFAULT_CHAN always reset itself */ /* SPU_DEFAULT_CHANNEL always reset itself */
if( p_subpic->i_channel == DEFAULT_CHAN ) if( p_subpic->i_channel == SPU_DEFAULT_CHANNEL )
SpuClearChannel( p_spu, DEFAULT_CHAN ); spu_ClearChannel( p_spu, SPU_DEFAULT_CHANNEL );
/* p_private is for spu only and cannot be non NULL here */ /* p_private is for spu only and cannot be non NULL here */
for( subpicture_region_t *r = p_subpic->p_region; r != NULL; r = r->p_next ) for( subpicture_region_t *r = p_subpic->p_region; r != NULL; r = r->p_next )
...@@ -715,6 +710,40 @@ void spu_OffsetSubtitleDate( spu_t *p_spu, mtime_t i_duration ) ...@@ -715,6 +710,40 @@ void spu_OffsetSubtitleDate( spu_t *p_spu, mtime_t i_duration )
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
} }
int spu_RegisterChannel( spu_t *p_spu )
{
spu_private_t *p_sys = p_spu->p;
vlc_mutex_lock( &p_sys->lock );
int i_channel = p_sys->i_channel++;
vlc_mutex_unlock( &p_sys->lock );
return i_channel;
}
void spu_ClearChannel( spu_t *p_spu, int i_channel )
{
spu_private_t *p_sys = p_spu->p;
vlc_mutex_lock( &p_sys->lock );
for( int i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
spu_heap_entry_t *p_entry = &p_sys->heap.p_entry[i_subpic];
subpicture_t *p_subpic = p_entry->p_subpicture;
if( !p_subpic )
continue;
if( p_subpic->i_channel != i_channel && ( i_channel != -1 || p_subpic->i_channel == SPU_DEFAULT_CHANNEL ) )
continue;
/* You cannot delete subpicture outside of spu_SortSubpictures */
p_entry->b_reject = true;
}
vlc_mutex_unlock( &p_sys->lock );
}
/***************************************************************************** /*****************************************************************************
* subpicture_t allocation * subpicture_t allocation
*****************************************************************************/ *****************************************************************************/
...@@ -1759,67 +1788,6 @@ static int SubpictureCmp( const void *s0, const void *s1 ) ...@@ -1759,67 +1788,6 @@ static int SubpictureCmp( const void *s0, const void *s1 )
return r; return r;
} }
/*****************************************************************************
* SpuClearChannel: clear an spu channel
*****************************************************************************
* This function destroys the subpictures which belong to the spu channel
* corresponding to i_channel_id.
*****************************************************************************/
static void SpuClearChannel( spu_t *p_spu, int i_channel )
{
spu_private_t *p_sys = p_spu->p;
int i_subpic; /* subpicture index */
vlc_mutex_lock( &p_sys->lock );
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
spu_heap_entry_t *p_entry = &p_sys->heap.p_entry[i_subpic];
subpicture_t *p_subpic = p_entry->p_subpicture;
if( !p_subpic )
continue;
if( p_subpic->i_channel != i_channel && ( i_channel != -1 || p_subpic->i_channel == DEFAULT_CHAN ) )
continue;
/* You cannot delete subpicture outside of spu_SortSubpictures */
p_entry->b_reject = true;
}
vlc_mutex_unlock( &p_sys->lock );
}
/*****************************************************************************
* spu_ControlDefault: default methods for the subpicture unit control.
*****************************************************************************/
static int SpuControl( spu_t *p_spu, int i_query, va_list args )
{
spu_private_t *p_sys = p_spu->p;
int *pi, i;
switch( i_query )
{
case SPU_CHANNEL_REGISTER:
pi = (int *)va_arg( args, int * );
vlc_mutex_lock( &p_sys->lock );
if( pi )
*pi = p_sys->i_channel++;
vlc_mutex_unlock( &p_sys->lock );
break;
case SPU_CHANNEL_CLEAR:
i = (int)va_arg( args, int );
SpuClearChannel( p_spu, i );
break;
default:
msg_Dbg( p_spu, "control query not supported" );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* Object variables callbacks * Object variables callbacks
*****************************************************************************/ *****************************************************************************/
...@@ -1955,7 +1923,7 @@ static int SubFilterAllocationInit( filter_t *p_filter, void *p_data ) ...@@ -1955,7 +1923,7 @@ static int SubFilterAllocationInit( filter_t *p_filter, void *p_data )
p_filter->pf_sub_buffer_del = sub_del_buffer; p_filter->pf_sub_buffer_del = sub_del_buffer;
p_filter->p_owner = p_sys; p_filter->p_owner = p_sys;
spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel ); p_sys->i_channel = spu_RegisterChannel( p_spu );
p_sys->p_spu = p_spu; p_sys->p_spu = p_spu;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -1965,7 +1933,7 @@ static void SubFilterAllocationClean( filter_t *p_filter ) ...@@ -1965,7 +1933,7 @@ static void SubFilterAllocationClean( filter_t *p_filter )
{ {
filter_owner_sys_t *p_sys = p_filter->p_owner; filter_owner_sys_t *p_sys = p_filter->p_owner;
SpuClearChannel( p_sys->p_spu, p_sys->i_channel ); spu_ClearChannel( p_sys->p_spu, p_sys->i_channel );
free( p_filter->p_owner ); free( p_filter->p_owner );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment