[vlc-commits] commit: Used filter_GetInputAttachments in freetype and quartztext. ( Laurent Aimar )
git at videolan.org
git at videolan.org
Wed May 26 22:43:07 CEST 2010
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed May 26 22:37:25 2010 +0200| [b087d7887a1741c581a979812131505777975a3f] | committer: Laurent Aimar
Used filter_GetInputAttachments in freetype and quartztext.
It removes two broken vlc_object_find(INPUT, PARENT) and fixes input
attachements support when the vout is reused.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b087d7887a1741c581a979812131505777975a3f
---
modules/misc/freetype.c | 38 ++++++++--------------------------
modules/misc/quartztext.c | 50 +++++++++++++++-----------------------------
2 files changed, 26 insertions(+), 62 deletions(-)
diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c
index 5fc41fd..6422a38 100644
--- a/modules/misc/freetype.c
+++ b/modules/misc/freetype.c
@@ -534,44 +534,26 @@ static void Destroy( vlc_object_t *p_this )
static int LoadFontsFromAttachments( filter_t *p_filter )
{
filter_sys_t *p_sys = p_filter->p_sys;
- input_thread_t *p_input;
input_attachment_t **pp_attachments;
int i_attachments_cnt;
- int k;
- int rv = VLC_SUCCESS;
- p_input = (input_thread_t *)vlc_object_find( p_filter, VLC_OBJECT_INPUT, FIND_PARENT );
- if( ! p_input )
+ if( filter_GetInputAttachments( p_filter, &pp_attachments, &i_attachments_cnt ) )
return VLC_EGENERIC;
- if( VLC_SUCCESS != input_Control( p_input, INPUT_GET_ATTACHMENTS, &pp_attachments, &i_attachments_cnt ))
- {
- vlc_object_release(p_input);
- return VLC_EGENERIC;
- }
-
p_sys->i_font_attachments = 0;
p_sys->pp_font_attachments = malloc( i_attachments_cnt * sizeof( input_attachment_t * ));
- if(! p_sys->pp_font_attachments )
- rv = VLC_ENOMEM;
+ if( !p_sys->pp_font_attachments )
+ return VLC_ENOMEM;
- for( k = 0; k < i_attachments_cnt; k++ )
+ for( int k = 0; k < i_attachments_cnt; k++ )
{
input_attachment_t *p_attach = pp_attachments[k];
- if( p_sys->pp_font_attachments )
+ if( ( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
+ !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) && // OTF
+ p_attach->i_data > 0 && p_attach->p_data )
{
- if(( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
- !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) && // OTF
- ( p_attach->i_data > 0 ) &&
- ( p_attach->p_data != NULL ) )
- {
- p_sys->pp_font_attachments[ p_sys->i_font_attachments++ ] = p_attach;
- }
- else
- {
- vlc_input_attachment_Delete( p_attach );
- }
+ p_sys->pp_font_attachments[ p_sys->i_font_attachments++ ] = p_attach;
}
else
{
@@ -580,9 +562,7 @@ static int LoadFontsFromAttachments( filter_t *p_filter )
}
free( pp_attachments );
- vlc_object_release(p_input);
-
- return rv;
+ return VLC_SUCCESS;
}
/*****************************************************************************
diff --git a/modules/misc/quartztext.c b/modules/misc/quartztext.c
index 732f276..4b5294f 100644
--- a/modules/misc/quartztext.c
+++ b/modules/misc/quartztext.c
@@ -232,59 +232,43 @@ static void Destroy( vlc_object_t *p_this )
static int LoadFontsFromAttachments( filter_t *p_filter )
{
filter_sys_t *p_sys = p_filter->p_sys;
- input_thread_t *p_input;
input_attachment_t **pp_attachments;
int i_attachments_cnt;
- int k;
- int rv = VLC_SUCCESS;
- p_input = (input_thread_t *)vlc_object_find( p_filter, VLC_OBJECT_INPUT, FIND_PARENT );
- if( ! p_input )
+ if( filter_GetInputAttachments( p_filter, &pp_attachments, &i_attachments_cnt ) )
return VLC_EGENERIC;
- if( VLC_SUCCESS != input_Control( p_input, INPUT_GET_ATTACHMENTS, &pp_attachments, &i_attachments_cnt ))
- {
- vlc_object_release(p_input);
- return VLC_EGENERIC;
- }
-
p_sys->i_fonts = 0;
p_sys->p_fonts = malloc( i_attachments_cnt * sizeof( ATSFontContainerRef ) );
if(! p_sys->p_fonts )
- rv = VLC_ENOMEM;
+ return VLC_ENOMEM;
- for( k = 0; k < i_attachments_cnt; k++ )
+ for( int k = 0; k < i_attachments_cnt; k++ )
{
input_attachment_t *p_attach = pp_attachments[k];
- if( p_sys->p_fonts )
+ if( ( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
+ !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) && // OTF
+ p_attach->i_data > 0 && p_attach->p_data )
{
- if(( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
- !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) && // OTF
- ( p_attach->i_data > 0 ) &&
- ( p_attach->p_data != NULL ) )
+ ATSFontContainerRef container;
+
+ if( noErr == ATSFontActivateFromMemory( p_attach->p_data,
+ p_attach->i_data,
+ kATSFontContextLocal,
+ kATSFontFormatUnspecified,
+ NULL,
+ kATSOptionFlagsDefault,
+ &container ))
{
- ATSFontContainerRef container;
-
- if( noErr == ATSFontActivateFromMemory( p_attach->p_data,
- p_attach->i_data,
- kATSFontContextLocal,
- kATSFontFormatUnspecified,
- NULL,
- kATSOptionFlagsDefault,
- &container ))
- {
- p_sys->p_fonts[ p_sys->i_fonts++ ] = container;
- }
+ p_sys->p_fonts[ p_sys->i_fonts++ ] = container;
}
}
vlc_input_attachment_Delete( p_attach );
}
free( pp_attachments );
- vlc_object_release(p_input);
-
- return rv;
+ return VLC_SUCCESS;
}
static char *EliminateCRLF( char *psz_string )
More information about the vlc-commits
mailing list