Lines Matching refs:client
164 struct cras_client *client; member
257 struct cras_client client; member
263 offsetof(struct client_int, client)))
283 static int client_thread_rm_stream(struct cras_client *client,
285 static int handle_message_from_server(struct cras_client *client);
286 static int reregister_notifications(struct cras_client *client);
296 static void server_state_unlock(const struct cras_client *client, int lock_rc) in server_state_unlock() argument
300 if (!client) in server_state_unlock()
302 client_int = to_client_int(client); in server_state_unlock()
318 static int server_state_rdlock(const struct cras_client *client) in server_state_rdlock() argument
323 if (!client) in server_state_rdlock()
325 client_int = to_client_int(client); in server_state_rdlock()
329 if (!client->server_state) { in server_state_rdlock()
344 static int server_state_wrlock(const struct cras_client *client) in server_state_wrlock() argument
348 if (!client) in server_state_wrlock()
350 client_int = to_client_int(client); in server_state_wrlock()
355 static struct client_stream *stream_from_id(const struct cras_client *client, in stream_from_id() argument
360 DL_SEARCH_SCALAR(client->streams, out, id, id); in stream_from_id()
367 void server_fill_pollfd(const struct cras_client *client, in server_fill_pollfd() argument
372 poll_fd->fd = client->server_fd; in server_fill_pollfd()
373 switch (client->server_fd_state) { in server_fill_pollfd()
393 static void server_fd_move_to_state(struct cras_client *client, in server_fd_move_to_state() argument
396 if (state == client->server_fd_state) in server_fd_move_to_state()
399 client->server_fd_state = state; in server_fd_move_to_state()
413 static int error_delay_next_action(struct cras_client *client, int poll_revents) in error_delay_next_action() argument
418 if (client->server_fd == -1) { in error_delay_next_action()
419 client->server_fd = timerfd_create(CLOCK_MONOTONIC, in error_delay_next_action()
421 if (client->server_fd == -1) { in error_delay_next_action()
432 rc = timerfd_settime(client->server_fd, 0, &timeout, NULL); in error_delay_next_action()
446 close(client->server_fd); in error_delay_next_action()
447 client->server_fd = -1; in error_delay_next_action()
448 server_fd_move_to_state(client, CRAS_SOCKET_STATE_WAIT_FOR_SOCKET); in error_delay_next_action()
462 static void wait_for_socket_next_action(struct cras_client *client) in wait_for_socket_next_action() argument
464 if (client->sock_file_exists) in wait_for_socket_next_action()
465 server_fd_move_to_state(client, in wait_for_socket_next_action()
480 static int wait_for_writable_next_action(struct cras_client *client, in wait_for_writable_next_action() argument
486 if (client->server_fd == -1) { in wait_for_writable_next_action()
487 client->server_fd = socket(PF_UNIX, SOCK_SEQPACKET, 0); in wait_for_writable_next_action()
488 if (client->server_fd < 0) { in wait_for_writable_next_action()
500 cras_make_fd_nonblocking(client->server_fd); in wait_for_writable_next_action()
504 strcpy(address.sun_path, client->sock_file); in wait_for_writable_next_action()
505 rc = connect(client->server_fd, (struct sockaddr *)&address, in wait_for_writable_next_action()
517 close(client->server_fd); in wait_for_writable_next_action()
518 client->server_fd = -1; in wait_for_writable_next_action()
528 cras_make_fd_blocking(client->server_fd); in wait_for_writable_next_action()
529 server_fd_move_to_state(client, CRAS_SOCKET_STATE_FIRST_MESSAGE); in wait_for_writable_next_action()
536 static int connect_transition_action(struct cras_client *client) in connect_transition_action() argument
541 rc = reregister_notifications(client); in connect_transition_action()
545 server_fd_move_to_state(client, CRAS_SOCKET_STATE_CONNECTED); in connect_transition_action()
548 eventfd_read(client->server_event_fd, &event_value); in connect_transition_action()
549 eventfd_write(client->server_event_fd, 1); in connect_transition_action()
550 if (client->server_connection_cb) in connect_transition_action()
551 client->server_connection_cb( in connect_transition_action()
552 client, CRAS_CONN_STATUS_CONNECTED, in connect_transition_action()
553 client->server_connection_user_arg); in connect_transition_action()
563 static int first_message_next_action(struct cras_client *client, in first_message_next_action() argument
568 if (client->server_fd < 0) in first_message_next_action()
574 rc = handle_message_from_server(client); in first_message_next_action()
577 } else if (client->id >= 0) { in first_message_next_action()
578 rc = connect_transition_action(client); in first_message_next_action()
617 static void disconnect_transition_action(struct cras_client *client, bool force) in disconnect_transition_action() argument
620 cras_socket_state_t old_state = client->server_fd_state; in disconnect_transition_action()
626 DL_FOREACH (client->streams, s) { in disconnect_transition_action()
627 s->config->err_cb(client, s->id, -ENOTCONN, in disconnect_transition_action()
629 client_thread_rm_stream(client, s->id); in disconnect_transition_action()
633 lock_rc = server_state_wrlock(client); in disconnect_transition_action()
634 if (client->server_state) { in disconnect_transition_action()
635 munmap((void *)client->server_state, in disconnect_transition_action()
636 sizeof(*client->server_state)); in disconnect_transition_action()
637 client->server_state = NULL; in disconnect_transition_action()
639 server_state_unlock(client, lock_rc); in disconnect_transition_action()
642 client->id = -1; in disconnect_transition_action()
645 if (client->server_fd >= 0) { in disconnect_transition_action()
647 shutdown_and_close_socket(client->server_fd); in disconnect_transition_action()
649 close(client->server_fd); in disconnect_transition_action()
650 client->server_fd = -1; in disconnect_transition_action()
655 eventfd_read(client->server_event_fd, &event_value); in disconnect_transition_action()
665 server_fd_move_to_state(client, CRAS_SOCKET_STATE_DISCONNECTED); in disconnect_transition_action()
666 if (client->server_connection_cb) in disconnect_transition_action()
667 client->server_connection_cb( in disconnect_transition_action()
668 client, CRAS_CONN_STATUS_FAILED, in disconnect_transition_action()
669 client->server_connection_user_arg); in disconnect_transition_action()
677 server_fd_move_to_state(client, CRAS_SOCKET_STATE_ERROR_DELAY); in disconnect_transition_action()
682 server_fd_move_to_state(client, in disconnect_transition_action()
685 if (client->server_connection_cb) in disconnect_transition_action()
686 client->server_connection_cb( in disconnect_transition_action()
687 client, CRAS_CONN_STATUS_DISCONNECTED, in disconnect_transition_action()
688 client->server_connection_user_arg); in disconnect_transition_action()
693 static int server_fd_dispatch(struct cras_client *client, int poll_revents) in server_fd_dispatch() argument
700 disconnect_transition_action(client, true); in server_fd_dispatch()
702 old_state = client->server_fd_state; in server_fd_dispatch()
704 switch (client->server_fd_state) { in server_fd_dispatch()
709 rc = error_delay_next_action(client, poll_revents); in server_fd_dispatch()
712 wait_for_socket_next_action(client); in server_fd_dispatch()
715 rc = wait_for_writable_next_action(client, poll_revents); in server_fd_dispatch()
718 rc = first_message_next_action(client, poll_revents); in server_fd_dispatch()
722 rc = handle_message_from_server(client); in server_fd_dispatch()
728 rc = server_fd_dispatch(client, POLLHUP); in server_fd_dispatch()
729 } else if (old_state != client->server_fd_state) { in server_fd_dispatch()
731 rc = server_fd_dispatch(client, 0); in server_fd_dispatch()
739 static int server_connect(struct cras_client *client) in server_connect() argument
741 if (client->server_fd_state != CRAS_SOCKET_STATE_DISCONNECTED) in server_connect()
744 server_fd_move_to_state(client, CRAS_SOCKET_STATE_WAIT_FOR_SOCKET); in server_connect()
745 return server_fd_dispatch(client, 0); in server_connect()
751 static void server_disconnect(struct cras_client *client) in server_disconnect() argument
753 if (client->server_fd_state == CRAS_SOCKET_STATE_DISCONNECTED) in server_disconnect()
757 server_fd_move_to_state(client, CRAS_SOCKET_STATE_DISCONNECTED); in server_disconnect()
758 disconnect_transition_action(client, false); in server_disconnect()
767 struct cras_client *client = (struct cras_client *)context; in sock_file_wait_callback() local
770 client->sock_file_exists = 1; in sock_file_wait_callback()
771 switch (client->server_fd_state) { in sock_file_wait_callback()
781 server_fd_dispatch(client, 0); in sock_file_wait_callback()
786 client->sock_file_exists = 0; in sock_file_wait_callback()
787 switch (client->server_fd_state) { in sock_file_wait_callback()
796 server_disconnect(client); in sock_file_wait_callback()
797 server_connect(client); in sock_file_wait_callback()
812 static int sock_file_wait_dispatch(struct cras_client *client, int poll_revents) in sock_file_wait_dispatch() argument
819 rc = cras_file_wait_dispatch(client->sock_file_wait); in sock_file_wait_dispatch()
835 static int check_server_connected_wait(struct cras_client *client, in check_server_connected_wait() argument
841 poll_fd.fd = client->server_event_fd; in check_server_connected_wait()
870 static int connect_to_server(struct cras_client *client, in connect_to_server() argument
877 if (!client) in connect_to_server()
880 if (thread_is_running(&client->thread) && use_command_thread) { in connect_to_server()
881 rc = cras_client_connect_async(client); in connect_to_server()
883 rc = check_server_connected_wait(client, timeout); in connect_to_server()
890 if (check_server_connected_wait(client, &connected_timeout)) in connect_to_server()
893 poll_fd[0].fd = cras_file_wait_get_fd(client->sock_file_wait); in connect_to_server()
896 rc = server_connect(client); in connect_to_server()
901 server_fill_pollfd(client, &(poll_fd[1])); in connect_to_server()
907 rc = sock_file_wait_dispatch(client, in connect_to_server()
913 rc = server_fd_dispatch(client, poll_fd[1].revents); in connect_to_server()
914 if (rc == 0 && client->server_fd_state == in connect_to_server()
927 static int connect_to_server_wait_retry(struct cras_client *client, in connect_to_server_wait_retry() argument
942 return connect_to_server(client, timeout, use_command_thread); in connect_to_server_wait_retry()
950 static int connect_to_server_wait(struct cras_client *client, in connect_to_server_wait() argument
953 return connect_to_server_wait_retry(client, SERVER_CONNECT_TIMEOUT_MS, in connect_to_server_wait()
973 res = write(stream->client->stream_fds[1], &msg, sizeof(msg)); in send_stream_message()
1104 frames = config->unified_cb(stream->client, stream->id, in handle_capture_data_ready()
1108 frames = config->aud_cb(stream->client, stream->id, in handle_capture_data_ready()
1175 frames = config->unified_cb(stream->client, stream->id, NULL, in handle_playback_request()
1179 frames = config->aud_cb(stream->client, stream->id, buf, in handle_playback_request()
1198 if (stream->client->thread_priority_cb) { in audio_thread_set_priority()
1199 stream->client->thread_priority_cb(stream->client); in audio_thread_set_priority()
1225 pthread_mutex_lock(&stream->client->stream_start_lock); in audio_thread()
1226 pthread_cond_broadcast(&stream->client->stream_start_cond); in audio_thread()
1227 pthread_mutex_unlock(&stream->client->stream_start_lock); in audio_thread()
1314 pthread_mutex_lock(&stream->client->stream_start_lock); in start_aud_thread()
1317 pthread_mutex_unlock(&stream->client->stream_start_lock); in start_aud_thread()
1327 rc = pthread_cond_timedwait(&stream->client->stream_start_cond, in start_aud_thread()
1328 &stream->client->stream_start_lock, in start_aud_thread()
1330 pthread_mutex_unlock(&stream->client->stream_start_lock); in start_aud_thread()
1440 static int send_connect_message(struct cras_client *client, in send_connect_message() argument
1470 rc = cras_send_with_fds(client->server_fd, &serv_msg, sizeof(serv_msg), in send_connect_message()
1498 static int client_thread_add_stream(struct cras_client *client, in client_thread_add_stream() argument
1512 client, CRAS_NODE_TYPE_HOTWORD, CRAS_STREAM_INPUT); in client_thread_add_stream()
1523 new_id = cras_get_stream_id(client->id, client->next_stream_id); in client_thread_add_stream()
1524 client->next_stream_id++; in client_thread_add_stream()
1525 DL_SEARCH_SCALAR(client->streams, out, id, new_id); in client_thread_add_stream()
1530 stream->client = client; in client_thread_add_stream()
1539 rc = send_connect_message(client, stream, dev_idx); in client_thread_add_stream()
1546 DL_APPEND(client->streams, stream); in client_thread_add_stream()
1553 static int client_thread_rm_stream(struct cras_client *client, in client_thread_rm_stream() argument
1557 struct client_stream *stream = stream_from_id(client, stream_id); in client_thread_rm_stream()
1564 if (client->server_fd_state == CRAS_SOCKET_STATE_CONNECTED) { in client_thread_rm_stream()
1566 rc = write(client->server_fd, &msg, sizeof(msg)); in client_thread_rm_stream()
1577 DL_DELETE(client->streams, stream); in client_thread_rm_stream()
1588 static int client_thread_set_stream_volume(struct cras_client *client, in client_thread_set_stream_volume() argument
1594 stream = stream_from_id(client, stream_id); in client_thread_set_stream_volume()
1606 static void attach_atlog_shm(struct cras_client *client, int fd) in attach_atlog_shm() argument
1608 client->atlog_ro = (struct audio_thread_event_log *)mmap( in attach_atlog_shm()
1609 NULL, sizeof(*client->atlog_ro), PROT_READ, MAP_SHARED, fd, 0); in attach_atlog_shm()
1614 static int client_attach_shm(struct cras_client *client, int shm_fd) in client_attach_shm() argument
1619 lock_rc = server_state_wrlock(client); in client_attach_shm()
1620 if (client->server_state) { in client_attach_shm()
1625 client->server_state = (struct cras_server_state *)mmap( in client_attach_shm()
1626 NULL, sizeof(*client->server_state), PROT_READ, MAP_SHARED, in client_attach_shm()
1630 if (client->server_state == (struct cras_server_state *)-1) { in client_attach_shm()
1637 if (client->server_state->state_version != CRAS_SERVER_STATE_VERSION) { in client_attach_shm()
1638 munmap((void *)client->server_state, in client_attach_shm()
1639 sizeof(*client->server_state)); in client_attach_shm()
1640 client->server_state = NULL; in client_attach_shm()
1648 server_state_unlock(client, lock_rc); in client_attach_shm()
1652 static void cras_client_get_hotword_models_ready(struct cras_client *client, in cras_client_get_hotword_models_ready() argument
1655 if (!client->get_hotword_models_cb) in cras_client_get_hotword_models_ready()
1657 client->get_hotword_models_cb(client, hotword_models); in cras_client_get_hotword_models_ready()
1658 client->get_hotword_models_cb = NULL; in cras_client_get_hotword_models_ready()
1662 static int handle_message_from_server(struct cras_client *client) in handle_message_from_server() argument
1672 nread = cras_recv_with_fds(client->server_fd, buf, sizeof(buf), in handle_message_from_server()
1683 rc = client_attach_shm(client, server_fds[0]); in handle_message_from_server()
1686 client->id = cmsg->client_id; in handle_message_from_server()
1694 stream_from_id(client, cmsg->stream_id); in handle_message_from_server()
1715 stream->config->err_cb(stream->client, stream->id, rc, in handle_message_from_server()
1720 if (client->debug_info_callback) in handle_message_from_server()
1721 client->debug_info_callback(client); in handle_message_from_server()
1722 client->debug_info_callback = NULL; in handle_message_from_server()
1727 attach_atlog_shm(client, server_fds[0]); in handle_message_from_server()
1728 if (client->atlog_access_callback) in handle_message_from_server()
1729 client->atlog_access_callback(client); in handle_message_from_server()
1730 client->atlog_access_callback = NULL; in handle_message_from_server()
1736 client, (const char *)cmsg->hotword_models); in handle_message_from_server()
1742 if (client->observer_ops.output_volume_changed) in handle_message_from_server()
1743 client->observer_ops.output_volume_changed( in handle_message_from_server()
1744 client->observer_context, cmsg->volume); in handle_message_from_server()
1750 if (client->observer_ops.output_mute_changed) in handle_message_from_server()
1751 client->observer_ops.output_mute_changed( in handle_message_from_server()
1752 client->observer_context, cmsg->muted, in handle_message_from_server()
1759 if (client->observer_ops.capture_gain_changed) in handle_message_from_server()
1760 client->observer_ops.capture_gain_changed( in handle_message_from_server()
1761 client->observer_context, cmsg->volume); in handle_message_from_server()
1767 if (client->observer_ops.capture_mute_changed) in handle_message_from_server()
1768 client->observer_ops.capture_mute_changed( in handle_message_from_server()
1769 client->observer_context, cmsg->muted, in handle_message_from_server()
1774 if (client->observer_ops.nodes_changed) in handle_message_from_server()
1775 client->observer_ops.nodes_changed( in handle_message_from_server()
1776 client->observer_context); in handle_message_from_server()
1784 if (client->observer_ops.active_node_changed) in handle_message_from_server()
1785 client->observer_ops.active_node_changed( in handle_message_from_server()
1786 client->observer_context, direction, in handle_message_from_server()
1793 if (client->observer_ops.output_node_volume_changed) in handle_message_from_server()
1794 client->observer_ops.output_node_volume_changed( in handle_message_from_server()
1795 client->observer_context, cmsg->node_id, in handle_message_from_server()
1802 if (client->observer_ops.node_left_right_swapped_changed) in handle_message_from_server()
1803 client->observer_ops.node_left_right_swapped_changed( in handle_message_from_server()
1804 client->observer_context, cmsg->node_id, in handle_message_from_server()
1811 if (client->observer_ops.input_node_gain_changed) in handle_message_from_server()
1812 client->observer_ops.input_node_gain_changed( in handle_message_from_server()
1813 client->observer_context, cmsg->node_id, in handle_message_from_server()
1822 if (client->observer_ops.num_active_streams_changed) in handle_message_from_server()
1823 client->observer_ops.num_active_streams_changed( in handle_message_from_server()
1824 client->observer_context, direction, in handle_message_from_server()
1836 static int handle_stream_message(struct cras_client *client, int poll_revents) in handle_stream_message() argument
1844 rc = read(client->stream_fds[0], &msg, sizeof(msg)); in handle_stream_message()
1850 client_thread_rm_stream(client, msg.stream_id); in handle_stream_message()
1855 static int handle_command_message(struct cras_client *client, int poll_revents) in handle_command_message() argument
1864 rc = read(client->command_fds[0], buf, sizeof(msg->len)); in handle_command_message()
1870 rc = read(client->command_fds[0], &buf[0] + rc, to_read); in handle_command_message()
1881 DL_FOREACH (client->streams, s) in handle_command_message()
1882 client_thread_rm_stream(client, s->id); in handle_command_message()
1885 client->thread.state = CRAS_THREAD_STOP; in handle_command_message()
1892 rc = client_thread_add_stream(client, add_msg->stream, in handle_command_message()
1898 rc = client_thread_rm_stream(client, msg->stream_id); in handle_command_message()
1903 rc = client_thread_set_stream_volume(client, in handle_command_message()
1909 rc = connect_to_server_wait(client, false); in handle_command_message()
1912 rc = server_connect(client); in handle_command_message()
1921 if (write(client->command_reply_fds[1], &rc, sizeof(rc)) != sizeof(rc)) in handle_command_message()
1932 struct cras_client *client = (struct cras_client *)arg; in client_thread() local
1934 int (*cbs[4])(struct cras_client * client, int poll_revents); in client_thread()
1941 while (thread_is_running(&client->thread)) { in client_thread()
1944 rc = cras_file_wait_get_fd(client->sock_file_wait); in client_thread()
1953 if (client->server_fd >= 0) { in client_thread()
1955 server_fill_pollfd(client, &(pollfds[num_pollfds])); in client_thread()
1958 if (client->command_fds[0] >= 0) { in client_thread()
1960 pollfds[num_pollfds].fd = client->command_fds[0]; in client_thread()
1965 if (client->stream_fds[0] >= 0) { in client_thread()
1967 pollfds[num_pollfds].fd = client->stream_fds[0]; in client_thread()
1981 cbs[i](client, pollfds[i].revents); in client_thread()
1988 close(client->command_reply_fds[1]); in client_thread()
1989 client->command_reply_fds[1] = -1; in client_thread()
1996 static int send_command_message(struct cras_client *client, in send_command_message() argument
2000 if (client == NULL || !thread_is_running(&client->thread)) in send_command_message()
2003 rc = write(client->command_fds[1], msg, msg->len); in send_command_message()
2008 rc = read(client->command_reply_fds[0], &cmd_res, sizeof(cmd_res)); in send_command_message()
2015 static int send_simple_cmd_msg(struct cras_client *client, in send_simple_cmd_msg() argument
2024 return send_command_message(client, &msg); in send_simple_cmd_msg()
2028 static int send_stream_volume_command_msg(struct cras_client *client, in send_stream_volume_command_msg() argument
2039 return send_command_message(client, &msg.header); in send_stream_volume_command_msg()
2043 static int write_message_to_server(struct cras_client *client, in write_message_to_server() argument
2048 if (client->server_fd_state == CRAS_SOCKET_STATE_CONNECTED || in write_message_to_server()
2049 client->server_fd_state == CRAS_SOCKET_STATE_FIRST_MESSAGE) { in write_message_to_server()
2050 write_rc = write(client->server_fd, msg, msg->length); in write_message_to_server()
2056 client->server_fd_state != CRAS_SOCKET_STATE_FIRST_MESSAGE) in write_message_to_server()
2068 static int fill_socket_file(struct cras_client *client, in fill_socket_file() argument
2073 client->sock_file = in fill_socket_file()
2075 if (client->sock_file == NULL) in fill_socket_file()
2078 rc = cras_fill_socket_path(conn_type, (char *)client->sock_file); in fill_socket_file()
2080 free((void *)client->sock_file); in fill_socket_file()
2090 int cras_client_create_with_type(struct cras_client **client, in cras_client_create_with_type() argument
2108 *client = &client_int->client; in cras_client_create_with_type()
2109 (*client)->server_fd = -1; in cras_client_create_with_type()
2110 (*client)->id = -1; in cras_client_create_with_type()
2119 rc = pthread_mutex_init(&(*client)->stream_start_lock, NULL); in cras_client_create_with_type()
2128 rc = pthread_cond_init(&(*client)->stream_start_cond, &cond_attr); in cras_client_create_with_type()
2136 (*client)->server_event_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); in cras_client_create_with_type()
2137 if ((*client)->server_event_fd < 0) { in cras_client_create_with_type()
2143 rc = fill_socket_file((*client), conn_type); in cras_client_create_with_type()
2148 rc = cras_file_wait_create((*client)->sock_file, in cras_client_create_with_type()
2150 sock_file_wait_callback, *client, in cras_client_create_with_type()
2151 &(*client)->sock_file_wait); in cras_client_create_with_type()
2155 (*client)->sock_file, strerror(-rc)); in cras_client_create_with_type()
2158 (*client)->sock_file_exists = (rc == 0); in cras_client_create_with_type()
2162 rc = pipe((*client)->command_fds); in cras_client_create_with_type()
2167 rc = pipe((*client)->stream_fds); in cras_client_create_with_type()
2169 close((*client)->command_fds[0]); in cras_client_create_with_type()
2170 close((*client)->command_fds[1]); in cras_client_create_with_type()
2173 (*client)->command_reply_fds[0] = -1; in cras_client_create_with_type()
2174 (*client)->command_reply_fds[1] = -1; in cras_client_create_with_type()
2178 if ((*client)->server_event_fd >= 0) in cras_client_create_with_type()
2179 close((*client)->server_event_fd); in cras_client_create_with_type()
2180 cras_file_wait_destroy((*client)->sock_file_wait); in cras_client_create_with_type()
2181 free((void *)(*client)->sock_file); in cras_client_create_with_type()
2183 pthread_cond_destroy(&(*client)->stream_start_cond); in cras_client_create_with_type()
2185 pthread_mutex_destroy(&(*client)->stream_start_lock); in cras_client_create_with_type()
2189 *client = NULL; in cras_client_create_with_type()
2194 int cras_client_create(struct cras_client **client) in cras_client_create() argument
2196 return cras_client_create_with_type(client, CRAS_CONTROL); in cras_client_create()
2199 void cras_client_destroy(struct cras_client *client) in cras_client_destroy() argument
2202 if (client == NULL) in cras_client_destroy()
2204 client_int = to_client_int(client); in cras_client_destroy()
2205 client->server_connection_cb = NULL; in cras_client_destroy()
2206 cras_client_stop(client); in cras_client_destroy()
2207 server_disconnect(client); in cras_client_destroy()
2208 close(client->server_event_fd); in cras_client_destroy()
2209 close(client->command_fds[0]); in cras_client_destroy()
2210 close(client->command_fds[1]); in cras_client_destroy()
2211 close(client->stream_fds[0]); in cras_client_destroy()
2212 close(client->stream_fds[1]); in cras_client_destroy()
2213 cras_file_wait_destroy(client->sock_file_wait); in cras_client_destroy()
2215 free((void *)client->sock_file); in cras_client_destroy()
2219 int cras_client_connect(struct cras_client *client) in cras_client_connect() argument
2221 return connect_to_server(client, NULL, true); in cras_client_connect()
2224 int cras_client_connect_timeout(struct cras_client *client, in cras_client_connect_timeout() argument
2227 return connect_to_server_wait_retry(client, timeout_ms, true); in cras_client_connect_timeout()
2230 int cras_client_connected_wait(struct cras_client *client) in cras_client_connected_wait() argument
2232 return send_simple_cmd_msg(client, 0, CLIENT_SERVER_CONNECT); in cras_client_connected_wait()
2235 int cras_client_connect_async(struct cras_client *client) in cras_client_connect_async() argument
2237 return send_simple_cmd_msg(client, 0, CLIENT_SERVER_CONNECT_ASYNC); in cras_client_connect_async()
2359 struct cras_client *client, uint32_t dev_idx, in cras_client_send_add_stream_command_message() argument
2366 if (client == NULL || config == NULL || stream_id_out == NULL) in cras_client_send_add_stream_command_message()
2403 rc = send_command_message(client, &cmd_msg.header); in cras_client_send_add_stream_command_message()
2421 int cras_client_add_stream(struct cras_client *client, in cras_client_add_stream() argument
2426 client, NO_DEVICE, stream_id_out, config); in cras_client_add_stream()
2429 int cras_client_add_pinned_stream(struct cras_client *client, uint32_t dev_idx, in cras_client_add_pinned_stream() argument
2434 client, dev_idx, stream_id_out, config); in cras_client_add_pinned_stream()
2437 int cras_client_rm_stream(struct cras_client *client, in cras_client_rm_stream() argument
2440 if (client == NULL) in cras_client_rm_stream()
2443 return send_simple_cmd_msg(client, stream_id, CLIENT_REMOVE_STREAM); in cras_client_rm_stream()
2446 int cras_client_set_stream_volume(struct cras_client *client, in cras_client_set_stream_volume() argument
2450 if (client == NULL) in cras_client_set_stream_volume()
2453 return send_stream_volume_command_msg(client, stream_id, volume_scaler); in cras_client_set_stream_volume()
2456 int cras_client_set_system_volume(struct cras_client *client, size_t volume) in cras_client_set_system_volume() argument
2460 if (client == NULL) in cras_client_set_system_volume()
2464 return write_message_to_server(client, &msg.header); in cras_client_set_system_volume()
2467 int cras_client_set_system_capture_gain(struct cras_client *client, long gain) in cras_client_set_system_capture_gain() argument
2471 if (client == NULL) in cras_client_set_system_capture_gain()
2475 return write_message_to_server(client, &msg.header); in cras_client_set_system_capture_gain()
2478 int cras_client_set_system_mute(struct cras_client *client, int mute) in cras_client_set_system_mute() argument
2482 if (client == NULL) in cras_client_set_system_mute()
2486 return write_message_to_server(client, &msg.header); in cras_client_set_system_mute()
2489 int cras_client_set_user_mute(struct cras_client *client, int mute) in cras_client_set_user_mute() argument
2493 if (client == NULL) in cras_client_set_user_mute()
2497 return write_message_to_server(client, &msg.header); in cras_client_set_user_mute()
2500 int cras_client_set_system_mute_locked(struct cras_client *client, int locked) in cras_client_set_system_mute_locked() argument
2504 if (client == NULL) in cras_client_set_system_mute_locked()
2508 return write_message_to_server(client, &msg.header); in cras_client_set_system_mute_locked()
2511 int cras_client_set_system_capture_mute(struct cras_client *client, int mute) in cras_client_set_system_capture_mute() argument
2515 if (client == NULL) in cras_client_set_system_capture_mute()
2519 return write_message_to_server(client, &msg.header); in cras_client_set_system_capture_mute()
2522 int cras_client_set_system_capture_mute_locked(struct cras_client *client, in cras_client_set_system_capture_mute_locked() argument
2527 if (client == NULL) in cras_client_set_system_capture_mute_locked()
2531 return write_message_to_server(client, &msg.header); in cras_client_set_system_capture_mute_locked()
2534 size_t cras_client_get_system_volume(const struct cras_client *client) in cras_client_get_system_volume() argument
2539 lock_rc = server_state_rdlock(client); in cras_client_get_system_volume()
2543 volume = client->server_state->volume; in cras_client_get_system_volume()
2544 server_state_unlock(client, lock_rc); in cras_client_get_system_volume()
2548 long cras_client_get_system_capture_gain(const struct cras_client *client) in cras_client_get_system_capture_gain() argument
2553 lock_rc = server_state_rdlock(client); in cras_client_get_system_capture_gain()
2557 gain = client->server_state->capture_gain; in cras_client_get_system_capture_gain()
2558 server_state_unlock(client, lock_rc); in cras_client_get_system_capture_gain()
2562 int cras_client_get_system_muted(const struct cras_client *client) in cras_client_get_system_muted() argument
2567 lock_rc = server_state_rdlock(client); in cras_client_get_system_muted()
2571 muted = client->server_state->mute; in cras_client_get_system_muted()
2572 server_state_unlock(client, lock_rc); in cras_client_get_system_muted()
2576 int cras_client_get_user_muted(const struct cras_client *client) in cras_client_get_user_muted() argument
2581 lock_rc = server_state_rdlock(client); in cras_client_get_user_muted()
2585 muted = client->server_state->user_mute; in cras_client_get_user_muted()
2586 server_state_unlock(client, lock_rc); in cras_client_get_user_muted()
2590 int cras_client_get_system_capture_muted(const struct cras_client *client) in cras_client_get_system_capture_muted() argument
2595 lock_rc = server_state_rdlock(client); in cras_client_get_system_capture_muted()
2599 muted = client->server_state->capture_mute; in cras_client_get_system_capture_muted()
2600 server_state_unlock(client, lock_rc); in cras_client_get_system_capture_muted()
2604 long cras_client_get_system_min_volume(const struct cras_client *client) in cras_client_get_system_min_volume() argument
2609 lock_rc = server_state_rdlock(client); in cras_client_get_system_min_volume()
2613 min_volume = client->server_state->min_volume_dBFS; in cras_client_get_system_min_volume()
2614 server_state_unlock(client, lock_rc); in cras_client_get_system_min_volume()
2618 long cras_client_get_system_max_volume(const struct cras_client *client) in cras_client_get_system_max_volume() argument
2623 lock_rc = server_state_rdlock(client); in cras_client_get_system_max_volume()
2627 max_volume = client->server_state->max_volume_dBFS; in cras_client_get_system_max_volume()
2628 server_state_unlock(client, lock_rc); in cras_client_get_system_max_volume()
2632 long cras_client_get_system_min_capture_gain(const struct cras_client *client) in cras_client_get_system_min_capture_gain() argument
2637 lock_rc = server_state_rdlock(client); in cras_client_get_system_min_capture_gain()
2641 min_gain = client->server_state->min_capture_gain; in cras_client_get_system_min_capture_gain()
2642 server_state_unlock(client, lock_rc); in cras_client_get_system_min_capture_gain()
2646 long cras_client_get_system_max_capture_gain(const struct cras_client *client) in cras_client_get_system_max_capture_gain() argument
2651 lock_rc = server_state_rdlock(client); in cras_client_get_system_max_capture_gain()
2655 max_gain = client->server_state->max_capture_gain; in cras_client_get_system_max_capture_gain()
2656 server_state_unlock(client, lock_rc); in cras_client_get_system_max_capture_gain()
2661 cras_client_get_audio_debug_info(const struct cras_client *client) in cras_client_get_audio_debug_info() argument
2666 lock_rc = server_state_rdlock(client); in cras_client_get_audio_debug_info()
2670 debug_info = &client->server_state->audio_debug_info; in cras_client_get_audio_debug_info()
2671 server_state_unlock(client, lock_rc); in cras_client_get_audio_debug_info()
2676 cras_client_get_bt_debug_info(const struct cras_client *client) in cras_client_get_bt_debug_info() argument
2681 lock_rc = server_state_rdlock(client); in cras_client_get_bt_debug_info()
2685 debug_info = &client->server_state->bt_debug_info; in cras_client_get_bt_debug_info()
2686 server_state_unlock(client, lock_rc); in cras_client_get_bt_debug_info()
2691 cras_client_get_audio_thread_snapshot_buffer(const struct cras_client *client) in cras_client_get_audio_thread_snapshot_buffer() argument
2696 lock_rc = server_state_rdlock(client); in cras_client_get_audio_thread_snapshot_buffer()
2700 snapshot_buffer = &client->server_state->snapshot_buffer; in cras_client_get_audio_thread_snapshot_buffer()
2701 server_state_unlock(client, lock_rc); in cras_client_get_audio_thread_snapshot_buffer()
2705 unsigned cras_client_get_num_active_streams(const struct cras_client *client, in cras_client_get_num_active_streams() argument
2711 lock_rc = server_state_rdlock(client); in cras_client_get_num_active_streams()
2716 version = begin_server_state_read(client->server_state); in cras_client_get_num_active_streams()
2719 num_streams += client->server_state->num_active_streams[i]; in cras_client_get_num_active_streams()
2726 &client->server_state->last_active_stream_time); in cras_client_get_num_active_streams()
2728 if (end_server_state_read(client->server_state, version)) in cras_client_get_num_active_streams()
2731 server_state_unlock(client, lock_rc); in cras_client_get_num_active_streams()
2735 int cras_client_run_thread(struct cras_client *client) in cras_client_run_thread() argument
2739 if (client == NULL) in cras_client_run_thread()
2741 if (thread_is_running(&client->thread)) in cras_client_run_thread()
2744 assert(client->command_reply_fds[0] == -1 && in cras_client_run_thread()
2745 client->command_reply_fds[1] == -1); in cras_client_run_thread()
2747 if (pipe(client->command_reply_fds) < 0) in cras_client_run_thread()
2749 client->thread.state = CRAS_THREAD_RUNNING; in cras_client_run_thread()
2750 rc = pthread_create(&client->thread.tid, NULL, client_thread, client); in cras_client_run_thread()
2752 client->thread.state = CRAS_THREAD_STOP; in cras_client_run_thread()
2759 int cras_client_stop(struct cras_client *client) in cras_client_stop() argument
2761 if (client == NULL) in cras_client_stop()
2763 if (!thread_is_running(&client->thread)) in cras_client_stop()
2766 send_simple_cmd_msg(client, 0, CLIENT_STOP); in cras_client_stop()
2767 pthread_join(client->thread.tid, NULL); in cras_client_stop()
2771 close(client->command_reply_fds[0]); in cras_client_stop()
2772 client->command_reply_fds[0] = -1; in cras_client_stop()
2778 struct cras_client *client, cras_connection_status_cb_t connection_cb, in cras_client_set_connection_status_cb() argument
2781 client->server_connection_cb = connection_cb; in cras_client_set_connection_status_cb()
2782 client->server_connection_user_arg = user_arg; in cras_client_set_connection_status_cb()
2785 void cras_client_set_thread_priority_cb(struct cras_client *client, in cras_client_set_thread_priority_cb() argument
2788 client->thread_priority_cb = cb; in cras_client_set_thread_priority_cb()
2791 int cras_client_get_output_devices(const struct cras_client *client, in cras_client_get_output_devices() argument
2800 lock_rc = server_state_rdlock(client); in cras_client_get_output_devices()
2803 state = client->server_state; in cras_client_get_output_devices()
2813 server_state_unlock(client, lock_rc); in cras_client_get_output_devices()
2821 int cras_client_get_input_devices(const struct cras_client *client, in cras_client_get_input_devices() argument
2830 lock_rc = server_state_rdlock(client); in cras_client_get_input_devices()
2831 if (!client) in cras_client_get_input_devices()
2833 state = client->server_state; in cras_client_get_input_devices()
2843 server_state_unlock(client, lock_rc); in cras_client_get_input_devices()
2851 int cras_client_get_attached_clients(const struct cras_client *client, in cras_client_get_attached_clients() argument
2859 lock_rc = server_state_rdlock(client); in cras_client_get_attached_clients()
2862 state = client->server_state; in cras_client_get_attached_clients()
2870 server_state_unlock(client, lock_rc); in cras_client_get_attached_clients()
2885 static int cras_client_find_output_node(const struct cras_client *client, in cras_client_find_output_node() argument
2897 if (!client || !dev_name || !node_name) in cras_client_find_output_node()
2912 rc = cras_client_get_output_devices(client, devs, nodes, &ndevs, in cras_client_find_output_node()
2942 int cras_client_get_node_by_id(const struct cras_client *client, int input, in cras_client_get_node_by_id() argument
2952 if (!client || !node_info) { in cras_client_get_node_by_id()
2974 rc = cras_client_get_input_devices(client, devs, nodes, &ndevs, in cras_client_get_node_by_id()
2977 rc = cras_client_get_output_devices(client, devs, nodes, &ndevs, in cras_client_get_node_by_id()
2998 int cras_client_output_dev_plugged(const struct cras_client *client, in cras_client_output_dev_plugged() argument
3004 if (cras_client_find_output_node(client, name, "Front Headphone Jack", in cras_client_output_dev_plugged()
3011 int cras_client_set_node_attr(struct cras_client *client, in cras_client_set_node_attr() argument
3017 if (client == NULL) in cras_client_set_node_attr()
3021 return write_message_to_server(client, &msg.header); in cras_client_set_node_attr()
3024 int cras_client_select_node(struct cras_client *client, in cras_client_select_node() argument
3030 if (client == NULL) in cras_client_select_node()
3034 return write_message_to_server(client, &msg.header); in cras_client_select_node()
3037 int cras_client_add_active_node(struct cras_client *client, in cras_client_add_active_node() argument
3043 if (client == NULL) in cras_client_add_active_node()
3047 return write_message_to_server(client, &msg.header); in cras_client_add_active_node()
3050 int cras_client_rm_active_node(struct cras_client *client, in cras_client_rm_active_node() argument
3056 if (client == NULL) in cras_client_rm_active_node()
3060 return write_message_to_server(client, &msg.header); in cras_client_rm_active_node()
3101 int cras_client_reload_dsp(struct cras_client *client) in cras_client_reload_dsp() argument
3105 if (client == NULL) in cras_client_reload_dsp()
3109 return write_message_to_server(client, &msg.header); in cras_client_reload_dsp()
3112 int cras_client_dump_dsp_info(struct cras_client *client) in cras_client_dump_dsp_info() argument
3116 if (client == NULL) in cras_client_dump_dsp_info()
3120 return write_message_to_server(client, &msg.header); in cras_client_dump_dsp_info()
3124 struct cras_client *client, void (*debug_info_cb)(struct cras_client *)) in cras_client_update_audio_debug_info() argument
3128 if (client == NULL) in cras_client_update_audio_debug_info()
3131 if (client->debug_info_callback != NULL) in cras_client_update_audio_debug_info()
3133 client->debug_info_callback = debug_info_cb; in cras_client_update_audio_debug_info()
3136 return write_message_to_server(client, &msg.header); in cras_client_update_audio_debug_info()
3139 int cras_client_get_atlog_access(struct cras_client *client, in cras_client_get_atlog_access() argument
3144 if (client == NULL) in cras_client_get_atlog_access()
3147 if (client->atlog_access_callback != NULL) in cras_client_get_atlog_access()
3149 client->atlog_access_callback = atlog_access_cb; in cras_client_get_atlog_access()
3152 return write_message_to_server(client, &msg.header); in cras_client_get_atlog_access()
3155 int cras_client_read_atlog(struct cras_client *client, uint64_t *read_idx, in cras_client_read_atlog() argument
3163 if (!client->atlog_ro) in cras_client_read_atlog()
3166 sync_write_pos = client->atlog_ro->sync_write_pos; in cras_client_read_atlog()
3168 memcpy(&log, client->atlog_ro, sizeof(log)); in cras_client_read_atlog()
3212 struct cras_client *client, void (*debug_info_cb)(struct cras_client *)) in cras_client_update_bt_debug_info() argument
3216 if (client == NULL) in cras_client_update_bt_debug_info()
3219 if (client->debug_info_callback != NULL) in cras_client_update_bt_debug_info()
3221 client->debug_info_callback = debug_info_cb; in cras_client_update_bt_debug_info()
3224 return write_message_to_server(client, &msg.header); in cras_client_update_bt_debug_info()
3228 struct cras_client *client, void (*debug_info_cb)(struct cras_client *)) in cras_client_update_audio_thread_snapshots() argument
3232 if (client == NULL) in cras_client_update_audio_thread_snapshots()
3235 if (client->debug_info_callback != NULL) in cras_client_update_audio_thread_snapshots()
3237 client->debug_info_callback = debug_info_cb; in cras_client_update_audio_thread_snapshots()
3240 return write_message_to_server(client, &msg.header); in cras_client_update_audio_thread_snapshots()
3243 int cras_client_set_node_volume(struct cras_client *client, in cras_client_set_node_volume() argument
3248 if (client == NULL) in cras_client_set_node_volume()
3252 return write_message_to_server(client, &msg.header); in cras_client_set_node_volume()
3255 int cras_client_swap_node_left_right(struct cras_client *client, in cras_client_swap_node_left_right() argument
3260 if (client == NULL) in cras_client_swap_node_left_right()
3265 return write_message_to_server(client, &msg.header); in cras_client_swap_node_left_right()
3268 int cras_client_set_node_capture_gain(struct cras_client *client, in cras_client_set_node_capture_gain() argument
3273 if (client == NULL) in cras_client_set_node_capture_gain()
3279 return write_message_to_server(client, &msg.header); in cras_client_set_node_capture_gain()
3282 int cras_client_add_test_iodev(struct cras_client *client, in cras_client_add_test_iodev() argument
3288 return write_message_to_server(client, &msg.header); in cras_client_add_test_iodev()
3291 int cras_client_test_iodev_command(struct cras_client *client, in cras_client_test_iodev_command() argument
3301 rc = write_message_to_server(client, &msg->header); in cras_client_test_iodev_command()
3306 int cras_client_config_global_remix(struct cras_client *client, in cras_client_config_global_remix() argument
3317 rc = write_message_to_server(client, &msg->header); in cras_client_config_global_remix()
3322 int cras_client_get_first_node_type_idx(const struct cras_client *client, in cras_client_get_first_node_type_idx() argument
3334 lock_rc = server_state_rdlock(client); in cras_client_get_first_node_type_idx()
3337 state = client->server_state; in cras_client_get_first_node_type_idx()
3352 server_state_unlock(client, lock_rc); in cras_client_get_first_node_type_idx()
3358 server_state_unlock(client, lock_rc); in cras_client_get_first_node_type_idx()
3363 int cras_client_get_first_dev_type_idx(const struct cras_client *client, in cras_client_get_first_dev_type_idx() argument
3370 rc = cras_client_get_first_node_type_idx(client, type, direction, in cras_client_get_first_dev_type_idx()
3378 int cras_client_set_suspend(struct cras_client *client, int suspend) in cras_client_set_suspend() argument
3383 return write_message_to_server(client, &msg); in cras_client_set_suspend()
3386 int cras_client_get_hotword_models(struct cras_client *client, in cras_client_get_hotword_models() argument
3392 if (!client) in cras_client_get_hotword_models()
3394 client->get_hotword_models_cb = cb; in cras_client_get_hotword_models()
3397 return write_message_to_server(client, &msg.header); in cras_client_get_hotword_models()
3400 int cras_client_set_hotword_model(struct cras_client *client, in cras_client_set_hotword_model() argument
3407 return write_message_to_server(client, &msg.header); in cras_client_set_hotword_model()
3410 int cras_client_set_aec_dump(struct cras_client *client, in cras_client_set_aec_dump() argument
3418 return cras_send_with_fds(client->server_fd, &msg, sizeof(msg), in cras_client_set_aec_dump()
3421 return write_message_to_server(client, &msg.header); in cras_client_set_aec_dump()
3424 int cras_client_reload_aec_config(struct cras_client *client) in cras_client_reload_aec_config() argument
3429 return write_message_to_server(client, &msg.header); in cras_client_reload_aec_config()
3432 int cras_client_get_aec_supported(struct cras_client *client) in cras_client_get_aec_supported() argument
3437 lock_rc = server_state_rdlock(client); in cras_client_get_aec_supported()
3441 aec_supported = client->server_state->aec_supported; in cras_client_get_aec_supported()
3442 server_state_unlock(client, lock_rc); in cras_client_get_aec_supported()
3446 int cras_client_get_aec_group_id(struct cras_client *client) in cras_client_get_aec_group_id() argument
3451 lock_rc = server_state_rdlock(client); in cras_client_get_aec_group_id()
3455 aec_group_id = client->server_state->aec_group_id; in cras_client_get_aec_group_id()
3456 server_state_unlock(client, lock_rc); in cras_client_get_aec_group_id()
3460 int cras_client_set_bt_wbs_enabled(struct cras_client *client, bool enabled) in cras_client_set_bt_wbs_enabled() argument
3465 return write_message_to_server(client, &msg.header); in cras_client_set_bt_wbs_enabled()
3468 void cras_client_set_state_change_callback_context(struct cras_client *client, in cras_client_set_state_change_callback_context() argument
3471 if (!client) in cras_client_set_state_change_callback_context()
3473 client->observer_context = context; in cras_client_set_state_change_callback_context()
3476 static int cras_send_register_notification(struct cras_client *client, in cras_send_register_notification() argument
3487 rc = write_message_to_server(client, &msg.header); in cras_send_register_notification()
3494 struct cras_client *client, in cras_client_set_output_volume_changed_callback() argument
3497 if (!client) in cras_client_set_output_volume_changed_callback()
3499 client->observer_ops.output_volume_changed = cb; in cras_client_set_output_volume_changed_callback()
3501 client, CRAS_CLIENT_OUTPUT_VOLUME_CHANGED, cb != NULL); in cras_client_set_output_volume_changed_callback()
3505 struct cras_client *client, cras_client_output_mute_changed_callback cb) in cras_client_set_output_mute_changed_callback() argument
3507 if (!client) in cras_client_set_output_mute_changed_callback()
3509 client->observer_ops.output_mute_changed = cb; in cras_client_set_output_mute_changed_callback()
3511 client, CRAS_CLIENT_OUTPUT_MUTE_CHANGED, cb != NULL); in cras_client_set_output_mute_changed_callback()
3515 struct cras_client *client, in cras_client_set_capture_gain_changed_callback() argument
3518 if (!client) in cras_client_set_capture_gain_changed_callback()
3520 client->observer_ops.capture_gain_changed = cb; in cras_client_set_capture_gain_changed_callback()
3522 client, CRAS_CLIENT_CAPTURE_GAIN_CHANGED, cb != NULL); in cras_client_set_capture_gain_changed_callback()
3526 struct cras_client *client, in cras_client_set_capture_mute_changed_callback() argument
3529 if (!client) in cras_client_set_capture_mute_changed_callback()
3531 client->observer_ops.capture_mute_changed = cb; in cras_client_set_capture_mute_changed_callback()
3533 client, CRAS_CLIENT_CAPTURE_MUTE_CHANGED, cb != NULL); in cras_client_set_capture_mute_changed_callback()
3537 struct cras_client *client, cras_client_nodes_changed_callback cb) in cras_client_set_nodes_changed_callback() argument
3539 if (!client) in cras_client_set_nodes_changed_callback()
3541 client->observer_ops.nodes_changed = cb; in cras_client_set_nodes_changed_callback()
3543 client, CRAS_CLIENT_NODES_CHANGED, cb != NULL); in cras_client_set_nodes_changed_callback()
3547 struct cras_client *client, cras_client_active_node_changed_callback cb) in cras_client_set_active_node_changed_callback() argument
3549 if (!client) in cras_client_set_active_node_changed_callback()
3551 client->observer_ops.active_node_changed = cb; in cras_client_set_active_node_changed_callback()
3553 client, CRAS_CLIENT_ACTIVE_NODE_CHANGED, cb != NULL); in cras_client_set_active_node_changed_callback()
3557 struct cras_client *client, in cras_client_set_output_node_volume_changed_callback() argument
3560 if (!client) in cras_client_set_output_node_volume_changed_callback()
3562 client->observer_ops.output_node_volume_changed = cb; in cras_client_set_output_node_volume_changed_callback()
3564 client, CRAS_CLIENT_OUTPUT_NODE_VOLUME_CHANGED, cb != NULL); in cras_client_set_output_node_volume_changed_callback()
3568 struct cras_client *client, in cras_client_set_node_left_right_swapped_changed_callback() argument
3571 if (!client) in cras_client_set_node_left_right_swapped_changed_callback()
3573 client->observer_ops.node_left_right_swapped_changed = cb; in cras_client_set_node_left_right_swapped_changed_callback()
3575 client, CRAS_CLIENT_NODE_LEFT_RIGHT_SWAPPED_CHANGED, in cras_client_set_node_left_right_swapped_changed_callback()
3580 struct cras_client *client, in cras_client_set_input_node_gain_changed_callback() argument
3583 if (!client) in cras_client_set_input_node_gain_changed_callback()
3585 client->observer_ops.input_node_gain_changed = cb; in cras_client_set_input_node_gain_changed_callback()
3587 client, CRAS_CLIENT_INPUT_NODE_GAIN_CHANGED, cb != NULL); in cras_client_set_input_node_gain_changed_callback()
3591 struct cras_client *client, in cras_client_set_num_active_streams_changed_callback() argument
3594 if (!client) in cras_client_set_num_active_streams_changed_callback()
3596 client->observer_ops.num_active_streams_changed = cb; in cras_client_set_num_active_streams_changed_callback()
3598 client, CRAS_CLIENT_NUM_ACTIVE_STREAMS_CHANGED, cb != NULL); in cras_client_set_num_active_streams_changed_callback()
3601 static int reregister_notifications(struct cras_client *client) in reregister_notifications() argument
3605 if (client->observer_ops.output_volume_changed) { in reregister_notifications()
3607 client, client->observer_ops.output_volume_changed); in reregister_notifications()
3611 if (client->observer_ops.output_mute_changed) { in reregister_notifications()
3613 client, client->observer_ops.output_mute_changed); in reregister_notifications()
3617 if (client->observer_ops.capture_gain_changed) { in reregister_notifications()
3619 client, client->observer_ops.capture_gain_changed); in reregister_notifications()
3623 if (client->observer_ops.capture_mute_changed) { in reregister_notifications()
3625 client, client->observer_ops.capture_mute_changed); in reregister_notifications()
3629 if (client->observer_ops.nodes_changed) { in reregister_notifications()
3631 client, client->observer_ops.nodes_changed); in reregister_notifications()
3635 if (client->observer_ops.active_node_changed) { in reregister_notifications()
3637 client, client->observer_ops.active_node_changed); in reregister_notifications()
3641 if (client->observer_ops.output_node_volume_changed) { in reregister_notifications()
3643 client, in reregister_notifications()
3644 client->observer_ops.output_node_volume_changed); in reregister_notifications()
3648 if (client->observer_ops.node_left_right_swapped_changed) { in reregister_notifications()
3650 client, in reregister_notifications()
3651 client->observer_ops.node_left_right_swapped_changed); in reregister_notifications()
3655 if (client->observer_ops.input_node_gain_changed) { in reregister_notifications()
3657 client, client->observer_ops.input_node_gain_changed); in reregister_notifications()
3661 if (client->observer_ops.num_active_streams_changed) { in reregister_notifications()
3663 client, in reregister_notifications()
3664 client->observer_ops.num_active_streams_changed); in reregister_notifications()
3671 static int hotword_read_cb(struct cras_client *client, in hotword_read_cb() argument
3682 handle->trigger_cb(client, handle, handle->user_data); in hotword_read_cb()
3687 static int hotword_err_cb(struct cras_client *client, in hotword_err_cb() argument
3694 handle->err_cb(client, handle, error, handle->user_data); in hotword_err_cb()
3699 int cras_client_enable_hotword_callback(struct cras_client *client, in cras_client_enable_hotword_callback() argument
3708 if (!client) in cras_client_enable_hotword_callback()
3735 ret = cras_client_add_stream(client, &handle->stream_id, in cras_client_enable_hotword_callback()
3752 int cras_client_disable_hotword_callback(struct cras_client *client, in cras_client_disable_hotword_callback() argument
3755 if (!client || !handle) in cras_client_disable_hotword_callback()
3758 cras_client_rm_stream(client, handle->stream_id); in cras_client_disable_hotword_callback()