summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_parser.c23
-rw-r--r--apps/menus/playback_menu.c2
-rw-r--r--apps/playback.c34
-rw-r--r--apps/playback.h11
-rw-r--r--apps/settings.c44
-rw-r--r--apps/settings.h3
6 files changed, 52 insertions, 65 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 5409861cc7..dce88e9c58 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -2533,22 +2533,13 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2533 } 2533 }
2534#endif 2534#endif
2535#if defined(HAVE_ALBUMART) && !defined(__PCTOOL__) 2535#if defined(HAVE_ALBUMART) && !defined(__PCTOOL__)
2536 int status = audio_status(); 2536 /* last_albumart_{width,height} is either both 0 or valid AA dimensions */
2537 if (status & AUDIO_STATUS_PLAY) 2537 struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart);
2538 { 2538 if (aa && (aa->state != WPS_ALBUMART_NONE ||
2539 /* last_albumart_{width,height} is either both 0 or valid AA dimensions */ 2539 (((wps_data->last_albumart_height != aa->height) ||
2540 struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart); 2540 (wps_data->last_albumart_width != aa->width)))))
2541 if (aa && (aa->state != WPS_ALBUMART_NONE || 2541 {
2542 (((wps_data->last_albumart_height != aa->height) || 2542 playback_update_aa_dims();
2543 (wps_data->last_albumart_width != aa->width)))))
2544 {
2545 struct mp3entry *id3 = audio_current_track();
2546 unsigned long elapsed = id3->elapsed;
2547 unsigned long offset = id3->offset;
2548 audio_stop();
2549 if (!(status & AUDIO_STATUS_PAUSE))
2550 audio_play(elapsed, offset);
2551 }
2552 } 2543 }
2553#endif 2544#endif
2554#ifndef __PCTOOL__ 2545#ifndef __PCTOOL__
diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c
index a82c88e04a..23f1cb55bf 100644
--- a/apps/menus/playback_menu.c
+++ b/apps/menus/playback_menu.c
@@ -258,7 +258,7 @@ static int playback_callback(int action,const struct menu_item_ex *this_item)
258#ifdef HAVE_PLAY_FREQ 258#ifdef HAVE_PLAY_FREQ
259 if (this_item == &play_frequency) 259 if (this_item == &play_frequency)
260 { 260 {
261 settings_apply_play_freq(global_settings.play_frequency, false); 261 audio_set_playback_frequency(global_settings.play_frequency);
262 break; 262 break;
263 } 263 }
264#endif /* HAVE_PLAY_FREQ */ 264#endif /* HAVE_PLAY_FREQ */
diff --git a/apps/playback.c b/apps/playback.c
index 54410ad2cc..28e520319d 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -52,6 +52,10 @@
52#endif 52#endif
53#endif 53#endif
54 54
55#ifdef HAVE_PLAY_FREQ
56#include "pcm_mixer.h"
57#endif
58
55/* TODO: The audio thread really is doing multitasking of acting like a 59/* TODO: The audio thread really is doing multitasking of acting like a
56 consumer and producer of tracks. It may be advantageous to better 60 consumer and producer of tracks. It may be advantageous to better
57 logically separate the two functions. I won't go that far just yet. */ 61 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,
2523 resume.elapsed = id3_get(PLAYING_ID3)->elapsed; 2527 resume.elapsed = id3_get(PLAYING_ID3)->elapsed;
2524 resume.offset = id3_get(PLAYING_ID3)->offset; 2528 resume.offset = id3_get(PLAYING_ID3)->offset;
2525 track_list_clear(TRACK_LIST_CLEAR_ALL); 2529 track_list_clear(TRACK_LIST_CLEAR_ALL);
2530 pcmbuf_update_frequency();
2526 } 2531 }
2527 else 2532 else
2528 { 2533 {
@@ -2556,9 +2561,6 @@ static void audio_start_playback(const struct audio_resume_info *resume_info,
2556#ifndef PLATFORM_HAS_VOLUME_CHANGE 2561#ifndef PLATFORM_HAS_VOLUME_CHANGE
2557 sound_set_volume(global_settings.volume); 2562 sound_set_volume(global_settings.volume);
2558#endif 2563#endif
2559#ifdef HAVE_PLAY_FREQ
2560 settings_apply_play_freq(global_settings.play_frequency, true);
2561#endif
2562 pcmbuf_update_frequency(); 2564 pcmbuf_update_frequency();
2563 2565
2564 /* Be sure channel is audible */ 2566 /* Be sure channel is audible */
@@ -3628,6 +3630,12 @@ void playback_release_aa_slot(int slot)
3628 aa_slot->used--; 3630 aa_slot->used--;
3629 } 3631 }
3630} 3632}
3633
3634void playback_update_aa_dims(void)
3635{
3636 LOGFQUEUE("audio >| audio Q_AUDIO_REMAKE_AUDIO_BUFFER");
3637 audio_queue_send(Q_AUDIO_REMAKE_AUDIO_BUFFER, 0);
3638}
3631#endif /* HAVE_ALBUMART */ 3639#endif /* HAVE_ALBUMART */
3632 3640
3633/* Return file byte offset */ 3641/* Return file byte offset */
@@ -3702,6 +3710,26 @@ void audio_set_crossfade(int enable)
3702} 3710}
3703#endif /* HAVE_CROSSFADE */ 3711#endif /* HAVE_CROSSFADE */
3704 3712
3713#ifdef HAVE_PLAY_FREQ
3714void audio_set_playback_frequency(int setting)
3715{
3716 static const unsigned long play_sampr[] = { SAMPR_44, SAMPR_48 };
3717
3718 if ((unsigned)setting >= ARRAYLEN(play_sampr))
3719 setting = 0;
3720
3721 unsigned long playback_sampr = mixer_get_frequency();
3722 unsigned long sampr = play_sampr[setting];
3723
3724 if (sampr != playback_sampr)
3725 {
3726 mixer_set_frequency(sampr);
3727 LOGFQUEUE("audio >| audio Q_AUDIO_REMAKE_AUDIO_BUFFER");
3728 audio_queue_send(Q_AUDIO_REMAKE_AUDIO_BUFFER, 0);
3729 }
3730}
3731#endif /* HAVE_PLAY_FREQ */
3732
3705unsigned int playback_status(void) 3733unsigned int playback_status(void)
3706{ 3734{
3707 return play_status; 3735 return play_status;
diff --git a/apps/playback.h b/apps/playback.h
index 177768ded3..8a63bd7907 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -62,12 +62,18 @@ int playback_claim_aa_slot(struct dim *dim);
62 * Save to call from other threads */ 62 * Save to call from other threads */
63void playback_release_aa_slot(int slot); 63void playback_release_aa_slot(int slot);
64 64
65/*
66 * Tells playback to sync buffered album art dimensions
67 *
68 * Save to call from other threads */
69void playback_update_aa_dims(void);
70
65struct bufopen_bitmap_data { 71struct bufopen_bitmap_data {
66 struct dim *dim; 72 struct dim *dim;
67 struct mp3_albumart *embedded_albumart; 73 struct mp3_albumart *embedded_albumart;
68}; 74};
69 75
70#endif 76#endif /* HAVE_ALBUMART */
71 77
72/* Functions */ 78/* Functions */
73int audio_track_count(void); 79int audio_track_count(void);
@@ -79,6 +85,9 @@ void audio_set_cuesheet(bool enable);
79#ifdef HAVE_CROSSFADE 85#ifdef HAVE_CROSSFADE
80void audio_set_crossfade(int enable); 86void audio_set_crossfade(int enable);
81#endif 87#endif
88#ifdef HAVE_PLAY_FREQ
89void audio_set_playback_frequency(int setting);
90#endif
82 91
83size_t audio_get_filebuflen(void); 92size_t audio_get_filebuflen(void);
84 93
diff --git a/apps/settings.c b/apps/settings.c
index aa51e051e9..8afec9f806 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -87,10 +87,6 @@ struct system_status global_status;
87#include "enc_config.h" 87#include "enc_config.h"
88#endif 88#endif
89#include "pcm_sampr.h" 89#include "pcm_sampr.h"
90#ifdef HAVE_PLAY_FREQ
91#include "pcm_mixer.h"
92#include "dsp_core.h"
93#endif
94#endif /* CONFIG_CODEC == SWCODEC */ 90#endif /* CONFIG_CODEC == SWCODEC */
95 91
96#define NVRAM_BLOCK_SIZE 44 92#define NVRAM_BLOCK_SIZE 44
@@ -735,41 +731,6 @@ void settings_apply_pm_range(void)
735} 731}
736#endif /* HAVE_LCD_BITMAP */ 732#endif /* HAVE_LCD_BITMAP */
737 733
738#ifdef HAVE_PLAY_FREQ
739void settings_apply_play_freq(int value, bool playback)
740{
741 static const unsigned long play_sampr[] = { SAMPR_44, SAMPR_48 };
742 static int prev_setting = 0;
743
744 if ((unsigned)value >= ARRAYLEN(play_sampr))
745 value = 0;
746
747 bool changed = value != prev_setting;
748 prev_setting = value;
749
750 unsigned long elapsed = 0;
751 unsigned long offset = 0;
752 bool playing = changed && !playback &&
753 audio_status() == AUDIO_STATUS_PLAY;
754
755 if (playing)
756 {
757 struct mp3entry *id3 = audio_current_track();
758 elapsed = id3->elapsed;
759 offset = id3->offset;
760 }
761
762 if (changed && !playback)
763 audio_hard_stop();
764
765 /* Other sub-areas of playback pick it up from the mixer */
766 mixer_set_frequency(play_sampr[value]);
767
768 if (playing)
769 audio_play(elapsed, offset);
770}
771#endif /* HAVE_PLAY_FREQ */
772
773void sound_settings_apply(void) 734void sound_settings_apply(void)
774{ 735{
775#ifdef AUDIOHW_HAVE_BASS 736#ifdef AUDIOHW_HAVE_BASS
@@ -1023,10 +984,11 @@ void settings_apply(bool read_disk)
1023 lcd_scroll_delay(global_settings.scroll_delay); 984 lcd_scroll_delay(global_settings.scroll_delay);
1024 985
1025 986
987#if CONFIG_CODEC == SWCODEC
1026#ifdef HAVE_PLAY_FREQ 988#ifdef HAVE_PLAY_FREQ
1027 settings_apply_play_freq(global_settings.play_frequency, false); 989 /* before crossfade */
990 audio_set_playback_frequency(global_settings.play_frequency);
1028#endif 991#endif
1029#if CONFIG_CODEC == SWCODEC
1030#ifdef HAVE_CROSSFADE 992#ifdef HAVE_CROSSFADE
1031 audio_set_crossfade(global_settings.crossfade); 993 audio_set_crossfade(global_settings.crossfade);
1032#endif 994#endif
diff --git a/apps/settings.h b/apps/settings.h
index 5de65bb193..71233d904a 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -224,9 +224,6 @@ void settings_apply_skins(void);
224 224
225void settings_apply(bool read_disk); 225void settings_apply(bool read_disk);
226void settings_apply_pm_range(void); 226void settings_apply_pm_range(void);
227#ifdef HAVE_PLAY_FREQ
228void settings_apply_play_freq(int value, bool playback);
229#endif
230void settings_display(void); 227void settings_display(void);
231 228
232enum optiontype { INT, BOOL }; 229enum optiontype { INT, BOOL };