Commit d4ccd7a5 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Fix broken NowPlaying (close #9960, #11796, #12850)

Prevent the es_out from overriding the NowPlaying state by splitting
the meta into NowPlaying and ESNowPlaying.

The function input_item_GetNowPlayingFb can be used to return the
preferred meta value.
parent 08969c41
......@@ -192,6 +192,7 @@ VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type
VLC_API char * input_item_GetName( input_item_t * p_i ) VLC_USED;
VLC_API char * input_item_GetTitleFbName( input_item_t * p_i ) VLC_USED;
VLC_API char * input_item_GetURI( input_item_t * p_i ) VLC_USED;
VLC_API char * input_item_GetNowPlayingFb( input_item_t *p_item ) VLC_USED;
VLC_API void input_item_SetURI( input_item_t * p_i, const char *psz_uri );
VLC_API mtime_t input_item_GetDuration( input_item_t * p_i );
VLC_API void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration );
......@@ -223,6 +224,7 @@ INPUT_META(Setting)
INPUT_META(URL)
INPUT_META(Language)
INPUT_META(NowPlaying)
INPUT_META(ESNowPlaying)
INPUT_META(Publisher)
INPUT_META(EncodedBy)
INPUT_META(ArtworkURL)
......
......@@ -45,6 +45,7 @@ typedef enum vlc_meta_type_t
vlc_meta_URL,
vlc_meta_Language,
vlc_meta_NowPlaying,
vlc_meta_ESNowPlaying,
vlc_meta_Publisher,
vlc_meta_EncodedBy,
vlc_meta_ArtworkURL,
......
......@@ -88,6 +88,7 @@ static const libvlc_meta_t vlc_to_libvlc_meta[] =
[vlc_meta_URL] = libvlc_meta_URL,
[vlc_meta_Language] = libvlc_meta_Language,
[vlc_meta_NowPlaying] = libvlc_meta_NowPlaying,
[vlc_meta_ESNowPlaying] = libvlc_meta_NowPlaying,
[vlc_meta_Publisher] = libvlc_meta_Publisher,
[vlc_meta_EncodedBy] = libvlc_meta_EncodedBy,
[vlc_meta_ArtworkURL] = libvlc_meta_ArtworkURL,
......@@ -495,13 +496,21 @@ libvlc_media_get_mrl( libvlc_media_t * p_md )
char *libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta )
{
char *psz_meta = input_item_GetMeta( p_md->p_input_item,
libvlc_to_vlc_meta[e_meta] );
/* Should be integrated in core */
if( psz_meta == NULL && e_meta == libvlc_meta_Title
&& p_md->p_input_item->psz_name != NULL )
psz_meta = strdup( p_md->p_input_item->psz_name );
char *psz_meta = NULL;
if( e_meta == libvlc_meta_NowPlaying )
{
psz_meta = input_item_GetNowPlayingFb( p_md->p_input_item );
}
else
{
psz_meta = input_item_GetMeta( p_md->p_input_item,
libvlc_to_vlc_meta[e_meta] );
/* Should be integrated in core */
if( psz_meta == NULL && e_meta == libvlc_meta_Title
&& p_md->p_input_item->psz_name != NULL )
psz_meta = strdup( p_md->p_input_item->psz_name );
}
return psz_meta;
}
......
......@@ -201,8 +201,8 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
}
/* Playing something ... */
if( input_item_GetNowPlaying( p_item ) )
psz_title = input_item_GetNowPlaying( p_item );
if( input_item_GetNowPlayingFb( p_item ) )
psz_title = input_item_GetNowPlayingFb( p_item );
else
psz_title = input_item_GetTitleFbName( p_item );
if( EMPTY_STR( psz_title ) )
......
......@@ -1012,7 +1012,7 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
}
/* Update now playing */
input_item_SetNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
input_item_SetESNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
input_item_SetPublisher( p_input->p->p_item, p_pgrm->psz_publisher );
input_SendEventMeta( p_input );
......@@ -1154,7 +1154,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
/* Check against empty meta data (empty for what we handle) */
if( !vlc_meta_Get( p_meta, vlc_meta_Title) &&
!vlc_meta_Get( p_meta, vlc_meta_NowPlaying) &&
!vlc_meta_Get( p_meta, vlc_meta_ESNowPlaying) &&
!vlc_meta_Get( p_meta, vlc_meta_Publisher) &&
vlc_meta_GetExtraCount( p_meta ) <= 0 )
{
......@@ -1293,20 +1293,20 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
if( p_pgrm == p_sys->p_pgrm )
{
input_item_SetNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
input_item_SetESNowPlaying( p_input->p->p_item, p_pgrm->psz_now_playing );
input_SendEventMeta( p_input );
}
if( p_pgrm->psz_now_playing )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
vlc_meta_TypeToLocalizedString(vlc_meta_NowPlaying), "%s",
vlc_meta_TypeToLocalizedString(vlc_meta_ESNowPlaying), "%s",
p_pgrm->psz_now_playing );
}
else
{
input_Control( p_input, INPUT_DEL_INFO, psz_cat,
vlc_meta_TypeToLocalizedString(vlc_meta_NowPlaying) );
vlc_meta_TypeToLocalizedString(vlc_meta_ESNowPlaying) );
}
free( psz_cat );
......
......@@ -448,6 +448,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
/* Remove 'Now playing' info as it is probably outdated */
input_item_SetNowPlaying( p_item, NULL );
input_item_SetESNowPlaying( p_item, NULL );
input_SendEventMeta( p_input );
/* */
......
......@@ -386,6 +386,17 @@ void input_item_SetDuration( input_item_t *p_i, mtime_t i_duration )
}
}
char *input_item_GetNowPlayingFb( input_item_t *p_item )
{
char *psz_meta = input_item_GetMeta( p_item, vlc_meta_NowPlaying );
if( !psz_meta || strlen( psz_meta ) == 0 )
{
free( psz_meta );
return input_item_GetMeta( p_item, vlc_meta_ESNowPlaying );
}
return psz_meta;
}
bool input_item_IsPreparsed( input_item_t *p_item )
{
......
......@@ -64,6 +64,7 @@ const char * vlc_meta_TypeToLocalizedString( vlc_meta_type_t meta_type )
[vlc_meta_Setting] = N_("Setting"),
[vlc_meta_URL] = N_("URL"),
[vlc_meta_Language] = N_("Language"),
[vlc_meta_ESNowPlaying]= N_("Now Playing"),
[vlc_meta_NowPlaying] = N_("Now Playing"),
[vlc_meta_Publisher] = N_("Publisher"),
[vlc_meta_EncodedBy] = N_("Encoded by"),
......
......@@ -158,7 +158,7 @@ static void DisplayVoutTitle( input_resource_t *p_resource,
input_item_t *p_item = input_GetItem( p_resource->p_input );
char *psz_nowplaying = input_item_GetNowPlaying( p_item );
char *psz_nowplaying = input_item_GetNowPlayingFb( p_item );
if( psz_nowplaying && *psz_nowplaying )
{
vout_DisplayTitle( p_vout, psz_nowplaying );
......
......@@ -189,6 +189,7 @@ input_item_GetDuration
input_item_GetInfo
input_item_GetMeta
input_item_GetName
input_item_GetNowPlayingFb
input_item_GetTitleFbName
input_item_GetURI
input_item_HasErrorWhenReading
......
......@@ -603,7 +603,16 @@ char *str_format_meta(input_thread_t *input, const char *s)
write_meta(stream, item, vlc_meta_TrackNumber);
break;
case 'p':
write_meta(stream, item, vlc_meta_NowPlaying);
if (item == NULL)
break;
{
char *value = input_item_GetNowPlayingFb(item);
if (value == NULL)
break;
fputs(value, stream);
free(value);
}
break;
case 'r':
write_meta(stream, item, vlc_meta_Rating);
......@@ -763,18 +772,27 @@ char *str_format_meta(input_thread_t *input, const char *s)
case 'Z':
if (item == NULL)
break;
if (write_meta(stream, item, vlc_meta_NowPlaying) == EOF)
{
char *title = input_item_GetTitleFbName(item);
char *value = input_item_GetNowPlayingFb(item);
if (value == NULL)
break;
if (write_meta(stream, item, vlc_meta_Artist) >= 0
&& title != NULL)
fputs(" - ", stream);
int ret = fputs(value, stream);
free(value);
if (title != NULL)
if (ret == EOF)
{
fputs(title, stream);
free(title);
char *title = input_item_GetTitleFbName(item);
if (write_meta(stream, item, vlc_meta_Artist) >= 0
&& title != NULL)
fputs(" - ", stream);
if (title != NULL)
{
fputs(title, stream);
free(title);
}
}
}
break;
......
......@@ -263,7 +263,7 @@ static void OSDEpgDestroy(subpicture_t *subpic)
*/
int vout_OSDEpg(vout_thread_t *vout, input_item_t *input)
{
char *now_playing = input_item_GetNowPlaying(input);
char *now_playing = input_item_GetNowPlayingFb(input);
vlc_epg_t *epg = NULL;
vlc_mutex_lock(&input->lock);
......
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