Lines Matching refs:state
73 } state; variable
90 state.shm_size = sizeof(*exp_state); in cras_system_state_init()
92 strncpy(state.shm_name, shm_name, sizeof(state.shm_name)); in cras_system_state_init()
93 state.shm_name[sizeof(state.shm_name) - 1] = '\0'; in cras_system_state_init()
94 state.shm_fd = rw_shm_fd; in cras_system_state_init()
95 state.shm_fd_ro = ro_shm_fd; in cras_system_state_init()
121 if ((rc = pthread_mutex_init(&state.update_lock, 0) != 0)) { in cras_system_state_init()
126 state.exp_state = exp_state; in cras_system_state_init()
132 state.device_config_dir = device_config_dir; in cras_system_state_init()
133 state.internal_ucm_suffix = NULL; in cras_system_state_init()
135 state.tm = cras_tm_init(); in cras_system_state_init()
136 if (!state.tm) { in cras_system_state_init()
142 state.device_blacklist = in cras_system_state_init()
146 memset(&state.snapshot_buffer, 0, in cras_system_state_init()
152 state.internal_ucm_suffix = internal_ucm_suffix; in cras_system_state_set_internal_ucm_suffix()
159 cras_device_blacklist_destroy(state.device_blacklist); in cras_system_state_deinit()
161 cras_tm_deinit(state.tm); in cras_system_state_deinit()
163 if (state.exp_state) { in cras_system_state_deinit()
164 munmap(state.exp_state, state.shm_size); in cras_system_state_deinit()
165 cras_shm_close_unlink(state.shm_name, state.shm_fd); in cras_system_state_deinit()
166 if (state.shm_fd_ro != state.shm_fd) in cras_system_state_deinit()
167 close(state.shm_fd_ro); in cras_system_state_deinit()
170 pthread_mutex_destroy(&state.update_lock); in cras_system_state_deinit()
178 state.exp_state->volume = MIN(volume, CRAS_MAX_SYSTEM_VOLUME); in cras_system_set_volume()
179 cras_observer_notify_output_volume(state.exp_state->volume); in cras_system_set_volume()
184 return state.exp_state->volume; in cras_system_get_volume()
190 state.exp_state->capture_gain_target = gain; in cras_system_set_capture_gain()
191 gain = MAX(gain, state.exp_state->min_capture_gain); in cras_system_set_capture_gain()
192 gain = MIN(gain, state.exp_state->max_capture_gain); in cras_system_set_capture_gain()
193 state.exp_state->capture_gain = gain; in cras_system_set_capture_gain()
194 cras_observer_notify_capture_gain(state.exp_state->capture_gain); in cras_system_set_capture_gain()
199 return state.exp_state->capture_gain; in cras_system_get_capture_gain()
204 cras_observer_notify_output_mute(state.exp_state->mute, in cras_system_notify_mute()
205 state.exp_state->user_mute, in cras_system_notify_mute()
206 state.exp_state->mute_locked); in cras_system_notify_mute()
213 if (state.exp_state->user_mute == !!mute) in cras_system_set_user_mute()
216 state.exp_state->user_mute = !!mute; in cras_system_set_user_mute()
218 if (current_mute == (mute || state.exp_state->mute)) in cras_system_set_user_mute()
228 if (state.exp_state->mute_locked) in cras_system_set_mute()
231 if (state.exp_state->mute == !!mute) in cras_system_set_mute()
234 state.exp_state->mute = !!mute; in cras_system_set_mute()
236 if (current_mute == (mute || state.exp_state->user_mute)) in cras_system_set_mute()
244 if (state.exp_state->mute_locked == !!locked) in cras_system_set_mute_locked()
247 state.exp_state->mute_locked = !!locked; in cras_system_set_mute_locked()
252 return state.exp_state->mute || state.exp_state->user_mute; in cras_system_get_mute()
257 return state.exp_state->user_mute; in cras_system_get_user_mute()
262 return state.exp_state->mute; in cras_system_get_system_mute()
267 return state.exp_state->mute_locked; in cras_system_get_mute_locked()
272 cras_observer_notify_capture_mute(state.exp_state->capture_mute, in cras_system_notify_capture_mute()
273 state.exp_state->capture_mute_locked); in cras_system_notify_capture_mute()
278 if (state.exp_state->capture_mute_locked) in cras_system_set_capture_mute()
281 state.exp_state->capture_mute = !!mute; in cras_system_set_capture_mute()
287 state.exp_state->capture_mute_locked = !!locked; in cras_system_set_capture_mute_locked()
293 return state.exp_state->capture_mute; in cras_system_get_capture_mute()
298 return state.exp_state->capture_mute_locked; in cras_system_get_capture_mute_locked()
303 return state.exp_state->suspended; in cras_system_get_suspended()
308 state.exp_state->suspended = suspended; in cras_system_set_suspended()
314 state.exp_state->min_volume_dBFS = min; in cras_system_set_volume_limits()
315 state.exp_state->max_volume_dBFS = max; in cras_system_set_volume_limits()
320 return state.exp_state->min_volume_dBFS; in cras_system_get_min_volume()
325 return state.exp_state->max_volume_dBFS; in cras_system_get_max_volume()
330 state.exp_state->min_capture_gain = MAX(min, DEFAULT_MIN_CAPTURE_GAIN); in cras_system_set_capture_gain_limits()
331 state.exp_state->max_capture_gain = max; in cras_system_set_capture_gain_limits()
333 cras_system_set_capture_gain(state.exp_state->capture_gain_target); in cras_system_set_capture_gain_limits()
338 return state.exp_state->min_capture_gain; in cras_system_get_min_capture_gain()
343 return state.exp_state->max_capture_gain; in cras_system_get_max_capture_gain()
348 return state.exp_state->default_output_buffer_size; in cras_system_get_default_output_buffer_size()
353 return state.exp_state->aec_supported; in cras_system_get_aec_supported()
367 DL_FOREACH(state.cards, card) { in cras_system_add_alsa_card()
373 state.device_config_dir, in cras_system_add_alsa_card()
374 state.device_blacklist, in cras_system_add_alsa_card()
376 ? state.internal_ucm_suffix in cras_system_add_alsa_card()
384 DL_APPEND(state.cards, card); in cras_system_add_alsa_card()
392 DL_FOREACH(state.cards, card) { in cras_system_remove_alsa_card()
398 DL_DELETE(state.cards, card); in cras_system_remove_alsa_card()
408 DL_FOREACH(state.cards, card) in cras_system_alsa_card_exists()
421 if (state.fd_add != NULL || state.fd_rm != NULL) in cras_system_set_select_handler()
423 state.fd_add = add; in cras_system_set_select_handler()
424 state.fd_rm = rm; in cras_system_set_select_handler()
425 state.select_data = select_data; in cras_system_set_select_handler()
433 if (state.fd_add == NULL) in cras_system_add_select_fd()
435 return state.fd_add(fd, callback, callback_data, in cras_system_add_select_fd()
436 state.select_data); in cras_system_add_select_fd()
444 if (state.add_task != NULL) in cras_system_set_add_task_handler()
447 state.add_task = add_task; in cras_system_set_add_task_handler()
448 state.task_data = task_data; in cras_system_set_add_task_handler()
454 if (state.add_task == NULL) in cras_system_add_task()
457 return state.add_task(callback, callback_data, state.task_data); in cras_system_add_task()
462 if (state.fd_rm != NULL) in cras_system_rm_select_fd()
463 state.fd_rm(fd, state.select_data); in cras_system_rm_select_fd()
512 sum += state.exp_state->num_active_streams[i]; in cras_system_state_get_active_streams()
519 return state.exp_state->num_active_streams[direction]; in cras_system_state_get_active_streams_by_direction()
524 *ts = state.exp_state->last_active_stream_time; in cras_system_state_get_last_stream_active_time()
529 *devs = state.exp_state->output_devs; in cras_system_state_get_output_devs()
530 return state.exp_state->num_output_devs; in cras_system_state_get_output_devs()
535 *devs = state.exp_state->input_devs; in cras_system_state_get_input_devs()
536 return state.exp_state->num_input_devs; in cras_system_state_get_input_devs()
541 *nodes = state.exp_state->output_nodes; in cras_system_state_get_output_nodes()
542 return state.exp_state->num_output_nodes; in cras_system_state_get_output_nodes()
547 *nodes = state.exp_state->input_nodes; in cras_system_state_get_input_nodes()
548 return state.exp_state->num_input_nodes; in cras_system_state_get_input_nodes()
553 state.exp_state->non_empty_status = non_empty; in cras_system_state_set_non_empty_status()
558 return state.exp_state->non_empty_status; in cras_system_state_get_non_empty_status()
563 if (pthread_mutex_lock(&state.update_lock)) { in cras_system_state_update_begin()
568 __sync_fetch_and_add(&state.exp_state->update_count, 1); in cras_system_state_update_begin()
569 return state.exp_state; in cras_system_state_update_begin()
574 __sync_fetch_and_add(&state.exp_state->update_count, 1); in cras_system_state_update_complete()
575 pthread_mutex_unlock(&state.update_lock); in cras_system_state_update_complete()
580 return state.exp_state; in cras_system_state_get_no_lock()
585 return state.shm_fd_ro; in cras_sys_state_shm_fd()
590 return state.tm; in cras_system_state_get_tm()
596 memcpy(&state.exp_state->snapshot_buffer, &state.snapshot_buffer, in cras_system_state_dump_snapshots()
603 state.snapshot_buffer.snapshots[state.snapshot_buffer.pos++] = in cras_system_state_add_snapshot()
605 state.snapshot_buffer.pos %= in cras_system_state_add_snapshot()