Commit 6583dd3a 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 internal function input_item_GetNowPlayingFb can be used to return
the preferred meta value.

Stripped-down version of d4ccd7a5b404f62435c60ecc65f772dab83f5937
available on master.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 21247f8c
......@@ -200,6 +200,17 @@ VLC_API void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration );
VLC_API bool input_item_IsPreparsed( input_item_t *p_i );
VLC_API bool input_item_IsArtFetched( input_item_t *p_i );
static inline 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;
}
#define INPUT_META( name ) \
static inline \
void input_item_Set ## name (input_item_t *p_input, const char *val) \
......@@ -225,6 +236,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,
......
......@@ -86,6 +86,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,
......@@ -491,12 +492,22 @@ 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;
}
......
......@@ -1014,7 +1014,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 );
......@@ -1157,6 +1157,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 )
{
......@@ -1295,20 +1296,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 );
......
......@@ -449,6 +449,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 );
/* */
......
......@@ -65,6 +65,7 @@ const char * vlc_meta_TypeToLocalizedString( vlc_meta_type_t meta_type )
[vlc_meta_URL] = N_("URL"),
[vlc_meta_Language] = N_("Language"),
[vlc_meta_NowPlaying] = N_("Now Playing"),
[vlc_meta_ESNowPlaying]= N_("Now Playing"),
[vlc_meta_Publisher] = N_("Publisher"),
[vlc_meta_EncodedBy] = N_("Encoded by"),
[vlc_meta_ArtworkURL] = N_("Artwork URL"),
......
......@@ -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 );
......
......@@ -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