Commit 1fd58a36 authored by JPeg's avatar JPeg Committed by Jean-Baptiste Kempf

Bugfix: last.fm segfaults under Windows This is due to %ju unsupported in...

Bugfix: last.fm segfaults under Windows This is due to %ju unsupported in printf. I also added a few HACKs to enhance submitting (length = 0 did not work, for instance).
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 519a81a2
...@@ -325,6 +325,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -325,6 +325,11 @@ static void Run( intf_thread_t *p_intf )
msg_Dbg( p_intf, "Going to submit some data..." ); msg_Dbg( p_intf, "Going to submit some data..." );
/* The session may be invalid if there is a trailing \n */
char *psz_ln = strrchr( p_sys->psz_auth_token, '\n' );
if( psz_ln )
*psz_ln = '\0';
if( !asprintf( &psz_submit, "s=%s", p_sys->psz_auth_token ) ) if( !asprintf( &psz_submit, "s=%s", p_sys->psz_auth_token ) )
{ /* Out of memory */ { /* Out of memory */
return; return;
...@@ -337,14 +342,24 @@ static void Run( intf_thread_t *p_intf ) ...@@ -337,14 +342,24 @@ static void Run( intf_thread_t *p_intf )
{ {
p_song = &p_sys->p_queue[i_song]; p_song = &p_sys->p_queue[i_song];
if( !asprintf( &psz_submit_song, if( !asprintf( &psz_submit_song,
"&a%%5B%d%%5D=%s&t%%5B%d%%5D=%s" "&a%%5B%d%%5D=%s"
"&i%%5B%d%%5D=%ju&o%%5B%d%%5D=P&r%%5B%d%%5D=" "&t%%5B%d%%5D=%s"
"&l%%5B%d%%5D=%d&b%%5B%d%%5D=%s" "&i%%5B%d%%5D=%u"
"&n%%5B%d%%5D=%s&m%%5B%d%%5D=%s", "&o%%5B%d%%5D=P"
i_song, p_song->psz_a, i_song, p_song->psz_t, "&r%%5B%d%%5D="
i_song, (uintmax_t)p_song->date, i_song, i_song, "&l%%5B%d%%5D=%d"
i_song, p_song->i_l, i_song, p_song->psz_b, "&b%%5B%d%%5D=%s"
i_song, p_song->psz_n, i_song, p_song->psz_m "&n%%5B%d%%5D=%s"
"&m%%5B%d%%5D=%s",
i_song, p_song->psz_a,
i_song, p_song->psz_t,
i_song, (unsigned)p_song->date, /* HACK: %ju (uintmax_t) unsupported on Windows */
i_song,
i_song,
i_song, p_song->i_l,
i_song, p_song->psz_b,
i_song, p_song->psz_n,
i_song, p_song->psz_m
) ) ) )
{ /* Out of memory */ { /* Out of memory */
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
...@@ -559,7 +574,7 @@ static void AddToQueue ( intf_thread_t *p_this ) ...@@ -559,7 +574,7 @@ static void AddToQueue ( intf_thread_t *p_this )
p_sys->time_total_pauses; p_sys->time_total_pauses;
played_time /= 1000000; /* µs → s */ played_time /= 1000000; /* µs → s */
if( ( played_time < 240 ) && if( ( played_time < 60 ) &&
( played_time < ( p_sys->p_current_song.i_l / 2 ) ) ) ( played_time < ( p_sys->p_current_song.i_l / 2 ) ) )
{ {
msg_Dbg( p_this, "Song not listened long enough, not submitting" ); msg_Dbg( p_this, "Song not listened long enough, not submitting" );
...@@ -567,10 +582,16 @@ static void AddToQueue ( intf_thread_t *p_this ) ...@@ -567,10 +582,16 @@ static void AddToQueue ( intf_thread_t *p_this )
} }
if( p_sys->p_current_song.i_l < 30 ) if( p_sys->p_current_song.i_l < 30 )
{
if( played_time < 30 )
{ {
msg_Dbg( p_this, "Song too short (< 30s), not submitting" ); msg_Dbg( p_this, "Song too short (< 30s), not submitting" );
goto end; goto end;
} }
else
/* This is a HACK to avoid length = 0 (seems to be rejected by audioscrobbler) */
p_sys->p_current_song.i_l = played_time;
}
if( !p_sys->p_current_song.psz_a || !*p_sys->p_current_song.psz_a || if( !p_sys->p_current_song.psz_a || !*p_sys->p_current_song.psz_a ||
!p_sys->p_current_song.psz_t || !*p_sys->p_current_song.psz_t ) !p_sys->p_current_song.psz_t || !*p_sys->p_current_song.psz_t )
......
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