Lines Matching refs:a2dpio
72 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in update_supported_formats() local
77 cras_bt_transport_configuration(a2dpio->transport, &a2dp, sizeof(a2dp)); in update_supported_formats()
111 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in bt_local_queued_frames() local
112 return a2dp_queued_frames(&a2dpio->a2dp) + in bt_local_queued_frames()
113 buf_queued(a2dpio->pcm_buf) / in bt_local_queued_frames()
176 static int enter_no_stream(struct a2dp_io *a2dpio) in enter_no_stream() argument
178 struct cras_iodev *odev = &a2dpio->base; in enter_no_stream()
196 static int leave_no_stream(struct a2dp_io *a2dpio) in leave_no_stream() argument
198 struct cras_iodev *odev = &a2dpio->base; in leave_no_stream()
216 struct a2dp_io *a2dpio = (struct a2dp_io *)odev; in no_stream() local
219 return enter_no_stream(a2dpio); in no_stream()
221 return leave_no_stream(a2dpio); in no_stream()
229 static int encode_a2dp_packet(struct a2dp_io *a2dpio) in encode_a2dp_packet() argument
232 size_t format_bytes = cras_get_format_bytes(a2dpio->base.format); in encode_a2dp_packet()
234 while (buf_queued(a2dpio->pcm_buf)) { in encode_a2dp_packet()
236 &a2dpio->a2dp, buf_read_pointer(a2dpio->pcm_buf), in encode_a2dp_packet()
237 buf_readable(a2dpio->pcm_buf), format_bytes, in encode_a2dp_packet()
238 cras_bt_transport_write_mtu(a2dpio->transport)); in encode_a2dp_packet()
244 buf_increment_read(a2dpio->pcm_buf, processed); in encode_a2dp_packet()
260 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in configure_dev() local
266 err = cras_bt_transport_acquire(a2dpio->transport); in configure_dev()
283 a2dpio->pcm_buf = byte_buffer_create(PCM_BUF_MAX_SIZE_BYTES); in configure_dev()
284 if (!a2dpio->pcm_buf) in configure_dev()
290 sock_depth = 2 * cras_bt_transport_write_mtu(a2dpio->transport); in configure_dev()
291 setsockopt(cras_bt_transport_fd(a2dpio->transport), SOL_SOCKET, in configure_dev()
294 getsockopt(cras_bt_transport_fd(a2dpio->transport), SOL_SOCKET, in configure_dev()
296 a2dpio->sock_depth_frames = a2dp_block_size(&a2dpio->a2dp, sock_depth) / in configure_dev()
303 a2dp_payload_length = cras_bt_transport_write_mtu(a2dpio->transport) - in configure_dev()
306 a2dpio->write_block = in configure_dev()
307 a2dp_block_size(&a2dpio->a2dp, a2dp_payload_length) / in configure_dev()
309 cras_frames_to_time(a2dpio->write_block, iodev->format->frame_rate, in configure_dev()
310 &a2dpio->flush_period); in configure_dev()
313 iodev->buffer_size = PCM_BUF_MAX_SIZE_FRAMES + a2dpio->write_block; in configure_dev()
320 iodev->min_buffer_level = a2dpio->write_block; in configure_dev()
323 cras_bt_transport_fd(a2dpio->transport), a2dp_socket_write_cb, in configure_dev()
326 cras_bt_transport_fd(a2dpio->transport), TRIGGER_NONE); in configure_dev()
332 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in start() local
339 clock_gettime(CLOCK_MONOTONIC_RAW, &a2dpio->next_flush_time); in start()
347 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in close_dev() local
350 if (!a2dpio->transport) in close_dev()
356 cras_bt_transport_fd(a2dpio->transport)); in close_dev()
358 err = cras_bt_transport_release(a2dpio->transport, !a2dpio->destroyed); in close_dev()
362 device = cras_bt_transport_device(a2dpio->transport); in close_dev()
365 a2dp_reset(&a2dpio->a2dp); in close_dev()
366 byte_buffer_destroy(&a2dpio->pcm_buf); in close_dev()
376 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in frames_to_play_in_sleep() local
380 if (*hw_level < a2dpio->write_block) in frames_to_play_in_sleep()
383 *hw_level -= a2dpio->write_block; in frames_to_play_in_sleep()
385 frames_until = cras_frames_until_time(&a2dpio->next_flush_time, in frames_to_play_in_sleep()
393 return a2dpio->write_block; in frames_to_play_in_sleep()
406 struct a2dp_io *a2dpio; in encode_and_flush() local
413 a2dpio = (struct a2dp_io *)iodev; in encode_and_flush()
415 device = cras_bt_transport_device(a2dpio->transport); in encode_and_flush()
423 a2dpio->next_flush_time.tv_sec, a2dpio->next_flush_time.tv_nsec); in encode_and_flush()
430 err = encode_a2dp_packet(a2dpio); in encode_and_flush()
438 if (!timespec_after(&now, &a2dpio->next_flush_time)) { in encode_and_flush()
447 cras_bt_transport_fd(a2dpio->transport), in encode_and_flush()
457 subtract_timespecs(&now, &a2dpio->next_flush_time, &ts); in encode_and_flush()
467 written = a2dp_write(&a2dpio->a2dp, in encode_and_flush()
468 cras_bt_transport_fd(a2dpio->transport), in encode_and_flush()
469 cras_bt_transport_write_mtu(a2dpio->transport)); in encode_and_flush()
471 a2dp_queued_frames(&a2dpio->a2dp), 0); in encode_and_flush()
478 cras_bt_transport_fd(a2dpio->transport), TRIGGER_POLL); in encode_and_flush()
488 cras_bt_transport_fd(a2dpio->transport), TRIGGER_NONE); in encode_and_flush()
494 add_timespecs(&a2dpio->next_flush_time, &a2dpio->flush_period); in encode_and_flush()
499 cras_bt_transport_fd(a2dpio->transport), TRIGGER_NONE); in encode_and_flush()
509 queued_frames = buf_queued(a2dpio->pcm_buf) / format_bytes; in encode_and_flush()
511 (iodev->min_buffer_level + a2dpio->write_block < queued_frames)) { in encode_and_flush()
512 err = encode_a2dp_packet(a2dpio); in encode_and_flush()
523 const struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in delay_frames() local
527 return frames_queued(iodev, &tstamp) + a2dpio->sock_depth_frames; in delay_frames()
534 struct a2dp_io *a2dpio; in get_buffer() local
536 a2dpio = (struct a2dp_io *)iodev; in get_buffer()
543 *frames = MIN(*frames, buf_writable(a2dpio->pcm_buf) / format_bytes); in get_buffer()
546 buf_write_pointer(a2dpio->pcm_buf)); in get_buffer()
555 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in put_buffer() local
560 if (written_bytes > buf_writable(a2dpio->pcm_buf)) in put_buffer()
563 buf_increment_write(a2dpio->pcm_buf, written_bytes); in put_buffer()
576 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in set_volume() local
578 cras_bt_transport_device(a2dpio->transport); in set_volume()
585 if (a2dpio->transport) in set_volume()
586 cras_bt_transport_set_volume(a2dpio->transport, volume); in set_volume()
594 void free_resources(struct a2dp_io *a2dpio) in free_resources() argument
598 node = a2dpio->base.active_node; in free_resources()
600 cras_iodev_rm_node(&a2dpio->base, node); in free_resources()
603 free(a2dpio->base.supported_channel_counts); in free_resources()
604 free(a2dpio->base.supported_rates); in free_resources()
605 free(a2dpio->base.supported_formats); in free_resources()
606 destroy_a2dp(&a2dpio->a2dp); in free_resources()
612 struct a2dp_io *a2dpio; in a2dp_iodev_create() local
619 a2dpio = (struct a2dp_io *)calloc(1, sizeof(*a2dpio)); in a2dp_iodev_create()
620 if (!a2dpio) in a2dp_iodev_create()
623 a2dpio->transport = transport; in a2dp_iodev_create()
624 cras_bt_transport_configuration(a2dpio->transport, &a2dp, sizeof(a2dp)); in a2dp_iodev_create()
625 err = init_a2dp(&a2dpio->a2dp, &a2dp); in a2dp_iodev_create()
631 iodev = &a2dpio->base; in a2dp_iodev_create()
642 name = cras_bt_transport_object_path(a2dpio->transport); in a2dp_iodev_create()
677 device, iodev, cras_bt_transport_profile(a2dpio->transport)); in a2dp_iodev_create()
687 if (a2dpio) { in a2dp_iodev_create()
688 free_resources(a2dpio); in a2dp_iodev_create()
689 free(a2dpio); in a2dp_iodev_create()
696 struct a2dp_io *a2dpio = (struct a2dp_io *)iodev; in a2dp_iodev_destroy() local
699 a2dpio->destroyed = 1; in a2dp_iodev_destroy()
700 device = cras_bt_transport_device(a2dpio->transport); in a2dp_iodev_destroy()
706 free_resources(a2dpio); in a2dp_iodev_destroy()
708 free(a2dpio); in a2dp_iodev_destroy()