Lines Matching refs:a2dpio
63 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in update_supported_formats() local
68 cras_bt_transport_configuration(a2dpio->transport, &a2dp, in update_supported_formats()
111 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in bt_queued_frames() local
114 a2dpio->bt_written_frames += fr; in bt_queued_frames()
115 consumed = cras_frames_since_time(&a2dpio->dev_open_time, in bt_queued_frames()
118 if (a2dpio->bt_written_frames > consumed) in bt_queued_frames()
119 return a2dpio->bt_written_frames - consumed; in bt_queued_frames()
128 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in frames_queued() local
131 a2dp_queued_frames(&a2dpio->a2dp) + in frames_queued()
132 buf_queued(a2dpio->pcm_buf) / in frames_queued()
141 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in configure_dev() local
145 err = cras_bt_transport_acquire(a2dpio->transport); in configure_dev()
162 a2dpio->pcm_buf = byte_buffer_create(PCM_BUF_MAX_SIZE_BYTES); in configure_dev()
163 if (!a2dpio->pcm_buf) in configure_dev()
171 sock_depth = 2 * cras_bt_transport_write_mtu(a2dpio->transport); in configure_dev()
172 setsockopt(cras_bt_transport_fd(a2dpio->transport), in configure_dev()
175 a2dpio->sock_depth_frames = in configure_dev()
176 a2dp_block_size(&a2dpio->a2dp, in configure_dev()
177 cras_bt_transport_write_mtu(a2dpio->transport)) in configure_dev()
179 iodev->min_buffer_level = a2dpio->sock_depth_frames; in configure_dev()
181 a2dpio->pre_fill_complete = 0; in configure_dev()
184 a2dpio->bt_written_frames = 0; in configure_dev()
185 clock_gettime(CLOCK_MONOTONIC_RAW, &a2dpio->dev_open_time); in configure_dev()
187 audio_thread_add_write_callback(cras_bt_transport_fd(a2dpio->transport), in configure_dev()
189 audio_thread_enable_callback(cras_bt_transport_fd(a2dpio->transport), in configure_dev()
197 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in close_dev() local
200 if (!a2dpio->transport) in close_dev()
207 cras_bt_transport_fd(a2dpio->transport)); in close_dev()
209 err = cras_bt_transport_release(a2dpio->transport, in close_dev()
210 !a2dpio->destroyed); in close_dev()
214 device = cras_bt_transport_device(a2dpio->transport); in close_dev()
217 a2dp_drain(&a2dpio->a2dp); in close_dev()
218 byte_buffer_destroy(&a2dpio->pcm_buf); in close_dev()
224 static int pre_fill_socket(struct a2dp_io *a2dpio) in pre_fill_socket() argument
232 &a2dpio->a2dp, in pre_fill_socket()
235 cras_get_format_bytes(a2dpio->base.format), in pre_fill_socket()
236 cras_bt_transport_write_mtu(a2dpio->transport)); in pre_fill_socket()
243 &a2dpio->a2dp, in pre_fill_socket()
244 cras_bt_transport_fd(a2dpio->transport), in pre_fill_socket()
245 cras_bt_transport_write_mtu(a2dpio->transport)); in pre_fill_socket()
255 a2dp_drain(&a2dpio->a2dp); in pre_fill_socket()
270 struct a2dp_io *a2dpio; in flush_data() local
273 a2dpio = (struct a2dp_io *)iodev; in flush_data()
275 device = cras_bt_transport_device(a2dpio->transport); in flush_data()
283 while (buf_queued(a2dpio->pcm_buf)) { in flush_data()
285 &a2dpio->a2dp, in flush_data()
286 buf_read_pointer(a2dpio->pcm_buf), in flush_data()
287 buf_readable(a2dpio->pcm_buf), in flush_data()
289 cras_bt_transport_write_mtu(a2dpio->transport)); in flush_data()
292 buf_queued(a2dpio->pcm_buf), in flush_data()
293 buf_readable(a2dpio->pcm_buf) in flush_data()
300 buf_increment_read(a2dpio->pcm_buf, processed); in flush_data()
303 written = a2dp_write(&a2dpio->a2dp, in flush_data()
304 cras_bt_transport_fd(a2dpio->transport), in flush_data()
305 cras_bt_transport_write_mtu(a2dpio->transport)); in flush_data()
308 a2dp_queued_frames(&a2dpio->a2dp), 0); in flush_data()
314 cras_bt_transport_fd(a2dpio->transport), 1); in flush_data()
332 queued_frames = buf_queued(a2dpio->pcm_buf) / format_bytes; in flush_data()
338 cras_bt_transport_fd(a2dpio->transport), 0); in flush_data()
345 const struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in delay_frames() local
349 return frames_queued(iodev, &tstamp) + a2dpio->sock_depth_frames; in delay_frames()
357 struct a2dp_io *a2dpio; in get_buffer() local
359 a2dpio = (struct a2dp_io *)iodev; in get_buffer()
366 *frames = MIN(*frames, buf_writable(a2dpio->pcm_buf) / in get_buffer()
371 buf_write_pointer(a2dpio->pcm_buf)); in get_buffer()
380 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in put_buffer() local
385 if (written_bytes > buf_writable(a2dpio->pcm_buf)) in put_buffer()
388 buf_increment_write(a2dpio->pcm_buf, written_bytes); in put_buffer()
394 if (!a2dpio->pre_fill_complete) { in put_buffer()
395 pre_fill_socket(a2dpio); in put_buffer()
396 a2dpio->pre_fill_complete = 1; in put_buffer()
398 clock_gettime(CLOCK_MONOTONIC_RAW, &a2dpio->dev_open_time); in put_buffer()
412 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in set_volume() local
414 cras_bt_transport_device(a2dpio->transport); in set_volume()
421 if (a2dpio->transport) in set_volume()
422 cras_bt_transport_set_volume(a2dpio->transport, volume); in set_volume()
430 void free_resources(struct a2dp_io *a2dpio) in free_resources() argument
434 node = a2dpio->base.active_node; in free_resources()
436 cras_iodev_rm_node(&a2dpio->base, node); in free_resources()
439 free(a2dpio->base.supported_channel_counts); in free_resources()
440 free(a2dpio->base.supported_rates); in free_resources()
441 free(a2dpio->base.supported_formats); in free_resources()
442 destroy_a2dp(&a2dpio->a2dp); in free_resources()
448 struct a2dp_io *a2dpio; in a2dp_iodev_create() local
455 a2dpio = (struct a2dp_io *)calloc(1, sizeof(*a2dpio)); in a2dp_iodev_create()
456 if (!a2dpio) in a2dp_iodev_create()
459 a2dpio->transport = transport; in a2dp_iodev_create()
460 cras_bt_transport_configuration(a2dpio->transport, &a2dp, in a2dp_iodev_create()
462 err = init_a2dp(&a2dpio->a2dp, &a2dp); in a2dp_iodev_create()
468 iodev = &a2dpio->base; in a2dp_iodev_create()
479 name = cras_bt_transport_object_path(a2dpio->transport); in a2dp_iodev_create()
511 cras_bt_transport_profile(a2dpio->transport)); in a2dp_iodev_create()
517 if (a2dpio) { in a2dp_iodev_create()
518 free_resources(a2dpio); in a2dp_iodev_create()
519 free(a2dpio); in a2dp_iodev_create()
526 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in a2dp_iodev_destroy() local
529 a2dpio->destroyed = 1; in a2dp_iodev_destroy()
530 device = cras_bt_transport_device(a2dpio->transport); in a2dp_iodev_destroy()
536 free_resources(a2dpio); in a2dp_iodev_destroy()
538 free(a2dpio); in a2dp_iodev_destroy()