/* Initialize the audio system - called from init() in main.c */ void INIT_ATTR audio_init(void) { /* Can never do this twice */ if (audio_is_initialized) { logf("audio: already initialized"); return; } logf("audio: initializing"); /* Initialize queues before giving control elsewhere in case it likes to send messages. Thread creation will be delayed however so nothing starts running until ready if something yields such as talk_init. */ queue_init(&audio_queue, true); codec_thread_init(); /* This thread does buffer, so match its priority */ audio_thread_id = create_thread(audio_thread, audio_stack, sizeof(audio_stack), 0, audio_thread_name IF_PRIO(, MIN(PRIORITY_BUFFERING, PRIORITY_USER_INTERFACE)) IF_COP(, CPU)); queue_enable_queue_send(&audio_queue, &audio_queue_sender_list, audio_thread_id); playback_init(); #ifdef AUDIO_HAVE_RECORDING recording_init(); #endif /* Probably safe to say */ audio_is_initialized = true; sound_settings_apply(); }
void radio_screen(void) { bool done = false; int button; bool stereo = false, last_stereo = false; int update_type = 0; bool screen_freeze = false; bool keep_playing = false; bool talk = false; #ifdef FM_RECORD_DBLPRE int lastbutton = BUTTON_NONE; unsigned long rec_lastclick = 0; #endif #if CONFIG_CODEC != SWCODEC int timeout = current_tick + HZ/10; #if !defined(SIMULATOR) unsigned int last_seconds = 0; unsigned int seconds = 0; struct audio_recording_options rec_options; #endif /* SIMULATOR */ #endif /* CONFIG_CODEC != SWCODEC */ #ifndef HAVE_NOISY_IDLE_MODE int button_timeout = current_tick + (2*HZ); #endif /* change status to "in screen" */ push_current_activity(ACTIVITY_FM); in_screen = true; if(radio_preset_count() <= 0) { radio_load_presets(global_settings.fmr_file); } skin_get_global_state()->id3 = NULL; #ifdef HAVE_ALBUMART radioart_init(true); #endif if(radio_status == FMRADIO_OFF) audio_stop(); fms_fix_displays(FMS_ENTER); #ifndef SIMULATOR #if CONFIG_CODEC != SWCODEC rec_create_directory(); audio_init_recording(); sound_settings_apply(); /* Yes, we use the D/A for monitoring */ peak_meter_playback(true); peak_meter_enable(true); rec_init_recording_options(&rec_options); rec_options.rec_source = AUDIO_SRC_LINEIN; rec_set_recording_options(&rec_options); audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN), sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); #endif /* CONFIG_CODEC != SWCODEC */ #endif /* ndef SIMULATOR */ /* turn on radio */ #if CONFIG_CODEC == SWCODEC /* This should be done before touching audio settings */ while (!pcm_is_initialized()) sleep(0); audio_set_input_source(AUDIO_SRC_FMRADIO, (radio_status == FMRADIO_PAUSED) ? SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); #else if (radio_status == FMRADIO_OFF) radio_start(); #endif if(radio_preset_count() < 1 && yesno_pop(ID2P(LANG_FM_FIRST_AUTOSCAN))) presets_scan(NULL); preset_set_current(preset_find(curr_freq)); if(radio_current_preset() != -1) radio_mode = RADIO_PRESET_MODE; /* Load/update the skin at last, when fully initialzed, so that it can * display the right content from the beginning */ FOR_NB_SCREENS(i) skin_update(FM_SCREEN, i, SKIN_REFRESH_ALL); #ifndef HAVE_NOISY_IDLE_MODE cpu_idle_mode(true); #endif while(!done) { if(search_dir != 0) { curr_freq = step_freq(curr_freq, search_dir); update_type = SKIN_REFRESH_ALL; if(tuner_set(RADIO_SCAN_FREQUENCY, curr_freq)) { preset_set_current(preset_find(curr_freq)); remember_frequency(); end_search(); talk = true; } trigger_cpu_boost(); } if (!update_type) { cancel_cpu_boost(); } button = fms_do_button_loop(update_type>0); #ifndef HAVE_NOISY_IDLE_MODE if (button != ACTION_NONE) { cpu_idle_mode(false); button_timeout = current_tick + (2*HZ); } #endif switch(button) { case ACTION_FM_STOP: #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR) if(audio_status() == AUDIO_STATUS_RECORD) { audio_stop(); } else #endif { done = true; if(presets_have_changed()) { if(yesno_pop(ID2P(LANG_SAVE_CHANGES))) { presets_save(); } } } update_type = SKIN_REFRESH_NON_STATIC; break; #ifdef FM_RECORD case ACTION_FM_RECORD: #ifdef FM_RECORD_DBLPRE if (lastbutton != ACTION_FM_RECORD_DBLPRE) { rec_lastclick = 0; break; } if (current_tick - rec_lastclick > HZ/2) { rec_lastclick = current_tick; break; } #endif /* FM_RECORD_DBLPRE */ #ifndef SIMULATOR if(audio_status() == AUDIO_STATUS_RECORD) { rec_command(RECORDING_CMD_START_NEWFILE); update_type = SKIN_REFRESH_ALL; } else { rec_command(RECORDING_CMD_START); update_type = SKIN_REFRESH_ALL; } #if CONFIG_CODEC != SWCODEC last_seconds = 0; #endif #endif /* SIMULATOR */ break; #endif /* #ifdef FM_RECORD */ case ACTION_FM_EXIT: #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR) if(audio_status() == AUDIO_STATUS_RECORD) audio_stop(); #endif keep_playing = true; done = true; if(presets_have_changed()) { if(yesno_pop(ID2P(LANG_SAVE_CHANGES))) { presets_save(); } } break; case ACTION_STD_PREV: case ACTION_STD_NEXT: next_station(button == ACTION_STD_PREV ? -1 : 1); end_search(); update_type = SKIN_REFRESH_ALL; talk = true; break; case ACTION_STD_PREVREPEAT: case ACTION_STD_NEXTREPEAT: { int dir = search_dir; search_dir = button == ACTION_STD_PREVREPEAT ? -1 : 1; if (radio_mode != RADIO_SCAN_MODE) { preset_next(search_dir); end_search(); talk = true; } else if (dir == 0) { /* Starting auto scan */ tuner_set(RADIO_MUTE, 1); } update_type = SKIN_REFRESH_ALL; break; } case ACTION_SETTINGS_INC: case ACTION_SETTINGS_INCREPEAT: global_settings.volume++; setvol(); update_type = SKIN_REFRESH_NON_STATIC; break; case ACTION_SETTINGS_DEC: case ACTION_SETTINGS_DECREPEAT: global_settings.volume--; setvol(); update_type = SKIN_REFRESH_NON_STATIC; break; case ACTION_FM_PLAY: if (radio_status == FMRADIO_PLAYING) radio_pause(); else radio_start(); update_type = SKIN_REFRESH_NON_STATIC; talk = false; talk_shutup(); break; case ACTION_FM_MENU: fms_fix_displays(FMS_EXIT); do_menu(&radio_settings_menu, NULL, NULL, false); preset_set_current(preset_find(curr_freq)); fms_fix_displays(FMS_ENTER); update_type = SKIN_REFRESH_ALL; break; #ifdef FM_PRESET case ACTION_FM_PRESET: if(radio_preset_count() < 1) { splash(HZ, ID2P(LANG_FM_NO_PRESETS)); update_type = SKIN_REFRESH_ALL; break; } fms_fix_displays(FMS_EXIT); handle_radio_presets(); fms_fix_displays(FMS_ENTER); update_type = SKIN_REFRESH_ALL; break; #endif /* FM_PRESET */ #ifdef FM_FREEZE case ACTION_FM_FREEZE: if(!screen_freeze) { splash(HZ, str(LANG_FM_FREEZE)); screen_freeze = true; } else { update_type = SKIN_REFRESH_ALL; screen_freeze = false; } break; #endif /* FM_FREEZE */ case SYS_USB_CONNECTED: #if CONFIG_CODEC != SWCODEC /* Only accept USB connection when not recording */ if(audio_status() != AUDIO_STATUS_RECORD) #endif { default_event_handler(SYS_USB_CONNECTED); screen_freeze = true; /* Cosmetic: makes sure the radio screen doesn't redraw */ done = true; } break; #ifdef FM_MODE case ACTION_FM_MODE: if(radio_mode == RADIO_SCAN_MODE) { /* Force scan mode if there are no presets. */ if(radio_preset_count() > 0) radio_mode = RADIO_PRESET_MODE; } else radio_mode = RADIO_SCAN_MODE; update_type = SKIN_REFRESH_ALL; cond_talk_ids_fq(radio_mode ? LANG_PRESET : LANG_RADIO_SCAN_MODE); talk = true; break; #endif /* FM_MODE */ #ifdef FM_NEXT_PRESET case ACTION_FM_NEXT_PRESET: preset_next(1); end_search(); update_type = SKIN_REFRESH_ALL; talk = true; break; #endif #ifdef FM_PREV_PRESET case ACTION_FM_PREV_PRESET: preset_next(-1); end_search(); update_type = SKIN_REFRESH_ALL; talk = true; break; #endif case ACTION_NONE: update_type = SKIN_REFRESH_NON_STATIC; break; /* this case is used by the softlock feature * it requests a full update here */ case ACTION_REDRAW: skin_request_full_update(FM_SCREEN); break; default: default_event_handler(button); #ifdef HAVE_RDS_CAP if (tuner_get(RADIO_EVENT)) update_type = SKIN_REFRESH_ALL; #endif if (!tuner_get(RADIO_PRESENT)) { #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR) if(audio_status() == AUDIO_STATUS_RECORD) audio_stop(); #endif keep_playing = false; done = true; if(presets_have_changed()) { if(yesno_pop(ID2P(LANG_SAVE_CHANGES))) { radio_save_presets(); } } /* Clear the preset list on exit. */ preset_list_clear(); } break; } /*switch(button)*/ #ifdef FM_RECORD_DBLPRE if (button != ACTION_NONE) lastbutton = button; #endif #if CONFIG_CODEC != SWCODEC peak_meter_peek(); #endif if(!screen_freeze) { /* Only display the peak meter when not recording */ #if CONFIG_CODEC != SWCODEC if(TIME_AFTER(current_tick, timeout)) { timeout = current_tick + HZ; #else /* SWCODEC */ { #endif /* CONFIG_CODEC == SWCODEC */ /* keep "mono" from always being displayed when paused */ if (radio_status != FMRADIO_PAUSED) { stereo = tuner_get(RADIO_STEREO) && !global_settings.fm_force_mono; if(stereo != last_stereo) { update_type = SKIN_REFRESH_ALL; last_stereo = stereo; } } } #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR) seconds = audio_recorded_time() / HZ; if (update_type || seconds > last_seconds) { last_seconds = seconds; #else if (update_type) { #endif FOR_NB_SCREENS(i) skin_update(FM_SCREEN, i, update_type); if (update_type == (int)SKIN_REFRESH_ALL) skin_request_full_update(CUSTOM_STATUSBAR); } } update_type = 0; if (global_settings.talk_file && talk && radio_status == FMRADIO_PAUSED) { talk = false; bool enqueue = false; if (radio_mode == RADIO_SCAN_MODE) { talk_value_decimal(curr_freq, UNIT_INT, 6, enqueue); enqueue = true; } if (radio_current_preset() >= 0) preset_talk(radio_current_preset(), radio_mode == RADIO_PRESET_MODE, enqueue); } #if CONFIG_CODEC != SWCODEC if(audio_status() & AUDIO_STATUS_ERROR) { done = true; } #endif #ifndef HAVE_NOISY_IDLE_MODE if (TIME_AFTER(current_tick, button_timeout)) { cpu_idle_mode(true); } #endif } /*while(!done)*/ #ifndef SIMULATOR #if CONFIG_CODEC != SWCODEC if(audio_status() & AUDIO_STATUS_ERROR) { splash(0, str(LANG_DISK_FULL)); audio_error_clear(); while(1) { button = get_action(CONTEXT_FM|ALLOW_SOFTLOCK, TIMEOUT_BLOCK); if(button == ACTION_FM_STOP) break; } } audio_init_playback(); #endif /* CONFIG_CODEC != SWCODEC */ sound_settings_apply(); #endif /* SIMULATOR */ if(keep_playing) { /* Catch FMRADIO_PLAYING status for the sim. */ #ifndef SIMULATOR #if CONFIG_CODEC != SWCODEC /* Enable the Left and right A/D Converter */ audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN), sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); mas_codec_writereg(6, 0x4000); #endif end_search(); #endif /* SIMULATOR */ } else { #if CONFIG_CODEC == SWCODEC audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); #else radio_stop(); #endif } #ifndef HAVE_NOISY_IDLE_MODE cpu_idle_mode(false); #endif fms_fix_displays(FMS_EXIT); pop_current_activity(); in_screen = false; } /* radio_screen */ void toggle_mono_mode(bool mono) { tuner_set(RADIO_FORCE_MONO, mono); } void set_radio_region(int region) { #ifdef HAVE_RADIO_REGION tuner_set(RADIO_REGION, region); #endif next_station(0); remember_frequency(); (void)region; }
void settings_apply(bool read_disk) { char buf[64]; #if CONFIG_CODEC == SWCODEC int i; #endif sound_settings_apply(); #ifdef HAVE_DISK_STORAGE audio_set_buffer_margin(global_settings.buffer_margin); #endif #ifdef HAVE_LCD_CONTRAST lcd_set_contrast(global_settings.contrast); #endif lcd_scroll_speed(global_settings.scroll_speed); #ifdef HAVE_REMOTE_LCD lcd_remote_set_contrast(global_settings.remote_contrast); lcd_remote_set_invert_display(global_settings.remote_invert); #ifdef HAVE_LCD_FLIP lcd_remote_set_flip(global_settings.remote_flip_display); #endif lcd_remote_scroll_speed(global_settings.remote_scroll_speed); lcd_remote_scroll_step(global_settings.remote_scroll_step); lcd_remote_scroll_delay(global_settings.remote_scroll_delay); lcd_remote_bidir_scroll(global_settings.remote_bidir_limit); #ifdef HAVE_REMOTE_LCD_TICKING lcd_remote_emireduce(global_settings.remote_reduce_ticking); #endif remote_backlight_set_timeout(global_settings.remote_backlight_timeout); #if CONFIG_CHARGING remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); #endif #ifdef HAS_REMOTE_BUTTON_HOLD remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold); #endif #endif /* HAVE_REMOTE_LCD */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS backlight_set_brightness(global_settings.brightness); #endif #ifdef HAVE_BACKLIGHT backlight_set_timeout(global_settings.backlight_timeout); #if CONFIG_CHARGING backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); #endif #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \ || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING) backlight_set_fade_in(global_settings.backlight_fade_in); backlight_set_fade_out(global_settings.backlight_fade_out); #endif #endif #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS buttonlight_set_brightness(global_settings.buttonlight_brightness); #endif #ifdef HAVE_BUTTON_LIGHT buttonlight_set_timeout(global_settings.buttonlight_timeout); #endif #ifdef HAVE_DISK_STORAGE storage_spindown(global_settings.disk_spindown); #endif #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) dac_line_in(global_settings.line_in); #endif set_poweroff_timeout(global_settings.poweroff); set_battery_capacity(global_settings.battery_capacity); #if BATTERY_TYPES_COUNT > 1 set_battery_type(global_settings.battery_type); #endif #ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_INVERT lcd_set_invert_display(global_settings.invert); #endif #ifdef HAVE_LCD_FLIP lcd_set_flip(global_settings.flip_display); button_set_flip(global_settings.flip_display); #endif lcd_update(); /* refresh after flipping the screen */ settings_apply_pm_range(); peak_meter_init_times( global_settings.peak_meter_release, global_settings.peak_meter_hold, global_settings.peak_meter_clip_hold); #endif #ifdef HAVE_SPEAKER audiohw_enable_speaker(global_settings.speaker_enabled); #endif if (read_disk) { #ifdef HAVE_LCD_BITMAP /* fonts need to be loaded before the WPS */ if ( global_settings.font_file[0]) { snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); if (font_load(NULL, buf) < 0) font_reset(NULL); } else font_reset(NULL); #ifdef HAVE_REMOTE_LCD if ( global_settings.remote_font_file[0]) { snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.remote_font_file); if (font_load_remoteui(buf) < 0) font_load_remoteui(NULL); } else font_load_remoteui(NULL); #endif if ( global_settings.kbd_file[0]) { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", global_settings.kbd_file); load_kbd(buf); } else load_kbd(NULL); #endif if ( global_settings.lang_file[0]) { snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", global_settings.lang_file); lang_core_load(buf); talk_init(); /* use voice of same language */ } /* reload wpses */ settings_apply_skins(); /* load the icon set */ icons_init(); #ifdef HAVE_LCD_COLOR if (global_settings.colors_file[0]) read_color_theme_file(); #endif } #ifdef HAVE_LCD_COLOR screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); screens[SCREEN_MAIN].set_background(global_settings.bg_color); screens[SCREEN_MAIN].set_selector_start(global_settings.lss_color); screens[SCREEN_MAIN].set_selector_end(global_settings.lse_color); screens[SCREEN_MAIN].set_selector_text(global_settings.lst_color); #endif #ifdef HAVE_LCD_BITMAP lcd_scroll_step(global_settings.scroll_step); gui_list_screen_scroll_step(global_settings.screen_scroll_step); gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view); #else lcd_jump_scroll(global_settings.jump_scroll); lcd_jump_scroll_delay(global_settings.jump_scroll_delay); #endif lcd_bidir_scroll(global_settings.bidir_limit); lcd_scroll_delay(global_settings.scroll_delay); set_codepage(global_settings.default_codepage); #if CONFIG_CODEC == SWCODEC #ifdef HAVE_CROSSFADE audio_set_crossfade(global_settings.crossfade); #endif dsp_set_replaygain(); dsp_set_crossfeed(global_settings.crossfeed); dsp_set_crossfeed_direct_gain(global_settings.crossfeed_direct_gain); dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, global_settings.crossfeed_hf_attenuation, global_settings.crossfeed_hf_cutoff); /* Configure software equalizer, hardware eq is handled in audio_init() */ dsp_set_eq(global_settings.eq_enabled); dsp_set_eq_precut(global_settings.eq_precut); for(i = 0; i < 5; i++) { dsp_set_eq_coefs(i); } dsp_dither_enable(global_settings.dithering_enabled); dsp_timestretch_enable(global_settings.timestretch_enabled); dsp_set_compressor(global_settings.compressor_threshold, global_settings.compressor_makeup_gain, global_settings.compressor_ratio, global_settings.compressor_knee, global_settings.compressor_release_time); #endif #ifdef HAVE_SPDIF_POWER spdif_power_enable(global_settings.spdif_enable); #endif #ifdef HAVE_BACKLIGHT set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); #ifdef HAVE_REMOTE_LCD set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); #endif #ifdef HAS_BUTTON_HOLD backlight_set_on_button_hold(global_settings.backlight_on_button_hold); #endif #ifdef HAVE_LCD_SLEEP_SETTING lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); #endif #endif /* HAVE_BACKLIGHT */ #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING touchpad_set_sensitivity(global_settings.touchpad_sensitivity); #endif #ifdef HAVE_USB_CHARGING_ENABLE usb_charging_enable(global_settings.usb_charging); #endif #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(global_settings.touch_mode); memcpy(&calibration_parameters, &global_settings.ts_calibration_data, sizeof(struct touchscreen_parameter)); #endif /* This should stay last */ #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_apply(); #endif #ifdef HAVE_LCD_BITMAP /* already called with THEME_STATUSBAR in settings_apply_skins() */ viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE); #endif }
void settings_apply(bool read_disk) { #ifdef HAVE_LCD_BITMAP int rc; #endif CHART(">set_codepage"); set_codepage(global_settings.default_codepage); CHART("<set_codepage"); sound_settings_apply(); #ifdef HAVE_DISK_STORAGE audio_set_buffer_margin(global_settings.buffer_margin); #endif #ifdef HAVE_LCD_CONTRAST lcd_set_contrast(global_settings.contrast); #endif lcd_scroll_speed(global_settings.scroll_speed); #ifdef HAVE_REMOTE_LCD lcd_remote_set_contrast(global_settings.remote_contrast); lcd_remote_set_invert_display(global_settings.remote_invert); #ifdef HAVE_LCD_FLIP lcd_remote_set_flip(global_settings.remote_flip_display); #endif lcd_remote_scroll_speed(global_settings.remote_scroll_speed); lcd_remote_scroll_step(global_settings.remote_scroll_step); lcd_remote_scroll_delay(global_settings.remote_scroll_delay); lcd_remote_bidir_scroll(global_settings.remote_bidir_limit); #ifdef HAVE_REMOTE_LCD_TICKING lcd_remote_emireduce(global_settings.remote_reduce_ticking); #endif remote_backlight_set_timeout(global_settings.remote_backlight_timeout); #if CONFIG_CHARGING remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); #endif #ifdef HAS_REMOTE_BUTTON_HOLD remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold); #endif #endif /* HAVE_REMOTE_LCD */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS backlight_set_brightness(global_settings.brightness); #endif #ifdef HAVE_BACKLIGHT backlight_set_timeout(global_settings.backlight_timeout); #if CONFIG_CHARGING backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); #endif #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \ || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING) backlight_set_fade_in(global_settings.backlight_fade_in); backlight_set_fade_out(global_settings.backlight_fade_out); #endif #endif #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS buttonlight_set_brightness(global_settings.buttonlight_brightness); #endif #ifdef HAVE_BUTTON_LIGHT buttonlight_set_timeout(global_settings.buttonlight_timeout); #endif #ifdef HAVE_DISK_STORAGE storage_spindown(global_settings.disk_spindown); #endif #if (CONFIG_CODEC == MAS3507D) && (CONFIG_PLATFORM & PLATFORM_NATIVE) dac_line_in(global_settings.line_in); #endif set_poweroff_timeout(global_settings.poweroff); if (global_settings.sleeptimer_on_startup) set_sleeptimer_duration(global_settings.sleeptimer_duration); set_keypress_restarts_sleep_timer( global_settings.keypress_restarts_sleeptimer); #if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0 /* only call if it's really exchangable */ set_battery_capacity(global_settings.battery_capacity); #endif #if BATTERY_TYPES_COUNT > 1 set_battery_type(global_settings.battery_type); #endif #ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_INVERT lcd_set_invert_display(global_settings.invert); #endif #ifdef HAVE_LCD_FLIP lcd_set_flip(global_settings.flip_display); button_set_flip(global_settings.flip_display); #endif lcd_update(); /* refresh after flipping the screen */ settings_apply_pm_range(); peak_meter_init_times( global_settings.peak_meter_release, global_settings.peak_meter_hold, global_settings.peak_meter_clip_hold); #endif #ifdef HAVE_SPEAKER audiohw_enable_speaker(global_settings.speaker_enabled); #endif if (read_disk) { char buf[MAX_PATH]; #ifdef HAVE_LCD_BITMAP /* fonts need to be loaded before the WPS */ if (global_settings.font_file[0] && global_settings.font_file[0] != '-') { int font_ui = screens[SCREEN_MAIN].getuifont(); const char* loaded_font = font_filename(font_ui); snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); if (!loaded_font || strcmp(loaded_font, buf)) { CHART2(">font_load ", global_settings.font_file); if (font_ui >= 0) font_unload(font_ui); rc = font_load_ex(buf, 0, global_settings.glyphs_to_cache); CHART2("<font_load ", global_settings.font_file); screens[SCREEN_MAIN].setuifont(rc); screens[SCREEN_MAIN].setfont(rc); } } #ifdef HAVE_REMOTE_LCD if ( global_settings.remote_font_file[0] && global_settings.remote_font_file[0] != '-') { int font_ui = screens[SCREEN_REMOTE].getuifont(); const char* loaded_font = font_filename(font_ui); snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.remote_font_file); if (!loaded_font || strcmp(loaded_font, buf)) { CHART2(">font_load_remoteui ", global_settings.remote_font_file); if (font_ui >= 0) font_unload(font_ui); rc = font_load(buf); CHART2("<font_load_remoteui ", global_settings.remote_font_file); screens[SCREEN_REMOTE].setuifont(rc); screens[SCREEN_REMOTE].setfont(rc); } } #endif if ( global_settings.kbd_file[0] && global_settings.kbd_file[0] != '-') { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", global_settings.kbd_file); CHART(">load_kbd"); load_kbd(buf); CHART("<load_kbd"); } else load_kbd(NULL); #endif /* HAVE_LCD_BITMAP */ if ( global_settings.lang_file[0]) { snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", global_settings.lang_file); CHART(">lang_core_load"); lang_core_load(buf); CHART("<lang_core_load"); } CHART(">talk_init"); talk_init(); /* use voice of same language */ CHART("<talk_init"); /* load the icon set */ CHART(">icons_init"); icons_init(); CHART("<icons_init"); #ifdef HAVE_LCD_COLOR if (global_settings.colors_file[0] && global_settings.colors_file[0] != '-') { CHART(">read_color_theme_file"); read_color_theme_file(); CHART("<read_color_theme_file"); } #endif } #ifdef HAVE_LCD_COLOR screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); screens[SCREEN_MAIN].set_background(global_settings.bg_color); #endif #ifdef HAVE_LCD_BITMAP lcd_scroll_step(global_settings.scroll_step); gui_list_screen_scroll_step(global_settings.screen_scroll_step); gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view); #endif lcd_bidir_scroll(global_settings.bidir_limit); 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 #ifdef HAVE_CROSSFADE audio_set_crossfade(global_settings.crossfade); #endif replaygain_update(); dsp_set_crossfeed_type(global_settings.crossfeed); dsp_set_crossfeed_direct_gain(global_settings.crossfeed_direct_gain); dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, global_settings.crossfeed_hf_attenuation, global_settings.crossfeed_hf_cutoff); /* Configure software equalizer, hardware eq is handled in audio_init() */ dsp_eq_enable(global_settings.eq_enabled); dsp_set_eq_precut(global_settings.eq_precut); for(int i = 0; i < EQ_NUM_BANDS; i++) { dsp_set_eq_coefs(i, &global_settings.eq_band_settings[i]); } dsp_dither_enable(global_settings.dithering_enabled); #ifdef HAVE_PITCHCONTROL dsp_timestretch_enable(global_settings.timestretch_enabled); #endif dsp_set_compressor(&global_settings.compressor_settings); #endif #ifdef HAVE_SPDIF_POWER spdif_power_enable(global_settings.spdif_enable); #endif #ifdef HAVE_BACKLIGHT set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); #ifdef HAVE_REMOTE_LCD set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); #endif #ifdef HAS_BUTTON_HOLD backlight_set_on_button_hold(global_settings.backlight_on_button_hold); #endif #ifdef HAVE_LCD_SLEEP_SETTING lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); #endif #endif /* HAVE_BACKLIGHT */ #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING touchpad_set_sensitivity(global_settings.touchpad_sensitivity); #endif #ifdef HAVE_TOUCHPAD_DEADZONE touchpad_set_deadzone(global_settings.touchpad_deadzone); #endif #ifdef HAVE_USB_CHARGING_ENABLE usb_charging_enable(global_settings.usb_charging); #endif #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(global_settings.touch_mode); memcpy(&calibration_parameters, &global_settings.ts_calibration_data, sizeof(struct touchscreen_parameter)); #endif /* This should stay last */ #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_apply(); #endif #ifdef HAVE_LCD_BITMAP /* already called with THEME_STATUSBAR in settings_apply_skins() */ CHART(">viewportmanager_theme_changed"); viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE|THEME_BUTTONBAR); CHART("<viewportmanager_theme_changed"); #endif }