/*****************************************************************************
* Local prototypes
*****************************************************************************/
+static void LocaleInit( void );
+static void LocaleDeinit( void );
static void SetLanguage ( char const * );
static int GetFilenames ( vlc_t *, int, char *[] );
static void Help ( vlc_t *, char const *psz_help_name );
libvlc.b_color = VLC_FALSE;
#endif
- /*
- * Global iconv
- */
- if( !vlc_current_charset( &psz_env ) )
- {
- vlc_mutex_init( p_libvlc, &libvlc.from_locale_lock );
- vlc_mutex_init( p_libvlc, &libvlc.to_locale_lock );
- libvlc.from_locale = vlc_iconv_open( "UTF-8", psz_env );
- libvlc.to_locale = vlc_iconv_open( psz_env, "UTF-8" );
- }
- free( psz_env );
-
/* Initialize message queue */
msg_Create( p_libvlc );
libvlc.p_module_bank = NULL;
libvlc.b_ready = VLC_TRUE;
+
+ /* UTF-8 convertor are initialized after the locale */
+ libvlc.from_locale = libvlc.to_locale = (vlc_iconv_t)(-1);
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_libvlc, "libvlc" );
module_t *p_help_module;
playlist_t *p_playlist;
vlc_value_t val;
+#if defined( ENABLE_NLS ) \
+ && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
char * psz_language;
+#endif
if( !p_vlc )
{
*/
SetLanguage( "" );
+ /*
+ * Global iconv, must be done after setlocale()
+ * so that vlc_current_charset() works.
+ */
+ LocaleInit();
+
/* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
msg_Dbg( p_vlc, "translation test: code is \"%s\"", _("C") );
/* Reset the default domain */
SetLanguage( psz_language );
+ LocaleDeinit();
+ LocaleInit();
/* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
msg_Dbg( p_vlc, "translation test: code is \"%s\"", _("C") );
msg_Destroy( p_libvlc );
/* Destroy global iconv */
- if( libvlc.to_locale != (vlc_iconv_t)(-1) )
- {
- vlc_mutex_destroy( &libvlc.from_locale_lock );
- vlc_mutex_destroy( &libvlc.to_locale_lock );
- vlc_iconv_close( libvlc.from_locale );
- vlc_iconv_close( libvlc.to_locale );
- }
+ LocaleDeinit();
/* Destroy mutexes */
vlc_mutex_destroy( &p_vlc->config_lock );
{
playlist_t * p_playlist;
vlc_bool_t b_playing;
+ vlc_value_t val;
vlc_t *p_vlc = vlc_current_object( i_object );
if( i_object ) vlc_object_release( p_vlc );
return VLC_ENOOBJ;
}
-
- b_playing = playlist_IsPlaying( p_playlist );
+ if( !p_playlist->p_input )
+ {
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_ENOOBJ;
+ }
+ var_Get( p_playlist->p_input, "state", &val );
+ b_playing = ( val.i_int == PLAYING_S );
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_vlc );
/* following functions are local */
+static void LocaleInit( void )
+{
+ char *psz_charset;
+
+ if( !vlc_current_charset( &psz_charset ) )
+ {
+ vlc_mutex_init( p_libvlc, &libvlc.from_locale_lock );
+ vlc_mutex_init( p_libvlc, &libvlc.to_locale_lock );
+ libvlc.from_locale = vlc_iconv_open( "UTF-8", psz_charset );
+ libvlc.to_locale = vlc_iconv_open( psz_charset, "UTF-8" );
+ if( !libvlc.to_locale )
+ {
+ // Not sure it is the right thing to do, but at least it
+ // doesn't make vlc crash with msvc !
+ libvlc.to_locale = (vlc_iconv_t)(-1);
+ }
+ }
+ else
+ libvlc.from_locale = libvlc.to_locale = (vlc_iconv_t)(-1);
+ free( psz_charset );
+}
+
+static void LocaleDeinit( void )
+{
+ if( libvlc.to_locale != (vlc_iconv_t)(-1) )
+ {
+ vlc_mutex_destroy( &libvlc.from_locale_lock );
+ vlc_mutex_destroy( &libvlc.to_locale_lock );
+ vlc_iconv_close( libvlc.from_locale );
+ vlc_iconv_close( libvlc.to_locale );
+ }
+}
+
/*****************************************************************************
* SetLanguage: set the interface language.
*****************************************************************************
#endif
setlocale( LC_ALL, psz_lang );
+ setlocale(LC_NUMERIC, "C" );
}
/* Specify where to find the locales for current domain */
char *psz_text, *psz_spaces = psz_spaces_text;
char *psz_bra = NULL, *psz_type = NULL, *psz_ket = NULL;
char *psz_suf = "", *psz_prefix = NULL;
- size_t i;
+ signed int i;
/* Skip deprecated options */
if( p_item->psz_current )