예제 #1
0
static int configure_record_dev(struct cras_iodev *iodev)
{
	struct loopback_iodev *loopdev = (struct loopback_iodev *)iodev;
	struct cras_iodev *edev;

	cras_iodev_init_audio_area(iodev, iodev->format->num_channels);
	clock_gettime(CLOCK_MONOTONIC_RAW, &loopdev->dev_start_time);
	loopdev->read_frames = 0;

	edev = cras_iodev_list_get_first_enabled_iodev(CRAS_STREAM_OUTPUT);
	register_loopback_hook(loopdev->loopback_type, edev, sample_hook,
			       (void *)iodev);
	cras_iodev_list_set_device_enabled_callback(device_enabled_hook,
						    device_disabled_hook,
						    (void *)iodev);

	return 0;
}
예제 #2
0
static int open_dev(struct cras_iodev *iodev)
{
	struct hfp_io *hfpio = (struct hfp_io *)iodev;
	int sk, err, mtu;

	/* Assert format is set before opening device. */
	if (iodev->format == NULL)
		return -EINVAL;
	iodev->format->format = SND_PCM_FORMAT_S16_LE;
	cras_iodev_init_audio_area(iodev, iodev->format->num_channels);

	if (hfp_info_running(hfpio->info))
		goto add_dev;

	sk = cras_bt_device_sco_connect(hfpio->device);
	if (sk < 0)
		goto error;

	mtu = cras_bt_device_sco_mtu(hfpio->device, sk);

	/* Start hfp_info */
	err = hfp_info_start(sk, mtu, hfpio->info);
	if (err)
		goto error;

add_dev:
	hfp_info_add_iodev(hfpio->info, iodev);
	hfp_set_call_status(hfpio->slc, 1);

	iodev->buffer_size = hfp_buf_size(hfpio->info, iodev);

	return 0;
error:
	syslog(LOG_ERR, "Failed to open HFP iodev");
	return -1;
}