forked from len0rd/rockbox
Do playback restarts the proper way
It isn't necessary to explicitly stop and restart playback to force it to update something that must cause rebuffering. Change-Id: I6ff5394fcafc7374af67ef9fbf9022bb4a79b773
This commit is contained in:
parent
75d2e1f35c
commit
abef236081
6 changed files with 52 additions and 65 deletions
|
@ -2533,22 +2533,13 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_ALBUMART) && !defined(__PCTOOL__)
|
#if defined(HAVE_ALBUMART) && !defined(__PCTOOL__)
|
||||||
int status = audio_status();
|
/* last_albumart_{width,height} is either both 0 or valid AA dimensions */
|
||||||
if (status & AUDIO_STATUS_PLAY)
|
struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart);
|
||||||
|
if (aa && (aa->state != WPS_ALBUMART_NONE ||
|
||||||
|
(((wps_data->last_albumart_height != aa->height) ||
|
||||||
|
(wps_data->last_albumart_width != aa->width)))))
|
||||||
{
|
{
|
||||||
/* last_albumart_{width,height} is either both 0 or valid AA dimensions */
|
playback_update_aa_dims();
|
||||||
struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart);
|
|
||||||
if (aa && (aa->state != WPS_ALBUMART_NONE ||
|
|
||||||
(((wps_data->last_albumart_height != aa->height) ||
|
|
||||||
(wps_data->last_albumart_width != aa->width)))))
|
|
||||||
{
|
|
||||||
struct mp3entry *id3 = audio_current_track();
|
|
||||||
unsigned long elapsed = id3->elapsed;
|
|
||||||
unsigned long offset = id3->offset;
|
|
||||||
audio_stop();
|
|
||||||
if (!(status & AUDIO_STATUS_PAUSE))
|
|
||||||
audio_play(elapsed, offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef __PCTOOL__
|
#ifndef __PCTOOL__
|
||||||
|
|
|
@ -258,7 +258,7 @@ static int playback_callback(int action,const struct menu_item_ex *this_item)
|
||||||
#ifdef HAVE_PLAY_FREQ
|
#ifdef HAVE_PLAY_FREQ
|
||||||
if (this_item == &play_frequency)
|
if (this_item == &play_frequency)
|
||||||
{
|
{
|
||||||
settings_apply_play_freq(global_settings.play_frequency, false);
|
audio_set_playback_frequency(global_settings.play_frequency);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_PLAY_FREQ */
|
#endif /* HAVE_PLAY_FREQ */
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PLAY_FREQ
|
||||||
|
#include "pcm_mixer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: The audio thread really is doing multitasking of acting like a
|
/* TODO: The audio thread really is doing multitasking of acting like a
|
||||||
consumer and producer of tracks. It may be advantageous to better
|
consumer and producer of tracks. It may be advantageous to better
|
||||||
logically separate the two functions. I won't go that far just yet. */
|
logically separate the two functions. I won't go that far just yet. */
|
||||||
|
@ -2523,6 +2527,7 @@ static void audio_start_playback(const struct audio_resume_info *resume_info,
|
||||||
resume.elapsed = id3_get(PLAYING_ID3)->elapsed;
|
resume.elapsed = id3_get(PLAYING_ID3)->elapsed;
|
||||||
resume.offset = id3_get(PLAYING_ID3)->offset;
|
resume.offset = id3_get(PLAYING_ID3)->offset;
|
||||||
track_list_clear(TRACK_LIST_CLEAR_ALL);
|
track_list_clear(TRACK_LIST_CLEAR_ALL);
|
||||||
|
pcmbuf_update_frequency();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2555,9 +2560,6 @@ static void audio_start_playback(const struct audio_resume_info *resume_info,
|
||||||
#endif
|
#endif
|
||||||
#ifndef PLATFORM_HAS_VOLUME_CHANGE
|
#ifndef PLATFORM_HAS_VOLUME_CHANGE
|
||||||
sound_set_volume(global_settings.volume);
|
sound_set_volume(global_settings.volume);
|
||||||
#endif
|
|
||||||
#ifdef HAVE_PLAY_FREQ
|
|
||||||
settings_apply_play_freq(global_settings.play_frequency, true);
|
|
||||||
#endif
|
#endif
|
||||||
pcmbuf_update_frequency();
|
pcmbuf_update_frequency();
|
||||||
|
|
||||||
|
@ -3628,6 +3630,12 @@ void playback_release_aa_slot(int slot)
|
||||||
aa_slot->used--;
|
aa_slot->used--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playback_update_aa_dims(void)
|
||||||
|
{
|
||||||
|
LOGFQUEUE("audio >| audio Q_AUDIO_REMAKE_AUDIO_BUFFER");
|
||||||
|
audio_queue_send(Q_AUDIO_REMAKE_AUDIO_BUFFER, 0);
|
||||||
|
}
|
||||||
#endif /* HAVE_ALBUMART */
|
#endif /* HAVE_ALBUMART */
|
||||||
|
|
||||||
/* Return file byte offset */
|
/* Return file byte offset */
|
||||||
|
@ -3702,6 +3710,26 @@ void audio_set_crossfade(int enable)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CROSSFADE */
|
#endif /* HAVE_CROSSFADE */
|
||||||
|
|
||||||
|
#ifdef HAVE_PLAY_FREQ
|
||||||
|
void audio_set_playback_frequency(int setting)
|
||||||
|
{
|
||||||
|
static const unsigned long play_sampr[] = { SAMPR_44, SAMPR_48 };
|
||||||
|
|
||||||
|
if ((unsigned)setting >= ARRAYLEN(play_sampr))
|
||||||
|
setting = 0;
|
||||||
|
|
||||||
|
unsigned long playback_sampr = mixer_get_frequency();
|
||||||
|
unsigned long sampr = play_sampr[setting];
|
||||||
|
|
||||||
|
if (sampr != playback_sampr)
|
||||||
|
{
|
||||||
|
mixer_set_frequency(sampr);
|
||||||
|
LOGFQUEUE("audio >| audio Q_AUDIO_REMAKE_AUDIO_BUFFER");
|
||||||
|
audio_queue_send(Q_AUDIO_REMAKE_AUDIO_BUFFER, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PLAY_FREQ */
|
||||||
|
|
||||||
unsigned int playback_status(void)
|
unsigned int playback_status(void)
|
||||||
{
|
{
|
||||||
return play_status;
|
return play_status;
|
||||||
|
|
|
@ -62,12 +62,18 @@ int playback_claim_aa_slot(struct dim *dim);
|
||||||
* Save to call from other threads */
|
* Save to call from other threads */
|
||||||
void playback_release_aa_slot(int slot);
|
void playback_release_aa_slot(int slot);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tells playback to sync buffered album art dimensions
|
||||||
|
*
|
||||||
|
* Save to call from other threads */
|
||||||
|
void playback_update_aa_dims(void);
|
||||||
|
|
||||||
struct bufopen_bitmap_data {
|
struct bufopen_bitmap_data {
|
||||||
struct dim *dim;
|
struct dim *dim;
|
||||||
struct mp3_albumart *embedded_albumart;
|
struct mp3_albumart *embedded_albumart;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif /* HAVE_ALBUMART */
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
int audio_track_count(void);
|
int audio_track_count(void);
|
||||||
|
@ -79,6 +85,9 @@ void audio_set_cuesheet(bool enable);
|
||||||
#ifdef HAVE_CROSSFADE
|
#ifdef HAVE_CROSSFADE
|
||||||
void audio_set_crossfade(int enable);
|
void audio_set_crossfade(int enable);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_PLAY_FREQ
|
||||||
|
void audio_set_playback_frequency(int setting);
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t audio_get_filebuflen(void);
|
size_t audio_get_filebuflen(void);
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,6 @@ struct system_status global_status;
|
||||||
#include "enc_config.h"
|
#include "enc_config.h"
|
||||||
#endif
|
#endif
|
||||||
#include "pcm_sampr.h"
|
#include "pcm_sampr.h"
|
||||||
#ifdef HAVE_PLAY_FREQ
|
|
||||||
#include "pcm_mixer.h"
|
|
||||||
#include "dsp_core.h"
|
|
||||||
#endif
|
|
||||||
#endif /* CONFIG_CODEC == SWCODEC */
|
#endif /* CONFIG_CODEC == SWCODEC */
|
||||||
|
|
||||||
#define NVRAM_BLOCK_SIZE 44
|
#define NVRAM_BLOCK_SIZE 44
|
||||||
|
@ -735,41 +731,6 @@ void settings_apply_pm_range(void)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
|
||||||
#ifdef HAVE_PLAY_FREQ
|
|
||||||
void settings_apply_play_freq(int value, bool playback)
|
|
||||||
{
|
|
||||||
static const unsigned long play_sampr[] = { SAMPR_44, SAMPR_48 };
|
|
||||||
static int prev_setting = 0;
|
|
||||||
|
|
||||||
if ((unsigned)value >= ARRAYLEN(play_sampr))
|
|
||||||
value = 0;
|
|
||||||
|
|
||||||
bool changed = value != prev_setting;
|
|
||||||
prev_setting = value;
|
|
||||||
|
|
||||||
unsigned long elapsed = 0;
|
|
||||||
unsigned long offset = 0;
|
|
||||||
bool playing = changed && !playback &&
|
|
||||||
audio_status() == AUDIO_STATUS_PLAY;
|
|
||||||
|
|
||||||
if (playing)
|
|
||||||
{
|
|
||||||
struct mp3entry *id3 = audio_current_track();
|
|
||||||
elapsed = id3->elapsed;
|
|
||||||
offset = id3->offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed && !playback)
|
|
||||||
audio_hard_stop();
|
|
||||||
|
|
||||||
/* Other sub-areas of playback pick it up from the mixer */
|
|
||||||
mixer_set_frequency(play_sampr[value]);
|
|
||||||
|
|
||||||
if (playing)
|
|
||||||
audio_play(elapsed, offset);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_PLAY_FREQ */
|
|
||||||
|
|
||||||
void sound_settings_apply(void)
|
void sound_settings_apply(void)
|
||||||
{
|
{
|
||||||
#ifdef AUDIOHW_HAVE_BASS
|
#ifdef AUDIOHW_HAVE_BASS
|
||||||
|
@ -1023,10 +984,11 @@ void settings_apply(bool read_disk)
|
||||||
lcd_scroll_delay(global_settings.scroll_delay);
|
lcd_scroll_delay(global_settings.scroll_delay);
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_PLAY_FREQ
|
|
||||||
settings_apply_play_freq(global_settings.play_frequency, false);
|
|
||||||
#endif
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
#ifdef HAVE_PLAY_FREQ
|
||||||
|
/* before crossfade */
|
||||||
|
audio_set_playback_frequency(global_settings.play_frequency);
|
||||||
|
#endif
|
||||||
#ifdef HAVE_CROSSFADE
|
#ifdef HAVE_CROSSFADE
|
||||||
audio_set_crossfade(global_settings.crossfade);
|
audio_set_crossfade(global_settings.crossfade);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -224,9 +224,6 @@ void settings_apply_skins(void);
|
||||||
|
|
||||||
void settings_apply(bool read_disk);
|
void settings_apply(bool read_disk);
|
||||||
void settings_apply_pm_range(void);
|
void settings_apply_pm_range(void);
|
||||||
#ifdef HAVE_PLAY_FREQ
|
|
||||||
void settings_apply_play_freq(int value, bool playback);
|
|
||||||
#endif
|
|
||||||
void settings_display(void);
|
void settings_display(void);
|
||||||
|
|
||||||
enum optiontype { INT, BOOL };
|
enum optiontype { INT, BOOL };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue