Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+51 -64
+6 -15
apps/gui/skin_engine/skin_parser.c
··· 2533 2533 } 2534 2534 #endif 2535 2535 #if defined(HAVE_ALBUMART) && !defined(__PCTOOL__) 2536 - int status = audio_status(); 2537 - if (status & AUDIO_STATUS_PLAY) 2536 + /* last_albumart_{width,height} is either both 0 or valid AA dimensions */ 2537 + struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart); 2538 + if (aa && (aa->state != WPS_ALBUMART_NONE || 2539 + (((wps_data->last_albumart_height != aa->height) || 2540 + (wps_data->last_albumart_width != aa->width))))) 2538 2541 { 2539 - /* last_albumart_{width,height} is either both 0 or valid AA dimensions */ 2540 - struct skin_albumart *aa = SKINOFFSETTOPTR(skin_buffer, wps_data->albumart); 2541 - if (aa && (aa->state != WPS_ALBUMART_NONE || 2542 - (((wps_data->last_albumart_height != aa->height) || 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 - } 2542 + playback_update_aa_dims(); 2552 2543 } 2553 2544 #endif 2554 2545 #ifndef __PCTOOL__
+1 -1
apps/menus/playback_menu.c
··· 258 258 #ifdef HAVE_PLAY_FREQ 259 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 262 break; 263 263 } 264 264 #endif /* HAVE_PLAY_FREQ */
+31 -3
apps/playback.c
··· 52 52 #endif 53 53 #endif 54 54 55 + #ifdef HAVE_PLAY_FREQ 56 + #include "pcm_mixer.h" 57 + #endif 58 + 55 59 /* TODO: The audio thread really is doing multitasking of acting like a 56 60 consumer and producer of tracks. It may be advantageous to better 57 61 logically separate the two functions. I won't go that far just yet. */ ··· 2523 2527 resume.elapsed = id3_get(PLAYING_ID3)->elapsed; 2524 2528 resume.offset = id3_get(PLAYING_ID3)->offset; 2525 2529 track_list_clear(TRACK_LIST_CLEAR_ALL); 2530 + pcmbuf_update_frequency(); 2526 2531 } 2527 2532 else 2528 2533 { ··· 2555 2560 #endif 2556 2561 #ifndef PLATFORM_HAS_VOLUME_CHANGE 2557 2562 sound_set_volume(global_settings.volume); 2558 - #endif 2559 - #ifdef HAVE_PLAY_FREQ 2560 - settings_apply_play_freq(global_settings.play_frequency, true); 2561 2563 #endif 2562 2564 pcmbuf_update_frequency(); 2563 2565 ··· 3628 3630 aa_slot->used--; 3629 3631 } 3630 3632 } 3633 + 3634 + void 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 3639 #endif /* HAVE_ALBUMART */ 3632 3640 3633 3641 /* Return file byte offset */ ··· 3701 3709 } 3702 3710 } 3703 3711 #endif /* HAVE_CROSSFADE */ 3712 + 3713 + #ifdef HAVE_PLAY_FREQ 3714 + void 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 */ 3704 3732 3705 3733 unsigned int playback_status(void) 3706 3734 {
+10 -1
apps/playback.h
··· 62 62 * Save to call from other threads */ 63 63 void 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 */ 69 + void playback_update_aa_dims(void); 70 + 65 71 struct bufopen_bitmap_data { 66 72 struct dim *dim; 67 73 struct mp3_albumart *embedded_albumart; 68 74 }; 69 75 70 - #endif 76 + #endif /* HAVE_ALBUMART */ 71 77 72 78 /* Functions */ 73 79 int audio_track_count(void); ··· 78 84 void audio_set_cuesheet(bool enable); 79 85 #ifdef HAVE_CROSSFADE 80 86 void audio_set_crossfade(int enable); 87 + #endif 88 + #ifdef HAVE_PLAY_FREQ 89 + void audio_set_playback_frequency(int setting); 81 90 #endif 82 91 83 92 size_t audio_get_filebuflen(void);
+3 -41
apps/settings.c
··· 87 87 #include "enc_config.h" 88 88 #endif 89 89 #include "pcm_sampr.h" 90 - #ifdef HAVE_PLAY_FREQ 91 - #include "pcm_mixer.h" 92 - #include "dsp_core.h" 93 - #endif 94 90 #endif /* CONFIG_CODEC == SWCODEC */ 95 91 96 92 #define NVRAM_BLOCK_SIZE 44 ··· 735 731 } 736 732 #endif /* HAVE_LCD_BITMAP */ 737 733 738 - #ifdef HAVE_PLAY_FREQ 739 - void 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 - 773 734 void sound_settings_apply(void) 774 735 { 775 736 #ifdef AUDIOHW_HAVE_BASS ··· 1023 984 lcd_scroll_delay(global_settings.scroll_delay); 1024 985 1025 986 987 + #if CONFIG_CODEC == SWCODEC 1026 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 991 #endif 1029 - #if CONFIG_CODEC == SWCODEC 1030 992 #ifdef HAVE_CROSSFADE 1031 993 audio_set_crossfade(global_settings.crossfade); 1032 994 #endif
-3
apps/settings.h
··· 224 224 225 225 void settings_apply(bool read_disk); 226 226 void settings_apply_pm_range(void); 227 - #ifdef HAVE_PLAY_FREQ 228 - void settings_apply_play_freq(int value, bool playback); 229 - #endif 230 227 void settings_display(void); 231 228 232 229 enum optiontype { INT, BOOL };