• Home
  • Raw
  • Download

Lines Matching full:info

56 int hfp_info_add_iodev(struct hfp_info *info, struct cras_iodev *dev)  in hfp_info_add_iodev()  argument
59 if (info->odev) in hfp_info_add_iodev()
61 info->odev = dev; in hfp_info_add_iodev()
63 buf_reset(info->playback_buf); in hfp_info_add_iodev()
65 if (info->idev) in hfp_info_add_iodev()
67 info->idev = dev; in hfp_info_add_iodev()
69 buf_reset(info->capture_buf); in hfp_info_add_iodev()
78 int hfp_info_rm_iodev(struct hfp_info *info, struct cras_iodev *dev) in hfp_info_rm_iodev() argument
80 if (dev->direction == CRAS_STREAM_OUTPUT && info->odev == dev) { in hfp_info_rm_iodev()
81 info->odev = NULL; in hfp_info_rm_iodev()
82 } else if (dev->direction == CRAS_STREAM_INPUT && info->idev == dev){ in hfp_info_rm_iodev()
83 info->idev = NULL; in hfp_info_rm_iodev()
90 int hfp_info_has_iodev(struct hfp_info *info) in hfp_info_has_iodev() argument
92 return info->odev || info->idev; in hfp_info_has_iodev()
95 void hfp_buf_acquire(struct hfp_info *info, struct cras_iodev *dev, in hfp_buf_acquire() argument
105 *buf = buf_write_pointer_size(info->playback_buf, &buf_avail); in hfp_buf_acquire()
107 *buf = buf_read_pointer_size(info->capture_buf, &buf_avail); in hfp_buf_acquire()
114 int hfp_buf_size(struct hfp_info *info, struct cras_iodev *dev) in hfp_buf_size() argument
116 return info->playback_buf->used_size / cras_get_format_bytes(dev->format); in hfp_buf_size()
119 void hfp_buf_release(struct hfp_info *info, struct cras_iodev *dev, in hfp_buf_release() argument
128 buf_increment_write(info->playback_buf, written_frames); in hfp_buf_release()
130 buf_increment_read(info->capture_buf, written_frames); in hfp_buf_release()
133 int hfp_buf_queued(struct hfp_info *info, const struct cras_iodev *dev) in hfp_buf_queued() argument
139 return buf_queued(info->playback_buf) / format_bytes; in hfp_buf_queued()
141 return buf_queued(info->capture_buf) / format_bytes; in hfp_buf_queued()
144 int hfp_write(struct hfp_info *info) in hfp_write() argument
151 samples = buf_read_pointer_size(info->playback_buf, &to_send); in hfp_write()
152 if (to_send < info->packet_size) in hfp_write()
154 to_send = info->packet_size; in hfp_write()
157 err = send(info->fd, samples, to_send, 0); in hfp_write()
165 if (err != (int)info->packet_size) { in hfp_write()
168 err, info->packet_size); in hfp_write()
172 buf_increment_read(info->playback_buf, to_send); in hfp_write()
178 static void hfp_info_set_packet_size(struct hfp_info *info, in hfp_info_set_packet_size() argument
184 info->packet_size = packet_size; in hfp_info_set_packet_size()
185 byte_buffer_set_used_size(info->playback_buf, used_size); in hfp_info_set_packet_size()
186 byte_buffer_set_used_size(info->capture_buf, used_size); in hfp_info_set_packet_size()
188 DL_FOREACH(info->packet_size_changed_cbs, callback) in hfp_info_set_packet_size()
192 void hfp_register_packet_size_changed_callback(struct hfp_info *info, in hfp_register_packet_size_changed_callback() argument
201 DL_APPEND(info->packet_size_changed_cbs, callback); in hfp_register_packet_size_changed_callback()
204 void hfp_unregister_packet_size_changed_callback(struct hfp_info *info, in hfp_unregister_packet_size_changed_callback() argument
208 DL_FOREACH(info->packet_size_changed_cbs, callback) { in hfp_unregister_packet_size_changed_callback()
210 DL_DELETE(info->packet_size_changed_cbs, callback); in hfp_unregister_packet_size_changed_callback()
216 int hfp_read(struct hfp_info *info) in hfp_read() argument
222 capture_buf = buf_write_pointer_size(info->capture_buf, &to_read); in hfp_read()
224 if (to_read < info->packet_size) in hfp_read()
226 to_read = info->packet_size; in hfp_read()
229 err = recv(info->fd, capture_buf, to_read, 0); in hfp_read()
238 if (err != (int)info->packet_size) { in hfp_read()
244 if (err && (info->packet_size == info->mtu)) { in hfp_read()
245 hfp_info_set_packet_size(info, err); in hfp_read()
248 err, info->packet_size); in hfp_read()
253 buf_increment_write(info->capture_buf, err); in hfp_read()
269 struct hfp_info *info = (struct hfp_info *)arg; in hfp_info_callback() local
272 if (!info->started) in hfp_info_callback()
275 err = hfp_read(info); in hfp_info_callback()
282 if (!info->idev) in hfp_info_callback()
283 buf_increment_read(info->capture_buf, info->packet_size); in hfp_info_callback()
285 if (info->odev) { in hfp_info_callback()
286 err = hfp_write(info); in hfp_info_callback()
296 hfp_info_stop(info); in hfp_info_callback()
303 struct hfp_info *info; in hfp_info_create() local
304 info = (struct hfp_info *)calloc(1, sizeof(*info)); in hfp_info_create()
305 if (!info) in hfp_info_create()
308 info->capture_buf = byte_buffer_create(MAX_HFP_BUF_SIZE_BYTES); in hfp_info_create()
309 if (!info->capture_buf) in hfp_info_create()
312 info->playback_buf = byte_buffer_create(MAX_HFP_BUF_SIZE_BYTES); in hfp_info_create()
313 if (!info->playback_buf) in hfp_info_create()
316 return info; in hfp_info_create()
319 if (info) { in hfp_info_create()
320 if (info->capture_buf) in hfp_info_create()
321 byte_buffer_destroy(&info->capture_buf); in hfp_info_create()
322 if (info->playback_buf) in hfp_info_create()
323 byte_buffer_destroy(&info->playback_buf); in hfp_info_create()
324 free(info); in hfp_info_create()
329 int hfp_info_running(struct hfp_info *info) in hfp_info_running() argument
331 return info->started; in hfp_info_running()
334 int hfp_info_start(int fd, unsigned int mtu, struct hfp_info *info) in hfp_info_start() argument
336 info->fd = fd; in hfp_info_start()
337 info->mtu = mtu; in hfp_info_start()
341 hfp_info_set_packet_size(info, mtu); in hfp_info_start()
342 buf_reset(info->playback_buf); in hfp_info_start()
343 buf_reset(info->capture_buf); in hfp_info_start()
345 audio_thread_add_callback(info->fd, hfp_info_callback, info); in hfp_info_start()
347 info->started = 1; in hfp_info_start()
352 int hfp_info_stop(struct hfp_info *info) in hfp_info_stop() argument
354 if (!info->started) in hfp_info_stop()
359 info->fd); in hfp_info_stop()
361 close(info->fd); in hfp_info_stop()
362 info->fd = 0; in hfp_info_stop()
363 info->started = 0; in hfp_info_stop()
368 void hfp_info_destroy(struct hfp_info *info) in hfp_info_destroy() argument
370 if (info->capture_buf) in hfp_info_destroy()
371 byte_buffer_destroy(&info->capture_buf); in hfp_info_destroy()
373 if (info->playback_buf) in hfp_info_destroy()
374 byte_buffer_destroy(&info->playback_buf); in hfp_info_destroy()
376 free(info); in hfp_info_destroy()