summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEn-Shuo Hsu <enshuo@chromium.org>2019-06-21 19:40:08 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-07-03 02:03:13 -0700
commit4bbcf430903caf62729aa1993599571cf945344a (patch)
tree6f9d878581124339dfe17cc378bf0c5ae6450a24
parent0c96f31233c5eb40bb15ae4162c4b9230c7624a4 (diff)
downloadadhd-4bbcf430903caf62729aa1993599571cf945344a.tar.gz
CRAS: Format cras_observer
Reformat codes with the .clang-format we just introduced. To format whole files provided in-place: clang-format -i -style=file [<file> ...] BUG=chromium:950858 TEST=Add directory to check_format_error and run FEATURES="test" USE=asan emerge-${BOARD} -v media-sound/adhd Change-Id: I3a9a6062fef3d84533029d64a133a6cfc5520482 Reviewed-on: https://chromium-review.googlesource.com/1670831 Tested-by: En-Shuo Hsu <enshuo@google.com> Commit-Ready: En-Shuo Hsu <enshuo@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
-rw-r--r--cras/src/server/cras_observer.c209
-rw-r--r--cras/src/server/cras_observer.h8
2 files changed, 102 insertions, 115 deletions
diff --git a/cras/src/server/cras_observer.c b/cras/src/server/cras_observer.c
index caff00d8..0f6ab96b 100644
--- a/cras/src/server/cras_observer.c
+++ b/cras/src/server/cras_observer.c
@@ -100,11 +100,10 @@ static void output_volume_alert(void *arg, void *data)
struct cras_observer_alert_data_volume *volume_data =
(struct cras_observer_alert_data_volume *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.output_volume_changed)
- client->ops.output_volume_changed(
- client->context,
- volume_data->volume);
+ client->ops.output_volume_changed(client->context,
+ volume_data->volume);
}
}
@@ -114,13 +113,12 @@ static void output_mute_alert(void *arg, void *data)
struct cras_observer_alert_data_mute *mute_data =
(struct cras_observer_alert_data_mute *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.output_mute_changed)
- client->ops.output_mute_changed(
- client->context,
- mute_data->muted,
- mute_data->user_muted,
- mute_data->mute_locked);
+ client->ops.output_mute_changed(client->context,
+ mute_data->muted,
+ mute_data->user_muted,
+ mute_data->mute_locked);
}
}
@@ -130,11 +128,10 @@ static void capture_gain_alert(void *arg, void *data)
struct cras_observer_alert_data_volume *volume_data =
(struct cras_observer_alert_data_volume *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.capture_gain_changed)
- client->ops.capture_gain_changed(
- client->context,
- volume_data->volume);
+ client->ops.capture_gain_changed(client->context,
+ volume_data->volume);
}
}
@@ -144,12 +141,11 @@ static void capture_mute_alert(void *arg, void *data)
struct cras_observer_alert_data_mute *mute_data =
(struct cras_observer_alert_data_mute *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.capture_mute_changed)
client->ops.capture_mute_changed(
- client->context,
- mute_data->muted,
- mute_data->mute_locked);
+ client->context, mute_data->muted,
+ mute_data->mute_locked);
}
}
@@ -162,7 +158,7 @@ static void nodes_alert(void *arg, void *data)
{
struct cras_observer_client *client;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.nodes_changed)
client->ops.nodes_changed(client->context);
}
@@ -174,12 +170,11 @@ static void active_node_alert(void *arg, void *data)
struct cras_observer_alert_data_active_node *node_data =
(struct cras_observer_alert_data_active_node *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.active_node_changed)
- client->ops.active_node_changed(
- client->context,
- node_data->direction,
- node_data->node_id);
+ client->ops.active_node_changed(client->context,
+ node_data->direction,
+ node_data->node_id);
}
}
@@ -189,12 +184,11 @@ static void output_node_volume_alert(void *arg, void *data)
struct cras_observer_alert_data_node_volume *node_data =
(struct cras_observer_alert_data_node_volume *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.output_node_volume_changed)
client->ops.output_node_volume_changed(
- client->context,
- node_data->node_id,
- node_data->volume);
+ client->context, node_data->node_id,
+ node_data->volume);
}
}
@@ -204,12 +198,11 @@ static void node_left_right_swapped_alert(void *arg, void *data)
struct cras_observer_alert_data_node_lr_swapped *node_data =
(struct cras_observer_alert_data_node_lr_swapped *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.node_left_right_swapped_changed)
client->ops.node_left_right_swapped_changed(
- client->context,
- node_data->node_id,
- node_data->swapped);
+ client->context, node_data->node_id,
+ node_data->swapped);
}
}
@@ -219,12 +212,11 @@ static void input_node_gain_alert(void *arg, void *data)
struct cras_observer_alert_data_node_volume *node_data =
(struct cras_observer_alert_data_node_volume *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.input_node_gain_changed)
- client->ops.input_node_gain_changed(
- client->context,
- node_data->node_id,
- node_data->volume);
+ client->ops.input_node_gain_changed(client->context,
+ node_data->node_id,
+ node_data->volume);
}
}
@@ -234,11 +226,10 @@ static void suspend_changed_alert(void *arg, void *data)
struct cras_observer_alert_data_suspend *suspend_data =
(struct cras_observer_alert_data_suspend *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.suspend_changed)
- client->ops.suspend_changed(
- client->context,
- suspend_data->suspended);
+ client->ops.suspend_changed(client->context,
+ suspend_data->suspended);
}
}
@@ -248,12 +239,11 @@ static void num_active_streams_alert(void *arg, void *data)
struct cras_observer_alert_data_streams *streams_data =
(struct cras_observer_alert_data_streams *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.num_active_streams_changed)
client->ops.num_active_streams_changed(
- client->context,
- streams_data->direction,
- streams_data->num_active_streams);
+ client->context, streams_data->direction,
+ streams_data->num_active_streams);
}
}
@@ -263,12 +253,11 @@ static void hotword_triggered_alert(void *arg, void *data)
struct cras_observer_alert_data_hotword_triggered *triggered_data =
(struct cras_observer_alert_data_hotword_triggered *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.hotword_triggered)
- client->ops.hotword_triggered(
- client->context,
- triggered_data->tv_sec,
- triggered_data->tv_nsec);
+ client->ops.hotword_triggered(client->context,
+ triggered_data->tv_sec,
+ triggered_data->tv_nsec);
}
}
@@ -276,13 +265,13 @@ static void non_empty_audio_state_changed_alert(void *arg, void *data)
{
struct cras_observer_client *client;
struct cras_observer_non_empty_audio_state *non_empty_audio_data =
- (struct cras_observer_non_empty_audio_state *)data;
+ (struct cras_observer_non_empty_audio_state *)data;
- DL_FOREACH(g_observer->clients, client) {
+ DL_FOREACH (g_observer->clients, client) {
if (client->ops.non_empty_audio_state_changed) {
client->ops.non_empty_audio_state_changed(
- client->context,
- non_empty_audio_data->non_empty);
+ client->context,
+ non_empty_audio_data->non_empty);
}
}
}
@@ -298,23 +287,23 @@ static int cras_observer_server_set_alert(struct cras_alert **alert,
return cras_alert_add_callback(*alert, cb, NULL);
}
-#define CRAS_OBSERVER_SET_ALERT(alert,prepare,flags) \
- do { \
- rc = cras_observer_server_set_alert( \
- &g_observer->alerts.alert, alert##_alert, \
- prepare, flags); \
- if (rc) \
- goto error; \
- } while(0)
-
-#define CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(alert,direction) \
- do { \
- rc = cras_observer_server_set_alert( \
- &g_observer->alerts.alert[direction], \
- alert##_alert, NULL, 0); \
- if (rc) \
- goto error; \
- } while(0)
+#define CRAS_OBSERVER_SET_ALERT(alert, prepare, flags) \
+ do { \
+ rc = cras_observer_server_set_alert(&g_observer->alerts.alert, \
+ alert##_alert, prepare, \
+ flags); \
+ if (rc) \
+ goto error; \
+ } while (0)
+
+#define CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(alert, direction) \
+ do { \
+ rc = cras_observer_server_set_alert( \
+ &g_observer->alerts.alert[direction], alert##_alert, \
+ NULL, 0); \
+ if (rc) \
+ goto error; \
+ } while (0)
/*
* Public interface
@@ -325,8 +314,8 @@ int cras_observer_server_init()
int rc;
memset(&g_empty_ops, 0, sizeof(g_empty_ops));
- g_observer = (struct cras_observer_server *)
- calloc(1, sizeof(struct cras_observer_server));
+ g_observer = (struct cras_observer_server *)calloc(
+ 1, sizeof(struct cras_observer_server));
if (!g_observer)
return -ENOMEM;
@@ -344,12 +333,12 @@ int cras_observer_server_init()
CRAS_OBSERVER_SET_ALERT(hotword_triggered, NULL, 0);
CRAS_OBSERVER_SET_ALERT(non_empty_audio_state_changed, NULL, 0);
- CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(
- num_active_streams, CRAS_STREAM_OUTPUT);
- CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(
- num_active_streams, CRAS_STREAM_INPUT);
- CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(
- num_active_streams, CRAS_STREAM_POST_MIX_PRE_DSP);
+ CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(num_active_streams,
+ CRAS_STREAM_OUTPUT);
+ CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(num_active_streams,
+ CRAS_STREAM_INPUT);
+ CRAS_OBSERVER_SET_ALERT_WITH_DIRECTION(num_active_streams,
+ CRAS_STREAM_POST_MIX_PRE_DSP);
return 0;
@@ -374,12 +363,13 @@ void cras_observer_server_free()
cras_alert_destroy(g_observer->alerts.suspend_changed);
cras_alert_destroy(g_observer->alerts.hotword_triggered);
cras_alert_destroy(g_observer->alerts.non_empty_audio_state_changed);
- cras_alert_destroy(g_observer->alerts.num_active_streams[
- CRAS_STREAM_OUTPUT]);
- cras_alert_destroy(g_observer->alerts.num_active_streams[
- CRAS_STREAM_INPUT]);
- cras_alert_destroy(g_observer->alerts.num_active_streams[
- CRAS_STREAM_POST_MIX_PRE_DSP]);
+ cras_alert_destroy(
+ g_observer->alerts.num_active_streams[CRAS_STREAM_OUTPUT]);
+ cras_alert_destroy(
+ g_observer->alerts.num_active_streams[CRAS_STREAM_INPUT]);
+ cras_alert_destroy(
+ g_observer->alerts
+ .num_active_streams[CRAS_STREAM_POST_MIX_PRE_DSP]);
free(g_observer);
g_observer = NULL;
}
@@ -411,9 +401,8 @@ void cras_observer_set_ops(struct cras_observer_client *client,
memcpy(&client->ops, ops, sizeof(client->ops));
}
-struct cras_observer_client *cras_observer_add(
- const struct cras_observer_ops *ops,
- void *context)
+struct cras_observer_client *
+cras_observer_add(const struct cras_observer_ops *ops, void *context)
{
struct cras_observer_client *client;
@@ -443,8 +432,8 @@ void cras_observer_notify_output_volume(int32_t volume)
struct cras_observer_alert_data_volume data;
data.volume = volume;
- cras_alert_pending_data(g_observer->alerts.output_volume,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.output_volume, &data,
+ sizeof(data));
}
void cras_observer_notify_output_mute(int muted, int user_muted,
@@ -455,8 +444,8 @@ void cras_observer_notify_output_mute(int muted, int user_muted,
data.muted = muted;
data.user_muted = user_muted;
data.mute_locked = mute_locked;
- cras_alert_pending_data(g_observer->alerts.output_mute,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.output_mute, &data,
+ sizeof(data));
}
void cras_observer_notify_capture_gain(int32_t gain)
@@ -464,8 +453,8 @@ void cras_observer_notify_capture_gain(int32_t gain)
struct cras_observer_alert_data_volume data;
data.volume = gain;
- cras_alert_pending_data(g_observer->alerts.capture_gain,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.capture_gain, &data,
+ sizeof(data));
}
void cras_observer_notify_capture_mute(int muted, int mute_locked)
@@ -475,8 +464,8 @@ void cras_observer_notify_capture_mute(int muted, int mute_locked)
data.muted = muted;
data.user_muted = 0;
data.mute_locked = mute_locked;
- cras_alert_pending_data(g_observer->alerts.capture_mute,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.capture_mute, &data,
+ sizeof(data));
}
void cras_observer_notify_nodes(void)
@@ -491,8 +480,8 @@ void cras_observer_notify_active_node(enum CRAS_STREAM_DIRECTION dir,
data.direction = dir;
data.node_id = node_id;
- cras_alert_pending_data(g_observer->alerts.active_node,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.active_node, &data,
+ sizeof(data));
}
void cras_observer_notify_output_node_volume(cras_node_id_t node_id,
@@ -502,8 +491,8 @@ void cras_observer_notify_output_node_volume(cras_node_id_t node_id,
data.node_id = node_id;
data.volume = volume;
- cras_alert_pending_data(g_observer->alerts.output_node_volume,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.output_node_volume, &data,
+ sizeof(data));
}
void cras_observer_notify_node_left_right_swapped(cras_node_id_t node_id,
@@ -517,15 +506,14 @@ void cras_observer_notify_node_left_right_swapped(cras_node_id_t node_id,
&data, sizeof(data));
}
-void cras_observer_notify_input_node_gain(cras_node_id_t node_id,
- int32_t gain)
+void cras_observer_notify_input_node_gain(cras_node_id_t node_id, int32_t gain)
{
struct cras_observer_alert_data_node_volume data;
data.node_id = node_id;
data.volume = gain;
- cras_alert_pending_data(g_observer->alerts.input_node_gain,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.input_node_gain, &data,
+ sizeof(data));
}
void cras_observer_notify_suspend_changed(int suspended)
@@ -533,8 +521,8 @@ void cras_observer_notify_suspend_changed(int suspended)
struct cras_observer_alert_data_suspend data;
data.suspended = suspended;
- cras_alert_pending_data(g_observer->alerts.suspend_changed,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.suspend_changed, &data,
+ sizeof(data));
}
void cras_observer_notify_num_active_streams(enum CRAS_STREAM_DIRECTION dir,
@@ -558,8 +546,8 @@ void cras_observer_notify_hotword_triggered(int64_t tv_sec, int64_t tv_nsec)
data.tv_sec = tv_sec;
data.tv_nsec = tv_nsec;
- cras_alert_pending_data(g_observer->alerts.hotword_triggered,
- &data, sizeof(data));
+ cras_alert_pending_data(g_observer->alerts.hotword_triggered, &data,
+ sizeof(data));
}
void cras_observer_notify_non_empty_audio_state_changed(int non_empty)
@@ -568,6 +556,7 @@ void cras_observer_notify_non_empty_audio_state_changed(int non_empty)
data.non_empty = non_empty;
- cras_alert_pending_data(g_observer->alerts.non_empty_audio_state_changed,
- &data, sizeof(data));
+ cras_alert_pending_data(
+ g_observer->alerts.non_empty_audio_state_changed, &data,
+ sizeof(data));
} \ No newline at end of file
diff --git a/cras/src/server/cras_observer.h b/cras/src/server/cras_observer.h
index 440a8cee..109bd609 100644
--- a/cras/src/server/cras_observer.h
+++ b/cras/src/server/cras_observer.h
@@ -19,9 +19,8 @@ struct cras_observer_client;
* Valid pointer to the client reference, or NULL on memory allocation
* error.
*/
-struct cras_observer_client *cras_observer_add(
- const struct cras_observer_ops *ops,
- void *context);
+struct cras_observer_client *
+cras_observer_add(const struct cras_observer_ops *ops, void *context);
/* Retrieve the observed state changes.
* Args:
@@ -84,8 +83,7 @@ void cras_observer_notify_node_left_right_swapped(cras_node_id_t node_id,
int swapped);
/* Notify observers of input node gain change. */
-void cras_observer_notify_input_node_gain(cras_node_id_t node_id,
- int32_t gain);
+void cras_observer_notify_input_node_gain(cras_node_id_t node_id, int32_t gain);
/* Notify observers of suspend state changed. */
void cras_observer_notify_suspend_changed(int suspended);