int volume() { int ret, vol; char cmd[MAXLEN]; char buf[MAXLEN]=""; vol=getvol(); if(vol==-1) return -1; sprintf(cmd, "AT*EAID=4,1,\"Volume\",10,%d\r", (int) ((vol/10.0)+.5)); writeport(cmd, strlen(cmd)); if(waitfor("OK", 1, TIMEOUT) != 1) return -1; while(1) { while((ret = readport(buf, MAXLEN, TIMEOUT)) == -EINTR); if(ret <= 0) return -1; if(strncmp(buf, "*EAII: 15,",10)==0) setvol(atoi(buf+10)); if(strncmp(buf, "*EAII: 0", 8)==0 || strncmp(buf, "*EAAI", 5)==0) { setvol(vol); return 0; } if(strncmp(buf, "*EAII: 4,",9)==0) { setvol(atoi(buf+9)); return 1; } } }
static void st300_pulse (int param) { // param = 0x02 -> internal 6840 clock // param = 0 -> external 4049 clock // timpX is the output level of the 6840 (only 0 or 1) // decrase timers and update interface // missig is external clock for the 6840 timers if (((st300loc.cr1 & 0x02) == param) && (st300loc.cr1 & 0x80) && (st300loc.reset ==0)) { if (snddatst300.timer1 > 0) { snddatst300.timer1--; } if ((snddatst300.timer1 == 0) && (st300loc.timlat1 != 0)) { snddatst300.timer1 = st300loc.timlat1; if (st300loc.timlat1 != st300loc.timlats1) { playsam1(0); } st300loc.timlats1 = st300loc.timlat1; st300loc.timp1 = (st300loc.timp1 ? 0 : 1); } } if (((st300loc.cr2 & 0x02) == param) && (st300loc.cr2 & 0x80) && (st300loc.reset ==0)) { if (snddatst300.timer2 > 0) { snddatst300.timer2--; } if ((snddatst300.timer2 == 0) && (st300loc.timlat2 != 0)) { snddatst300.timer2 = st300loc.timlat2; if (st300loc.timlat2 != st300loc.timlats2) { playsam2(0); } st300loc.timlats2 = st300loc.timlat2; st300loc.timp2 = (st300loc.timp2 ? 0 : 1); } } if (((st300loc.cr3 & 0x02) == param) && (st300loc.cr3 & 0x80) && (st300loc.reset ==0)) { if (snddatst300.timer3 > 0) { snddatst300.timer3--; } if ((snddatst300.timer3 == 0) && (st300loc.timlat3 != 0)) { snddatst300.timer3 = st300loc.timlat3; st300loc.timp3 = (st300loc.timp3 ? 0 : 1); if (st300loc.timp3) { nextvol(0); if (setvol(0) == 0) { logerror("playsam Q2/EXT noise volume off \n"); } if (setvol(0) == 100) { logerror("playsam Q2/EXT noise volume maximum\n"); } mixer_set_volume(st300loc.channel,setvol(0)*ST300_VOL); mixer_set_volume(st300loc.channel+2,setvol(0)*ST300_VOL); } } } }
static void playsam3(int param) { // timer q3 from 6840 is used for volume controll if ((st300loc.cr3 & 0x80) && (st300loc.timlat3 > 0) && (st300loc.reset == 0)) { // output is enabled... startvol(0); if (setvol(0) == 0) { logerror("playsam Q2/Q3noise volume off \n"); } if (setvol(0) == 100) { logerror("playsam Q2/Q3noise volume maximum\n"); } mixer_set_volume(st300loc.channel,setvol(0)*ST300_VOL); mixer_set_volume(st300loc.channel+2,setvol(0)*ST300_VOL); } else { // q3 is not running... startvol(0); if (setvol(0) == 0) { logerror("playsam Q2/EXT noise volume off \n"); } if (setvol(0) == 100) { logerror("playsam q2/EXT noise volume maximum\n"); } mixer_set_volume(st300loc.channel,setvol(0)*ST300_VOL); mixer_set_volume(st300loc.channel+2,setvol(0)*ST300_VOL); } }
static int volume_limit_callback(int action,const struct menu_item_ex *this_item) { (void)this_item; static struct int_setting volume_limit_int_setting; volume_limit_int_setting.option_callback = NULL; volume_limit_int_setting.unit = UNIT_DB; volume_limit_int_setting.min = sound_min(SOUND_VOLUME); volume_limit_int_setting.max = sound_max(SOUND_VOLUME); volume_limit_int_setting.step = sound_steps(SOUND_VOLUME); volume_limit_int_setting.formatter = NULL; volume_limit_int_setting.get_talk_id = get_dec_talkid; struct settings_list setting; setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP; setting.lang_id = LANG_VOLUME_LIMIT; setting.default_val.int_ = sound_max(SOUND_VOLUME); setting.int_setting = &volume_limit_int_setting; switch (action) { case ACTION_ENTER_MENUITEM: setting.setting = &global_settings.volume_limit; option_screen(&setting, NULL, false, ID2P(LANG_VOLUME_LIMIT)); case ACTION_EXIT_MENUITEM: /* on exit */ setvol(); break; } return action; }
/** * This function is called before gdk/gtk can respond * to any(!) window event and handles pressed hotkeys. * * @param gdk_xevent the native event to filter * @param event the GDK event to which the X event will be translated * @param data user data set when the filter was installed * @return a GdkFilterReturn value, should be GDK_FILTER_CONTINUE only */ static GdkFilterReturn key_filter(GdkXEvent *gdk_xevent, G_GNUC_UNUSED GdkEvent *event, G_GNUC_UNUSED gpointer data) { int type; guint key, state; XKeyEvent *xevent; //gboolean bResult; xevent = gdk_xevent; type = xevent->type; if (type == KeyPress) { key = ((XKeyEvent *) xevent)->keycode; state = ((XKeyEvent *) xevent)->state; if ((int) key == volMuteKey && checkModKey(state, volMuteMods)) { setmute(enable_noti && hotkey_noti); on_volume_has_changed(); return GDK_FILTER_CONTINUE; } else { int cv = getvol(); if ((int) key == volUpKey && checkModKey(state, volUpMods)) { setvol(cv + volStep, 1, enable_noti && hotkey_noti); } else if ((int) key == volDownKey && checkModKey(state, volDownMods)) { setvol(cv - volStep, -1, enable_noti && hotkey_noti); } // just ignore unknown hotkeys if (ismuted() == 0) setmute(enable_noti && hotkey_noti); on_volume_has_changed(); // this will set the slider value get_current_levels(); } } return GDK_FILTER_CONTINUE; }
static GdkFilterReturn key_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { int type; unsigned int key,state; XKeyEvent *xevent; //gboolean bResult; xevent = gdk_xevent; type = xevent->type; if (type == KeyPress) { key = ((XKeyEvent *)xevent)->keycode; state = ((XKeyEvent *)xevent)->state; if (key == volMuteKey && state == volMuteMods) { setmute(enable_noti&&hotkey_noti); get_mute_state(TRUE); return GDK_FILTER_CONTINUE; } else { int cv = getvol(); if (key == volUpKey && state == volUpMods) { setvol(cv+volStep,enable_noti&&hotkey_noti); } else if (key == volDownKey && state == volDownMods) { setvol(cv-volStep,enable_noti&&hotkey_noti); } // just ignore unknown hotkeys if (get_mute_state(TRUE) == 0) setmute(enable_noti&&hotkey_noti); // this will set the slider value get_current_levels(); } } return GDK_FILTER_CONTINUE; }
void adsr() // handle ADSR for 64 voices { byte v; for (v = 0; v < 64; v++) { int d = target[v] - amp[v]; // +ve means need to increase if (d) { if (d > 0) amp[v] += 4; // attack else amp[v]--; // decay setvol(v, amp[v]); visualize(v, amp[v]); } } }
void incvol(const Arg *arg) { long min, max; snd_mixer_elem_t* elem = getelem(alsachannel); snd_mixer_selem_get_playback_volume_range(elem, &min, &max); int delta = (arg->i*(max-min))/100; long vol = getvol(elem); int newvol = vol+delta; if (newvol < min) newvol = min; if (newvol > max) newvol = max; setvol(newvol, elem); }
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; }
/* Get the touched action. * egde_offset is a percentage value for the position of the touch * inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type. */ int skin_get_touchaction(struct wps_data *data, int* edge_offset, struct touchregion **retregion) { int returncode = ACTION_NONE; short x,y; short vx, vy; int type = action_get_touchscreen_press(&x, &y); struct skin_viewport *wvp; struct touchregion *r, *temp = NULL; char* skin_buffer = get_skin_buffer(data); bool repeated = (type == BUTTON_REPEAT); bool released = (type == BUTTON_REL); bool pressed = (type == BUTTON_TOUCHSCREEN); struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions); bool needs_repeat; while (regions) { struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, regions->token); r = SKINOFFSETTOPTR(skin_buffer, token->value.data); wvp = SKINOFFSETTOPTR(skin_buffer, r->wvp); /* make sure this region's viewport is visible */ if (wvp->hidden_flags&VP_DRAW_HIDDEN) { regions = SKINOFFSETTOPTR(skin_buffer, regions->next); continue; } if (data->touchscreen_locked && (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked)) { regions = SKINOFFSETTOPTR(skin_buffer, regions->next); continue; } needs_repeat = r->press_length != PRESS; /* check if it's inside this viewport */ if (viewport_point_within_vp(&(wvp->vp), x, y)) { /* reposition the touch inside the viewport since touchregions * are relative to a preceding viewport */ vx = x - wvp->vp.x; vy = y - wvp->vp.y; /* now see if the point is inside this region */ if (vx >= r->x && vx < r->x+r->width && vy >= r->y && vy < r->y+r->height) { /* reposition the touch within the area */ vx -= r->x; vy -= r->y; switch(r->action) { case ACTION_TOUCH_SCROLLBAR: case ACTION_TOUCH_VOLUME: case ACTION_TOUCH_SETTING: if (edge_offset) { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, r->bar); if(r->width > r->height) *edge_offset = vx*100/r->width; else *edge_offset = vy*100/r->height; if (r->reverse_bar || (bar && bar->invert_fill_direction)) *edge_offset = 100 - *edge_offset; } temp = r; returncode = r->action; r->last_press = current_tick; break; default: if (r->armed && ((repeated && needs_repeat) || (released && !needs_repeat))) { returncode = r->action; temp = r; } if (pressed) { r->armed = true; r->last_press = current_tick; } break; } } } regions = SKINOFFSETTOPTR(skin_buffer, regions->next); } /* On release, all regions are disarmed. */ if (released) skin_disarm_touchregions(data); if (retregion && temp) *retregion = temp; if (temp && temp->press_length == LONG_PRESS) temp->armed = false; if (returncode != ACTION_NONE) { if (global_settings.party_mode) { switch (returncode) { case ACTION_WPS_PLAY: case ACTION_WPS_SKIPPREV: case ACTION_WPS_SKIPNEXT: case ACTION_WPS_STOP: returncode = ACTION_NONE; break; default: break; } } switch (returncode) { case ACTION_TOUCH_SOFTLOCK: data->touchscreen_locked = !data->touchscreen_locked; returncode = ACTION_NONE; break; case ACTION_WPS_PLAY: if (!audio_status()) { if ( global_status.resume_index != -1 ) { if (playlist_resume() != -1) { playlist_start(global_status.resume_index, global_status.resume_offset); } } else { splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); } } else { wps_do_playpause(false); } returncode = ACTION_REDRAW; break; case ACTION_WPS_SKIPPREV: audio_prev(); returncode = ACTION_REDRAW; break; case ACTION_WPS_SKIPNEXT: audio_next(); returncode = ACTION_REDRAW; break; case ACTION_WPS_STOP: audio_stop(); returncode = ACTION_REDRAW; break; case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { const struct settings_list *setting = temp->setting_data.setting; option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true); returncode = ACTION_REDRAW; } break; case ACTION_SETTINGS_SET: { struct touchsetting *data = &temp->setting_data; const struct settings_list *s = data->setting; void (*f)(int) = NULL; switch (s->flags&F_T_MASK) { case F_T_CUSTOM: s->custom_setting ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text)); break; case F_T_INT: case F_T_UINT: *(int*)s->setting = data->value.number; if ((s->flags & F_T_SOUND) == F_T_SOUND) sound_set(s->sound_setting->setting, data->value.number); else if (s->flags&F_CHOICE_SETTING) f = s->choice_setting->option_callback; else if (s->flags&F_TABLE_SETTING) f = s->table_setting->option_callback; else f = s->int_setting->option_callback; if (f) f(data->value.number); break; case F_T_BOOL: *(bool*)s->setting = data->value.number ? true : false; if (s->bool_setting->option_callback) s->bool_setting ->option_callback(data->value.number ? true : false); break; } returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_MUTE: { const int min_vol = sound_min(SOUND_VOLUME); if (global_settings.volume == min_vol) global_settings.volume = temp->value; else { temp->value = global_settings.volume; global_settings.volume = min_vol; } setvol(); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ { global_settings.playlist_shuffle = !global_settings.playlist_shuffle; replaygain_update(); if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ { const struct settings_list *rep_setting = find_setting(&global_settings.repeat_mode, NULL); option_select_next_val(rep_setting, false, true); audio_flush_and_reload_tracks(); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_SETTING: { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, temp->bar); if (bar && edge_offset) { int val, count; get_setting_info_for_bar(bar->setting_id, &count, &val); val = *edge_offset * count / 100; update_setting_value_from_touch(bar->setting_id, val); } } break; } return returncode; } return ACTION_TOUCHSCREEN; }
static int run(int cmd, char *arg) { long speed; int l, r, rc, count; switch (cmd) { case CMD_QUIT: exit (0); case CMD_INFO: if (fd < 0 && ! open_cd ()) return (0); return info (arg); case CMD_CDID: if (fd < 0 && ! open_cd ()) return (0); return cdid (); case CMD_STATUS: if (fd < 0 && ! open_cd ()) return (0); return pstatus (arg); case CMD_NEXT: case CMD_PREVIOUS: if (fd < 0 && ! open_cd ()) return (0); while (isspace (*arg)) arg++; return next_prev (arg, cmd); case CMD_PAUSE: if (fd < 0 && ! open_cd ()) return (0); return ioctl (fd, CDIOCPAUSE); case CMD_RESUME: if (fd < 0 && ! open_cd ()) return (0); return ioctl (fd, CDIOCRESUME); case CMD_STOP: if (fd < 0 && ! open_cd ()) return (0); rc = ioctl (fd, CDIOCSTOP); (void) ioctl (fd, CDIOCALLOW); return (rc); case CMD_RESET: if (fd < 0 && ! open_cd ()) return (0); rc = ioctl (fd, CDIOCRESET); if (rc < 0) return rc; close(fd); fd = -1; return (0); case CMD_DEBUG: if (fd < 0 && ! open_cd ()) return (0); if (! strcasecmp (arg, "on")) return ioctl (fd, CDIOCSETDEBUG); if (! strcasecmp (arg, "off")) return ioctl (fd, CDIOCCLRDEBUG); warnx("invalid command arguments"); return (0); case CMD_EJECT: if (fd < 0 && ! open_cd ()) return (0); (void) ioctl (fd, CDIOCALLOW); rc = ioctl (fd, CDIOCEJECT); if (rc < 0) return (rc); return (0); case CMD_CLOSE: if (fd < 0 && ! open_cd ()) return (0); (void) ioctl (fd, CDIOCALLOW); rc = ioctl (fd, CDIOCCLOSE); if (rc < 0) return (rc); close(fd); fd = -1; return (0); case CMD_PLAY: if (fd < 0 && ! open_cd ()) return (0); while (isspace (*arg)) arg++; return play (arg); case CMD_SET: if (! strcasecmp (arg, "msf")) msf = 1; else if (! strcasecmp (arg, "lba")) msf = 0; else warnx("invalid command arguments"); return (0); case CMD_VOLUME: if (fd < 0 && !open_cd ()) return (0); if (! strlen (arg)) { char volume[] = "volume"; return pstatus (volume); } if (! strncasecmp (arg, "left", strlen(arg))) return ioctl (fd, CDIOCSETLEFT); if (! strncasecmp (arg, "right", strlen(arg))) return ioctl (fd, CDIOCSETRIGHT); if (! strncasecmp (arg, "mono", strlen(arg))) return ioctl (fd, CDIOCSETMONO); if (! strncasecmp (arg, "stereo", strlen(arg))) return ioctl (fd, CDIOCSETSTERIO); if (! strncasecmp (arg, "mute", strlen(arg))) return ioctl (fd, CDIOCSETMUTE); count = sscanf (arg, "%d %d", &l, &r); if (count == 1) return setvol (l, l); if (count == 2) return setvol (l, r); warnx("invalid command arguments"); return (0); case CMD_SPEED: if (fd < 0 && ! open_cd ()) return (0); errno = 0; if (strcasecmp("max", arg) == 0) speed = CDR_MAX_SPEED; else speed = strtol(arg, NULL, 10) * 177; if (speed <= 0 || speed > INT_MAX) { warnx("invalid command arguments %s", arg); return (0); } return ioctl(fd, CDRIOCREADSPEED, &speed); default: case CMD_HELP: help (); return (0); } }
void CVolume::setVolume(const neutrino_msg_t key) { neutrino_msg_t msg = key; int mode = CNeutrinoApp::getInstance()->getMode(); if (msg <= CRCInput::RC_MaxRC) { if(m_mode != mode) { m_mode = mode; setVolume(msg); return; } } hideVolscale(); //showVolscale(); neutrino_msg_data_t data = 0; uint64_t timeoutEnd = 0; int vol = g_settings.current_volume; do { if (msg <= CRCInput::RC_MaxRC) { bool sub_chan_keybind = g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME && g_RemoteControl && g_RemoteControl->subChannels.size() < 1; if ((msg == (neutrino_msg_t) g_settings.key_volumeup || msg == (neutrino_msg_t) g_settings.key_volumedown) || (sub_chan_keybind && (msg == CRCInput::RC_right || msg == CRCInput::RC_left))) { int dir = (msg == (neutrino_msg_t) g_settings.key_volumeup || msg == CRCInput::RC_right) ? 1 : -1; if (CNeutrinoApp::getInstance()->isMuted() && (dir > 0 || g_settings.current_volume > 0)) { hideVolscale(); CAudioMute::getInstance()->AudioMute(false, true); setVolume(msg); return; } if (!CNeutrinoApp::getInstance()->isMuted()) { /* current_volume is char, we need signed to catch v < 0 */ int v = g_settings.current_volume; v += dir * g_settings.current_volume_step; if (v > 100) v = 100; else if (v < 1) { v = 0; g_settings.current_volume = 0; if (g_settings.show_mute_icon) { hideVolscale(); CAudioMute::getInstance()->AudioMute(true, true); setVolume(msg); return; } } g_settings.current_volume = v; #ifdef ENABLE_GRAPHLCD nGLCD::ShowVolume(true); #endif } } else if (msg == CRCInput::RC_home) break; else { g_RCInput->postMsg(msg, data); break; } setvol(g_settings.current_volume); timeoutEnd = CRCInput::calcTimeoutEnd (g_settings.timing[SNeutrinoSettings::TIMING_VOLUMEBAR] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_VOLUMEBAR]); } else if (msg == NeutrinoMessages::EVT_VOLCHANGED) { timeoutEnd = CRCInput::calcTimeoutEnd (g_settings.timing[SNeutrinoSettings::TIMING_VOLUMEBAR] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_VOLUMEBAR]); } else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::unhandled) { g_RCInput->postMsg(msg, data); break; } // if (volscale) { if(vol != g_settings.current_volume) { vol = g_settings.current_volume; showVolscale(); volscale->paint(); } // } CVFD::getInstance()->showVolume(g_settings.current_volume); if (msg != CRCInput::RC_timeout) { g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); } } while (msg != CRCInput::RC_timeout); #ifdef ENABLE_GRAPHLCD nGLCD::ShowVolume(false); #endif hideVolscale(); }