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" {
typedef struct spu_private_t spu_private_t;
/* Default subpicture channel ID */
#define DEFAULT_CHAN 1
#define SPU_DEFAULT_CHANNEL (1)
/**
* Subpicture unit descriptor
......@@ -55,36 +55,9 @@ struct spu_t
{
VLC_COMMON_MEMBERS
int (*pf_control)( spu_t *, int, va_list );
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 * ) );
#define spu_Create(a) spu_Create(VLC_OBJECT(a))
VLC_EXPORT( int, spu_Init, ( spu_t * ) );
......@@ -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 ) );
/**
* 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
......
......@@ -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 ) )
p_sys->i_wanted_subpage = VBI_ANY_SUBNO;
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;
vlc_mutex_unlock( &p_sys->lock );
......@@ -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[1] = p_sys->i_key[2];
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;
......
......@@ -165,8 +165,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
* Alternatively, we should keep a reference to the vout thread. */
if( p_vout && p_vout != p_sys->p_last_vout )
for( unsigned i = 0; i < CHANNELS_NUMBER; i++ )
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_REGISTER,
&p_intf->p_sys->p_channels[ i ] );
p_intf->p_sys->p_channels[i] = spu_RegisterChannel( vout_GetSpu( p_vout ) );
p_sys->p_last_vout = p_vout;
/* Quit */
......@@ -176,7 +175,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
libvlc_Quit( p_intf->p_libvlc );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Quit" ) );
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) );
break;
/* Volume and audio actions */
......@@ -205,7 +204,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i_newvol == 0 )
{
ClearChannels( p_intf, p_vout );
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
vout_OSDIcon( VLC_OBJECT( p_intf ), SPU_DEFAULT_CHANNEL,
OSD_MUTE_ICON );
}
else
......@@ -299,13 +298,13 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
int state = var_GetInteger( p_input, "state" );
if( state != PAUSE_S )
{
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
vout_OSDIcon( VLC_OBJECT( p_intf ), SPU_DEFAULT_CHANNEL,
OSD_PAUSE_ICON );
state = PAUSE_S;
}
else
{
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
vout_OSDIcon( VLC_OBJECT( p_intf ), SPU_DEFAULT_CHANNEL,
OSD_PLAY_ICON );
state = PLAYING_S;
}
......@@ -322,7 +321,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else
{
ClearChannels( p_intf, p_vout );
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
vout_OSDIcon( VLC_OBJECT( p_intf ), SPU_DEFAULT_CHANNEL,
OSD_PLAY_ICON );
playlist_Play( p_playlist );
}
......@@ -370,7 +369,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
list.p_list->p_values[i+1] );
i++;
}
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_("Audio Device: %s"),
list2.p_list->p_values[i].psz_string);
}
......@@ -392,7 +391,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( var_GetInteger( p_input, "state" ) != PAUSE_S )
{
ClearChannels( p_intf, p_vout );
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
vout_OSDIcon( VLC_OBJECT( p_intf ), SPU_DEFAULT_CHANNEL,
OSD_PAUSE_ICON );
var_SetInteger( p_input, "state", PAUSE_S );
}
......@@ -467,7 +466,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else
i++;
var_Set( p_input, "audio-es", list.p_list->p_values[i] );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Audio track: %s"),
list2.p_list->p_values[i].psz_string );
}
......@@ -484,7 +483,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_count = list.p_list->i_count;
if( i_count <= 1 )
{
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Subtitle track: %s"), _("N/A") );
var_FreeList( &list, &list2 );
goto cleanup_and_continue;
......@@ -508,7 +507,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else
i++;
var_Set( p_input, "spu-es", list.p_list->p_values[i] );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Subtitle track: %s"),
list2.p_list->p_values[i].psz_string );
var_FreeList( &list, &list2 );
......@@ -533,7 +532,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == val_list.p_list->i_count ) i = 0;
var_SetString( p_vout, "aspect-ratio",
val_list.p_list->p_values[i].psz_string );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Aspect ratio: %s"),
text_list.p_list->p_values[i].psz_string );
......@@ -561,7 +560,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == val_list.p_list->i_count ) i = 0;
var_SetString( p_vout, "crop",
val_list.p_list->p_values[i].psz_string );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Crop: %s"),
text_list.p_list->p_values[i].psz_string );
......@@ -575,7 +574,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if ( f_scalefactor != 1.0 )
{
var_SetFloat( p_vout, "scale", 1.0 );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("Zooming reset") );
}
else
......@@ -583,10 +582,10 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
bool b_autoscale = !var_GetBool( p_vout, "autoscale" );
var_SetBool( p_vout, "autoscale", b_autoscale );
if( b_autoscale )
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("Scaled to screen") );
else
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("Original Size") );
}
}
......@@ -614,7 +613,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i_deinterlace != 0 )
{
var_SetInteger( p_vout, "deinterlace", 0 );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("Deinterlace off") );
}
else
......@@ -634,7 +633,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
break;
}
}
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s (%s)", _("Deinterlace on"), psz_text ? psz_text : psz_mode );
var_FreeList( &vlist, &tlist );
......@@ -667,7 +666,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( i == -1 ) i = val_list.p_list->i_count-1;
var_SetFloat( p_vout, "zoom",
val_list.p_list->p_values[i].f_float );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
_("Zoom mode: %s"),
text_list.p_list->p_values[i].psz_string );
......@@ -693,12 +692,12 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else if( i_action == ACTIONID_NEXT )
{
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, "%s", _("Next") );
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL, "%s", _("Next") );
playlist_Next( p_playlist );
}
else if( i_action == ACTIONID_PREV )
{
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, "%s",
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL, "%s",
_("Previous") );
playlist_Prev( p_playlist );
}
......@@ -709,13 +708,13 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
else if( i_action == ACTIONID_FRAME_NEXT )
{
var_TriggerCallback( p_input, "frame-next" );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("Next frame") );
}
else if( i_action == ACTIONID_RATE_NORMAL )
{
var_SetFloat( p_input, "rate", 1. );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL,
"%s", _("1.00x") );
}
else if( i_action == ACTIONID_FASTER )
......@@ -770,7 +769,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_delay -= 50000; /* 50 ms */
var_SetTime( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
}
......@@ -780,7 +779,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_delay += 50000; /* 50 ms */
var_SetTime( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
}
......@@ -790,7 +789,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
--i_pos;
var_SetInteger( p_input, "sub-margin", i_pos );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Subtitle position %i px" ),
(int)(i_pos) );
}
......@@ -800,7 +799,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
++i_pos;
var_SetInteger( p_input, "sub-margin", i_pos );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Subtitle position %i px" ),
(int)(i_pos) );
}
......@@ -810,7 +809,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_delay -= 50000; /* 50 ms */
var_SetTime( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Audio delay %i ms" ),
(int)(i_delay/1000) );
}
......@@ -820,7 +819,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i_delay += 50000; /* 50 ms */
var_SetTime( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN,
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL,
_( "Audio delay %i ms" ),
(int)(i_delay/1000) );
}
......@@ -859,9 +858,9 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
const bool b_record = var_ToggleBool( p_input, "record" );
if( b_record )
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _("Recording") );
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _("Recording") );
else
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _("Recording done") );
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _("Recording done") );
}
}
}
......@@ -1048,7 +1047,7 @@ static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
static void DisplayRate( input_thread_t *p_input, float f_rate )
{
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Speed: %.2fx"), f_rate );
vout_OSDMessage( VLC_OBJECT(p_input), SPU_DEFAULT_CHANNEL, _("Speed: %.2fx"), f_rate );
}
static float AdjustRateFine( input_thread_t *p_input, const int i_dir )
......@@ -1072,16 +1071,11 @@ static float AdjustRateFine( input_thread_t *p_input, const int i_dir )
static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
{
int i;
if( p_vout )
{
spu_t *p_spu = vout_GetSpu( p_vout );
spu_Control( p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
for( i = 0; i < CHANNELS_NUMBER; i++ )
{
spu_Control( p_spu, SPU_CHANNEL_CLEAR,
p_intf->p_sys->p_channels[ i ] );
}
spu_ClearChannel( p_spu, SPU_DEFAULT_CHANNEL );
for( int i = 0; i < CHANNELS_NUMBER; i++ )
spu_ClearChannel( p_spu, p_intf->p_sys->p_channels[i] );
}
}
......@@ -211,12 +211,12 @@
var_Set( p_playlist, "random", val );
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 );
}
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 );
}
......@@ -278,7 +278,7 @@
config_PutInt( p_playlist, "loop", 0 );
/* 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 )
{
......@@ -294,7 +294,7 @@
config_PutInt( p_playlist, "loop", 1 );
/* show the change */
vout_OSDMessage( p_intf, DEFAULT_CHAN, "%s", _( "Repeat All" ) );
vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
}
else
{
......@@ -310,7 +310,7 @@
config_PutInt( p_playlist, "loop", 0 );
/* 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 */
......@@ -336,12 +336,12 @@
var_Set( p_playlist, "repeat", val );
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 );
}
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 );
}
......@@ -364,12 +364,12 @@
var_Set( p_playlist, "loop", val );
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 );
}
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 );
}
......
......@@ -37,7 +37,7 @@
void CmdQuit::execute()
{
// Stop the playlist
vout_OSDMessage( getIntf(), DEFAULT_CHAN, "%s", _( "Quit" ) );
vout_OSDMessage( getIntf(), SPU_DEFAULT_CHANNEL, "%s", _( "Quit" ) );
// Kill libvlc
libvlc_Quit( getIntf()->p_libvlc );
......
......@@ -69,7 +69,7 @@ static int vlclua_osd_icon( lua_State *L )
{
const char *psz_icon = luaL_checkstring( L, 1 );
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 )
return luaL_error( L, "\"%s\" is not a valid osd icon.", psz_icon );
else
......@@ -83,7 +83,7 @@ static int vlclua_osd_icon( lua_State *L )
static int vlclua_osd_message( lua_State *L )
{
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 );
vout_OSDMessage( p_this, i_chan, "%s", psz_message );
return 0;
......@@ -113,7 +113,7 @@ static int vlclua_osd_slider( lua_State *L )
int i_position = luaL_checkint( L, 1 );
const char *psz_type = luaL_checkstring( L, 2 );
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 )
return luaL_error( L, "\"%s\" is not a valid slider type.",
psz_type );
......@@ -134,7 +134,7 @@ static int vlclua_spu_channel_register( lua_State *L )
if( !p_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 );
lua_pushinteger( L, i_chan );
return 1;
......@@ -149,7 +149,7 @@ static int vlclua_spu_channel_clear( lua_State *L )
if( !p_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 );
return 0;
}
......
......@@ -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 );
if( p_vout && 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 );
if( p_vout )
vlc_object_release( p_vout );
......@@ -2098,7 +2098,7 @@ static void DeleteDecoder( decoder_t * p_dec )
if( 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 );
}
}
......@@ -2427,8 +2427,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
vlc_mutex_unlock( &p_owner->lock );
spu_Control( vout_GetSpu( p_vout ), SPU_CHANNEL_REGISTER,
&p_owner->i_spu_channel );
p_owner->i_spu_channel = spu_RegisterChannel( vout_GetSpu( p_vout ) );
p_owner->i_spu_order = 0;
p_owner->p_spu_vout = p_vout;
}
......
......@@ -273,7 +273,7 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
{
msg_Dbg( p_resource->p_input, "saving a free vout" );
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;
}
......
......@@ -390,6 +390,8 @@ spu_DisplaySubpicture
spu_Init
spu_RenderSubpictures
spu_SortSubpictures
spu_RegisterChannel
spu_ClearChannel
sql_Create
sql_Destroy
stats_TimerClean
......
......@@ -269,7 +269,7 @@ int vout_OSDEpg( vout_thread_t *p_vout, input_item_t *p_input )
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_stop = i_now + 3000 * INT64_C(1000);
p_spu->b_ephemer = true;
......
......@@ -873,7 +873,7 @@ static void ThreadDisplayOsdTitle(vout_thread_t *vout, const char *string)
INT64_C(1000) * vout->p->title.timeout;
if (stop > start)
vout_ShowTextAbsolute(vout, DEFAULT_CHAN,
vout_ShowTextAbsolute(vout, SPU_DEFAULT_CHANNEL,
string, NULL,
vout->p->title.position,
30 + vout->p->fmt_in.i_width
......
......@@ -373,7 +373,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic )
if( !p_subpic )
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 */
p_subpic->i_channel = 0;
p_subpic->i_start = mdate();
......@@ -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 )
{
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" ) )
{
......
......@@ -164,10 +164,6 @@ static int CropCallback( vlc_object_t *, char const *,
static int MarginCallback( vlc_object_t *, char const *,
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, ...) */
static subpicture_t *spu_new_buffer( filter_t * );
static void spu_del_buffer( filter_t *, subpicture_t * );
......@@ -208,7 +204,6 @@ spu_t *spu_Create( vlc_object_t *p_this )
vlc_object_attach( p_spu, p_this );
/* Initialize spu fields */
p_spu->pf_control = SpuControl;
p_spu->p = p_sys = (spu_private_t*)&p_spu[1];
/* Initialize private fields */
......@@ -357,9 +352,9 @@ void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
{
spu_private_t *p_sys = p_spu->p;
/* DEFAULT_CHAN always reset itself */
if( p_subpic->i_channel == DEFAULT_CHAN )
SpuClearChannel( p_spu, DEFAULT_CHAN );
/* SPU_DEFAULT_CHANNEL always reset itself */
if( p_subpic->i_channel == SPU_DEFAULT_CHANNEL )
spu_ClearChannel( p_spu, SPU_DEFAULT_CHANNEL );
/* 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 )
......@@ -715,6 +710,40 @@ void spu_OffsetSubtitleDate( spu_t *p_spu, mtime_t i_duration )
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
*****************************************************************************/
......@@ -1759,67 +1788,6 @@ static int SubpictureCmp( const void *s0, const void *s1 )
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
*****************************************************************************/
......@@ -1955,7 +1923,7 @@ static int SubFilterAllocationInit( filter_t *p_filter, void *p_data )
p_filter->pf_sub_buffer_del = sub_del_buffer;