Skip to content

Commit

Permalink
Cleaned up a bit spu_t API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Aimar committed May 4, 2010
1 parent a01d5d9 commit 776b826
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 167 deletions.
39 changes: 11 additions & 28 deletions include/vlc_spu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 * ) );
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/codec/zvbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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;

Expand Down
76 changes: 35 additions & 41 deletions modules/control/hotkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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;
Expand All @@ -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 );
Expand All @@ -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 );

Expand Down Expand Up @@ -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 );

Expand All @@ -575,18 +574,18 @@ 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
{
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") );
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
}
Expand All @@ -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 )
Expand Down Expand Up @@ -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) );
}
Expand All @@ -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) );
}
Expand All @@ -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) );
}
Expand All @@ -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) );
}
Expand All @@ -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) );
}
Expand All @@ -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) );
}
Expand Down Expand Up @@ -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") );
}
}
}
Expand Down Expand Up @@ -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 )
Expand All @@ -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] );
}
}
Loading

0 comments on commit 776b826

Please sign in to comment.