forked from len0rd/rockbox
A patch by Robert Keevil that's been in the tracker way to long, fixes FS #6213: Audioscrobbler incorrectly submits last song
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13699 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
78c45530ff
commit
12d2d0fbc2
5 changed files with 32 additions and 8 deletions
|
|
@ -605,6 +605,8 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
|
|||
#else
|
||||
int i;
|
||||
|
||||
scrobbler_poweroff();
|
||||
|
||||
#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
if(!charger_inserted())
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3271,6 +3271,8 @@ static void audio_stop_playback(void)
|
|||
/* Save the current playing spot, or NULL if the playlist has ended */
|
||||
playlist_update_resume_info(id3);
|
||||
|
||||
prev_track_elapsed = CUR_TI->id3.elapsed;
|
||||
|
||||
/* Increment index so runtime info is saved in audio_clear_track_entries().
|
||||
* Done here, as audio_stop_playback() may be called more than once.
|
||||
* Don't update runtime unless playback is stopped because of end of playlist.
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ static bool scrobbler_flush_callback(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void add_to_cache(void)
|
||||
static void add_to_cache(unsigned long play_length)
|
||||
{
|
||||
if ( cache_pos >= SCROBBLER_MAX_CACHE )
|
||||
write_cache();
|
||||
|
|
@ -149,8 +149,7 @@ static void add_to_cache(void)
|
|||
|
||||
logf("SCROBBLER: add_to_cache[%d]", cache_pos);
|
||||
|
||||
if ( audio_prev_elapsed() >
|
||||
(scrobbler_entry.length/2) )
|
||||
if ( play_length > (scrobbler_entry.length/2) )
|
||||
rating = 'L'; /* Listened */
|
||||
|
||||
if (scrobbler_entry.tracknum > 0)
|
||||
|
|
@ -193,7 +192,7 @@ void scrobbler_change_event(struct mp3entry *id)
|
|||
{
|
||||
/* add entry using the previous scrobbler_entry and timestamp */
|
||||
if (pending)
|
||||
add_to_cache();
|
||||
add_to_cache(audio_prev_elapsed());
|
||||
|
||||
/* check if track was resumed > %50 played
|
||||
check for blank artist or track name */
|
||||
|
|
@ -239,7 +238,7 @@ void scrobbler_flush_cache(void)
|
|||
{
|
||||
/* Add any pending entries to the cache */
|
||||
if(pending)
|
||||
add_to_cache();
|
||||
add_to_cache(audio_prev_elapsed());
|
||||
|
||||
/* Write the cache to disk if needed */
|
||||
if (cache_pos)
|
||||
|
|
@ -265,6 +264,21 @@ void scrobbler_shutdown(void)
|
|||
}
|
||||
}
|
||||
|
||||
void scrobbler_poweroff(void)
|
||||
{
|
||||
if (scrobbler_initialised && pending)
|
||||
{
|
||||
if ( audio_status() )
|
||||
add_to_cache(audio_current_track()->elapsed);
|
||||
else
|
||||
add_to_cache(audio_prev_elapsed());
|
||||
|
||||
/* scrobbler_shutdown is called later, the cache will be written
|
||||
* make sure the final track isn't added twice when that happens */
|
||||
pending = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool scrobbler_is_enabled(void)
|
||||
{
|
||||
return scrobbler_initialised;
|
||||
|
|
|
|||
|
|
@ -21,4 +21,5 @@ void scrobbler_change_event(struct mp3entry *id);
|
|||
int scrobbler_init(void);
|
||||
void scrobbler_flush_cache(void);
|
||||
void scrobbler_shutdown(void);
|
||||
void scrobbler_poweroff(void);
|
||||
bool scrobbler_is_enabled(void);
|
||||
|
|
|
|||
|
|
@ -2727,6 +2727,11 @@ void audio_play(long offset)
|
|||
void audio_stop(void)
|
||||
{
|
||||
#ifndef SIMULATOR
|
||||
if (playing)
|
||||
{
|
||||
struct trackdata *track = get_trackdata(0);
|
||||
prev_track_elapsed = track->id3.elapsed;
|
||||
}
|
||||
mpeg_stop_done = false;
|
||||
queue_post(&mpeg_queue, MPEG_STOP, 0);
|
||||
while(!mpeg_stop_done)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue