Lines Matching refs:alert
45 struct cras_alert *alert; in cras_alert_create() local
46 alert = calloc(1, sizeof(*alert)); in cras_alert_create()
47 if (!alert) in cras_alert_create()
49 alert->prepare = prepare; in cras_alert_create()
50 alert->flags = flags; in cras_alert_create()
51 DL_APPEND(all_alerts, alert); in cras_alert_create()
52 return alert; in cras_alert_create()
55 int cras_alert_add_callback(struct cras_alert *alert, cras_alert_cb cb, in cras_alert_add_callback() argument
63 DL_FOREACH (alert->callbacks, alert_cb) in cras_alert_add_callback()
72 DL_APPEND(alert->callbacks, alert_cb); in cras_alert_add_callback()
76 int cras_alert_rm_callback(struct cras_alert *alert, cras_alert_cb cb, in cras_alert_rm_callback() argument
81 DL_FOREACH (alert->callbacks, alert_cb) in cras_alert_rm_callback()
83 DL_DELETE(alert->callbacks, alert_cb); in cras_alert_rm_callback()
92 static void cras_alert_process(struct cras_alert *alert) in cras_alert_process() argument
97 if (!alert->pending) in cras_alert_process()
100 alert->pending = 0; in cras_alert_process()
101 if (alert->prepare) in cras_alert_process()
102 alert->prepare(alert); in cras_alert_process()
104 if (!alert->data) { in cras_alert_process()
105 DL_FOREACH (alert->callbacks, cb) in cras_alert_process()
110 DL_FOREACH (alert->data, data) { in cras_alert_process()
111 DL_FOREACH (alert->callbacks, cb) in cras_alert_process()
113 DL_DELETE(alert->data, data); in cras_alert_process()
118 void cras_alert_pending(struct cras_alert *alert) in cras_alert_pending() argument
120 alert->pending = 1; in cras_alert_pending()
124 void cras_alert_pending_data(struct cras_alert *alert, void *data, in cras_alert_pending_data() argument
129 alert->pending = 1; in cras_alert_pending_data()
134 if (!(alert->flags & CRAS_ALERT_FLAG_KEEP_ALL_DATA) && alert->data) { in cras_alert_pending_data()
136 free(alert->data); in cras_alert_pending_data()
137 alert->data = NULL; in cras_alert_pending_data()
142 DL_APPEND(alert->data, d); in cras_alert_pending_data()
147 struct cras_alert *alert; in cras_alert_process_all_pending_alerts() local
151 DL_FOREACH (all_alerts, alert) in cras_alert_process_all_pending_alerts()
152 cras_alert_process(alert); in cras_alert_process_all_pending_alerts()
156 void cras_alert_destroy(struct cras_alert *alert) in cras_alert_destroy() argument
161 if (!alert) in cras_alert_destroy()
164 DL_FOREACH (alert->callbacks, cb) { in cras_alert_destroy()
165 DL_DELETE(alert->callbacks, cb); in cras_alert_destroy()
169 DL_FOREACH (alert->data, data) { in cras_alert_destroy()
170 DL_DELETE(alert->data, data); in cras_alert_destroy()
174 alert->callbacks = NULL; in cras_alert_destroy()
175 DL_DELETE(all_alerts, alert); in cras_alert_destroy()
176 free(alert); in cras_alert_destroy()
181 struct cras_alert *alert; in cras_alert_destroy_all() local
182 DL_FOREACH (all_alerts, alert) in cras_alert_destroy_all()
183 cras_alert_destroy(alert); in cras_alert_destroy_all()