Home | History | Annotate | Download | only in server

Lines Matching refs:state

31 /* The system state.
33 * exp_state - The exported system state shared with clients.
34 * shm_name - Name of posix shm region for exported state.
64 } state;
75 state.shm_size = sizeof(*exp_state);
77 snprintf(state.shm_name, sizeof(state.shm_name), "/cras-%d", getpid());
78 state.shm_fd = cras_shm_open_rw(state.shm_name, state.shm_size);
79 if (state.shm_fd < 0)
80 exit(state.shm_fd);
83 exp_state = mmap(NULL, state.shm_size,
85 state.shm_fd, 0);
90 state.shm_fd_ro = cras_shm_reopen_ro(state.shm_name, state.shm_fd);
91 if (state.shm_fd_ro < 0)
92 exit(state.shm_fd_ro);
94 /* Initial system state. */
110 if ((rc = pthread_mutex_init(&state.update_lock, 0) != 0)) {
111 syslog(LOG_ERR, "Fatal: system state mutex init");
115 state.exp_state = exp_state;
121 state.device_config_dir = device_config_dir;
122 state.internal_ucm_suffix = NULL;
124 state.tm = cras_tm_init();
125 if (!state.tm) {
126 syslog(LOG_ERR, "Fatal: system state timer init");
131 state.device_blacklist =
137 state.internal_ucm_suffix = internal_ucm_suffix;
144 cras_device_blacklist_destroy(state.device_blacklist);
146 cras_tm_deinit(state.tm);
148 if (state.exp_state) {
149 munmap(state.exp_state, state.shm_size);
150 cras_shm_close_unlink(state.shm_name, state.shm_fd);
151 if (state.shm_fd_ro != state.shm_fd)
152 close(state.shm_fd_ro);
155 pthread_mutex_destroy(&state.update_lock);
163 state.exp_state->volume = MIN(volume, CRAS_MAX_SYSTEM_VOLUME);
164 cras_observer_notify_output_volume(state.exp_state->volume);
169 return state.exp_state->volume;
175 state.exp_state->capture_gain_target = gain;
176 gain = MAX(gain, state.exp_state->min_capture_gain);
177 gain = MIN(gain, state.exp_state->max_capture_gain);
178 state.exp_state->capture_gain = gain;
179 cras_observer_notify_capture_gain(state.exp_state->capture_gain);
184 return state.exp_state->capture_gain;
189 cras_observer_notify_output_mute(state.exp_state->mute,
190 state.exp_state->user_mute,
191 state.exp_state->mute_locked);
196 if (state.exp_state->user_mute == !!mute)
199 state.exp_state->user_mute = !!mute;
205 if (state.exp_state->mute_locked)
208 if (state.exp_state->mute == !!mute)
211 state.exp_state->mute = !!mute;
217 if (state.exp_state->mute_locked == !!locked)
220 state.exp_state->mute_locked = !!locked;
226 return state.exp_state->mute || state.exp_state->user_mute;
231 return state.exp_state->user_mute;
236 return state.exp_state->mute;
241 return state.exp_state->mute_locked;
246 cras_observer_notify_capture_mute(state.exp_state->capture_mute,
247 state.exp_state->capture_mute_locked);
252 if (state.exp_state->capture_mute_locked)
255 state.exp_state->capture_mute = !!mute;
261 state.exp_state->capture_mute_locked = !!locked;
267 return state.exp_state->capture_mute;
272 return state.exp_state->capture_mute_locked;
277 return state.exp_state->suspended;
282 state.exp_state->suspended = suspended;
288 state.exp_state->min_volume_dBFS = min;
289 state.exp_state->max_volume_dBFS = max;
294 return state.exp_state->min_volume_dBFS;
299 return state.exp_state->max_volume_dBFS;
304 state.exp_state->min_capture_gain = MAX(min, DEFAULT_MIN_CAPTURE_GAIN);
305 state.exp_state->max_capture_gain = max;
307 cras_system_set_capture_gain(state.exp_state->capture_gain_target);
312 return state.exp_state->min_capture_gain;
317 return state.exp_state->max_capture_gain;
331 DL_FOREACH(state.cards, card) {
337 state.device_config_dir,
338 state.device_blacklist,
340 ? state.internal_ucm_suffix
348 DL_APPEND(state.cards, card);
356 DL_FOREACH(state.cards, card) {
362 DL_DELETE(state.cards, card);
372 DL_FOREACH(state.cards, card)
385 if (state.fd_add != NULL || state.fd_rm != NULL)
387 state.fd_add = add;
388 state.fd_rm = rm;
389 state.select_data = select_data;
397 if (state.fd_add == NULL)
399 return state.fd_add(fd, callback, callback_data,
400 state.select_data);
405 if (state.fd_rm != NULL)
406 state.fd_rm(fd, state.select_data);
455 sum += state.exp_state->num_active_streams[i];
462 return state.exp_state->num_active_streams[direction];
467 *ts = state.exp_state->last_active_stream_time;
472 *devs = state.exp_state->output_devs;
473 return state.exp_state->num_output_devs;
478 *devs = state.exp_state->input_devs;
479 return state.exp_state->num_input_devs;
484 *nodes = state.exp_state->output_nodes;
485 return state.exp_state->num_output_nodes;
490 *nodes = state.exp_state->input_nodes;
491 return state.exp_state->num_input_nodes;
496 if (pthread_mutex_lock(&state.update_lock)) {
501 __sync_fetch_and_add(&state.exp_state->update_count, 1);
502 return state.exp_state;
507 __sync_fetch_and_add(&state.exp_state->update_count, 1);
508 pthread_mutex_unlock(&state.update_lock);
513 return state.exp_state;
518 return state.shm_fd_ro;
523 return state.tm;