Lines Matching refs:l
56 static int reduce(pa_shmasyncq *l, int value) { in reduce() argument
57 return value & (unsigned) (l->n_elements - 1); in reduce()
60 static pa_atomic_t* get_cell(pa_shmasyncq *l, unsigned i) { in get_cell() argument
61 pa_assert(i < l->data->n_elements); in get_cell()
63 …return (pa_atomic_t*) ((uint8*t) l->data + PA_ALIGN(sizeof(pa_shmasyncq_data)) + i * (PA_ALIGN(siz… in get_cell()
71 pa_shmasyncq *l;
79 l = pa_xnew(pa_shmasyncq, 1);
81 l->data = data;
84 l->data->n_elements = n_elements;
85 l->data->element_size = element_size;
87 if (!(l->read_fdsem = pa_fdsem_new_shm(&d->read_fdsem_data))) {
88 pa_xfree(l);
91 fd[0] = pa_fdsem_get(l->read_fdsem);
93 if (!(l->write_fdsem = pa_fdsem_new(&d->write_fdsem_data, &fd[1]))) {
94 pa_fdsem_free(l->read_fdsem);
95 pa_xfree(l);
99 return l;
102 void pa_shmasyncq_free(pa_shmasyncq *l, pa_free_cb_t free_cb) {
103 pa_assert(l);
108 while ((p = pa_shmasyncq_pop(l, 0)))
112 pa_fdsem_free(l->read_fdsem);
113 pa_fdsem_free(l->write_fdsem);
114 pa_xfree(l);
117 int pa_shmasyncq_push(pa_shmasyncq*l, void *p, int wait) {
121 pa_assert(l);
124 cells = PA_SHMASYNCQ_CELLS(l);
127 idx = reduce(l, l->write_idx);
137 pa_fdsem_wait(l->read_fdsem);
142 l->write_idx++;
144 pa_fdsem_post(l->write_fdsem);
149 void* pa_shmasyncq_pop(pa_shmasyncq*l, int wait) {
154 pa_assert(l);
156 cells = PA_SHMASYNCQ_CELLS(l);
159 idx = reduce(l, l->read_idx);
169 pa_fdsem_wait(l->write_fdsem);
179 l->read_idx++;
181 pa_fdsem_post(l->read_fdsem);
192 int pa_shmasyncq_before_poll(pa_shmasyncq *l) {
196 pa_assert(l);
198 cells = PA_SHMASYNCQ_CELLS(l);
201 idx = reduce(l, l->read_idx);
207 if (pa_fdsem_before_poll(l->write_fdsem) >= 0)
214 void pa_shmasyncq_after_poll(pa_shmasyncq *l) {
215 pa_assert(l);
217 pa_fdsem_after_poll(l->write_fdsem);