• Home
  • Raw
  • Download

Lines Matching refs:common

109     struct a2dp_stream_common common;  member
116 struct a2dp_stream_common common; member
303 static int a2dp_ctrl_receive(struct a2dp_stream_common *common, void* buffer, int length) in a2dp_ctrl_receive() argument
305 int ret = TEMP_FAILURE_RETRY(recv(common->ctrl_fd, buffer, length, MSG_NOSIGNAL)); in a2dp_ctrl_receive()
312 ret = TEMP_FAILURE_RETRY(recv(common->ctrl_fd, buffer, length, MSG_NOSIGNAL)); in a2dp_ctrl_receive()
316 skt_disconnect(common->ctrl_fd); in a2dp_ctrl_receive()
317 common->ctrl_fd = AUDIO_SKT_DISCONNECTED; in a2dp_ctrl_receive()
323 skt_disconnect(common->ctrl_fd); in a2dp_ctrl_receive()
324 common->ctrl_fd = AUDIO_SKT_DISCONNECTED; in a2dp_ctrl_receive()
332 static int a2dp_command(struct a2dp_stream_common *common, char cmd) in a2dp_command() argument
339 if (TEMP_FAILURE_RETRY(send(common->ctrl_fd, &cmd, 1, MSG_NOSIGNAL)) == -1) in a2dp_command()
342 skt_disconnect(common->ctrl_fd); in a2dp_command()
343 common->ctrl_fd = AUDIO_SKT_DISCONNECTED; in a2dp_command()
348 if (a2dp_ctrl_receive(common, &ack, 1) < 0) in a2dp_command()
361 static int check_a2dp_ready(struct a2dp_stream_common *common) in check_a2dp_ready() argument
363 if (a2dp_command(common, A2DP_CTRL_CMD_CHECK_READY) < 0) in check_a2dp_ready()
371 static int a2dp_read_audio_config(struct a2dp_stream_common *common) in a2dp_read_audio_config() argument
377 if (a2dp_command(common, A2DP_CTRL_GET_AUDIO_CONFIG) < 0) in a2dp_read_audio_config()
383 if (a2dp_ctrl_receive(common, &sample_rate, 4) < 0) in a2dp_read_audio_config()
385 if (a2dp_ctrl_receive(common, &channel_count, 1) < 0) in a2dp_read_audio_config()
388common->cfg.channel_flags = (channel_count == 1 ? AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO); in a2dp_read_audio_config()
389 common->cfg.format = AUDIO_STREAM_DEFAULT_FORMAT; in a2dp_read_audio_config()
390 common->cfg.rate = sample_rate; in a2dp_read_audio_config()
392 INFO("got config %d %d", common->cfg.format, common->cfg.rate); in a2dp_read_audio_config()
397 static void a2dp_open_ctrl_path(struct a2dp_stream_common *common) in a2dp_open_ctrl_path() argument
405 if ((common->ctrl_fd = skt_connect(A2DP_CTRL_PATH, common->buffer_sz)) > 0) in a2dp_open_ctrl_path()
408 if (check_a2dp_ready(common) == 0) in a2dp_open_ctrl_path()
413 skt_disconnect(common->ctrl_fd); in a2dp_open_ctrl_path()
414 common->ctrl_fd = AUDIO_SKT_DISCONNECTED; in a2dp_open_ctrl_path()
428 static void a2dp_stream_common_init(struct a2dp_stream_common *common) in a2dp_stream_common_init() argument
436 pthread_mutex_init(&common->lock, &lock_attr); in a2dp_stream_common_init()
438 common->ctrl_fd = AUDIO_SKT_DISCONNECTED; in a2dp_stream_common_init()
439 common->audio_fd = AUDIO_SKT_DISCONNECTED; in a2dp_stream_common_init()
440 common->state = AUDIO_A2DP_STATE_STOPPED; in a2dp_stream_common_init()
443 common->buffer_sz = AUDIO_STREAM_OUTPUT_BUFFER_SZ; in a2dp_stream_common_init()
446 static int start_audio_datapath(struct a2dp_stream_common *common) in start_audio_datapath() argument
448 INFO("state %d", common->state); in start_audio_datapath()
450 if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) { in start_audio_datapath()
455 int oldstate = common->state; in start_audio_datapath()
456 common->state = AUDIO_A2DP_STATE_STARTING; in start_audio_datapath()
458 int a2dp_status = a2dp_command(common, A2DP_CTRL_CMD_START); in start_audio_datapath()
463 common->state = oldstate; in start_audio_datapath()
469 common->state = oldstate; in start_audio_datapath()
474 if (common->audio_fd == AUDIO_SKT_DISCONNECTED) in start_audio_datapath()
476 common->audio_fd = skt_connect(A2DP_DATA_PATH, common->buffer_sz); in start_audio_datapath()
477 if (common->audio_fd < 0) in start_audio_datapath()
479 common->state = oldstate; in start_audio_datapath()
483 common->state = AUDIO_A2DP_STATE_STARTED; in start_audio_datapath()
489 static int stop_audio_datapath(struct a2dp_stream_common *common) in stop_audio_datapath() argument
491 int oldstate = common->state; in stop_audio_datapath()
493 INFO("state %d", common->state); in stop_audio_datapath()
495 if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) in stop_audio_datapath()
500 common->state = AUDIO_A2DP_STATE_STOPPING; in stop_audio_datapath()
502 if (a2dp_command(common, A2DP_CTRL_CMD_STOP) < 0) in stop_audio_datapath()
505 common->state = oldstate; in stop_audio_datapath()
509 common->state = AUDIO_A2DP_STATE_STOPPED; in stop_audio_datapath()
512 skt_disconnect(common->audio_fd); in stop_audio_datapath()
513 common->audio_fd = AUDIO_SKT_DISCONNECTED; in stop_audio_datapath()
518 static int suspend_audio_datapath(struct a2dp_stream_common *common, bool standby) in suspend_audio_datapath() argument
520 INFO("state %d", common->state); in suspend_audio_datapath()
522 if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) in suspend_audio_datapath()
525 if (common->state == AUDIO_A2DP_STATE_STOPPING) in suspend_audio_datapath()
528 if (a2dp_command(common, A2DP_CTRL_CMD_SUSPEND) < 0) in suspend_audio_datapath()
532 common->state = AUDIO_A2DP_STATE_STANDBY; in suspend_audio_datapath()
534 common->state = AUDIO_A2DP_STATE_SUSPENDED; in suspend_audio_datapath()
537 skt_disconnect(common->audio_fd); in suspend_audio_datapath()
539 common->audio_fd = AUDIO_SKT_DISCONNECTED; in suspend_audio_datapath()
557 DEBUG("write %zu bytes (fd %d)", bytes, out->common.audio_fd); in out_write()
559 pthread_mutex_lock(&out->common.lock); in out_write()
561 if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED) in out_write()
564 pthread_mutex_unlock(&out->common.lock); in out_write()
569 if ((out->common.state == AUDIO_A2DP_STATE_STOPPED) || in out_write()
570 (out->common.state == AUDIO_A2DP_STATE_STANDBY)) in out_write()
572 if (start_audio_datapath(&out->common) < 0) in out_write()
577 int us_delay = calc_audiotime(out->common.cfg, bytes); in out_write()
582 pthread_mutex_unlock(&out->common.lock); in out_write()
586 else if (out->common.state != AUDIO_A2DP_STATE_STARTED) in out_write()
589 pthread_mutex_unlock(&out->common.lock); in out_write()
593 pthread_mutex_unlock(&out->common.lock); in out_write()
594 sent = skt_write(out->common.audio_fd, buffer, bytes); in out_write()
597 skt_disconnect(out->common.audio_fd); in out_write()
598 out->common.audio_fd = AUDIO_SKT_DISCONNECTED; in out_write()
599 if (out->common.state != AUDIO_A2DP_STATE_SUSPENDED) in out_write()
600 out->common.state = AUDIO_A2DP_STATE_STOPPED; in out_write()
618 DEBUG("rate %" PRIu32,out->common.cfg.rate); in out_get_sample_rate()
620 return out->common.cfg.rate; in out_get_sample_rate()
635 out->common.cfg.rate = rate; in out_set_sample_rate()
644 DEBUG("buffer_size : %zu", out->common.buffer_sz); in out_get_buffer_size()
646 return out->common.buffer_sz; in out_get_buffer_size()
653 DEBUG("channels 0x%" PRIx32, out->common.cfg.channel_flags); in out_get_channels()
655 return out->common.cfg.channel_flags; in out_get_channels()
661 DEBUG("format 0x%x", out->common.cfg.format); in out_get_format()
662 return out->common.cfg.format; in out_get_format()
680 pthread_mutex_lock(&out->common.lock); in out_standby()
682 if (out->common.state != AUDIO_A2DP_STATE_SUSPENDED) in out_standby()
683 retVal = suspend_audio_datapath(&out->common, true); in out_standby()
685 pthread_mutex_unlock (&out->common.lock); in out_standby()
706 INFO("state %d", out->common.state); in out_set_parameters()
720 pthread_mutex_lock(&out->common.lock); in out_set_parameters()
721 out->common.state = AUDIO_A2DP_STATE_STOPPING; in out_set_parameters()
722 pthread_mutex_unlock(&out->common.lock); in out_set_parameters()
730 pthread_mutex_lock(&out->common.lock); in out_set_parameters()
733 if (out->common.state == AUDIO_A2DP_STATE_STARTED) in out_set_parameters()
734 status = suspend_audio_datapath(&out->common, false); in out_set_parameters()
741 if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED) in out_set_parameters()
742 out->common.state = AUDIO_A2DP_STATE_STANDBY; in out_set_parameters()
745 pthread_mutex_unlock(&out->common.lock); in out_set_parameters()
773 latency_us = ((out->common.buffer_sz * 1000 ) / in out_get_latency()
775 out->common.cfg.rate) * 1000; in out_get_latency()
805 pthread_mutex_lock(&out->common.lock); in out_get_presentation_position()
806 uint64_t latency_frames = (uint64_t)out_get_latency(stream) * out->common.cfg.rate / 1000; in out_get_presentation_position()
812 pthread_mutex_unlock(&out->common.lock); in out_get_presentation_position()
825 pthread_mutex_lock(&out->common.lock); in out_get_render_position()
826 uint64_t latency_frames = (uint64_t)out_get_latency(stream) * out->common.cfg.rate / 1000; in out_get_render_position()
832 pthread_mutex_unlock(&out->common.lock); in out_get_render_position()
863 return in->common.cfg.rate; in in_get_sample_rate()
872 if (in->common.cfg.rate > 0 && in->common.cfg.rate == rate) in in_set_sample_rate()
891 return in->common.cfg.channel_flags; in in_get_channels()
965 DEBUG("read %zu bytes, state: %d", bytes, in->common.state); in in_read()
967 if (in->common.state == AUDIO_A2DP_STATE_SUSPENDED) in in_read()
974 if ((in->common.state == AUDIO_A2DP_STATE_STOPPED) || in in_read()
975 (in->common.state == AUDIO_A2DP_STATE_STANDBY)) in in_read()
977 pthread_mutex_lock(&in->common.lock); in in_read()
979 if (start_audio_datapath(&in->common) < 0) in in_read()
984 int us_delay = calc_audiotime(in->common.cfg, bytes); in in_read()
989 pthread_mutex_unlock(&in->common.lock); in in_read()
993 pthread_mutex_unlock(&in->common.lock); in in_read()
995 else if (in->common.state != AUDIO_A2DP_STATE_STARTED) in in_read()
1001 read = skt_read(in->common.audio_fd, buffer, bytes); in in_read()
1005 skt_disconnect(in->common.audio_fd); in in_read()
1006 in->common.audio_fd = AUDIO_SKT_DISCONNECTED; in in_read()
1007 in->common.state = AUDIO_A2DP_STATE_STOPPED; in in_read()
1070 out->stream.common.get_sample_rate = out_get_sample_rate; in adev_open_output_stream()
1071 out->stream.common.set_sample_rate = out_set_sample_rate; in adev_open_output_stream()
1072 out->stream.common.get_buffer_size = out_get_buffer_size; in adev_open_output_stream()
1073 out->stream.common.get_channels = out_get_channels; in adev_open_output_stream()
1074 out->stream.common.get_format = out_get_format; in adev_open_output_stream()
1075 out->stream.common.set_format = out_set_format; in adev_open_output_stream()
1076 out->stream.common.standby = out_standby; in adev_open_output_stream()
1077 out->stream.common.dump = out_dump; in adev_open_output_stream()
1078 out->stream.common.set_parameters = out_set_parameters; in adev_open_output_stream()
1079 out->stream.common.get_parameters = out_get_parameters; in adev_open_output_stream()
1080 out->stream.common.add_audio_effect = out_add_audio_effect; in adev_open_output_stream()
1081 out->stream.common.remove_audio_effect = out_remove_audio_effect; in adev_open_output_stream()
1090 a2dp_stream_common_init(&out->common); in adev_open_output_stream()
1092 out->common.cfg.channel_flags = AUDIO_STREAM_DEFAULT_CHANNEL_FLAG; in adev_open_output_stream()
1093 out->common.cfg.format = AUDIO_STREAM_DEFAULT_FORMAT; in adev_open_output_stream()
1094 out->common.cfg.rate = AUDIO_STREAM_DEFAULT_RATE; in adev_open_output_stream()
1106 a2dp_open_ctrl_path(&out->common); in adev_open_output_stream()
1107 if (out->common.ctrl_fd == AUDIO_SKT_DISCONNECTED) in adev_open_output_stream()
1134 INFO("closing output (state %d)", out->common.state); in adev_close_output_stream()
1136 pthread_mutex_lock(&out->common.lock); in adev_close_output_stream()
1137 …if ((out->common.state == AUDIO_A2DP_STATE_STARTED) || (out->common.state == AUDIO_A2DP_STATE_STOP… in adev_close_output_stream()
1138 stop_audio_datapath(&out->common); in adev_close_output_stream()
1140 skt_disconnect(out->common.ctrl_fd); in adev_close_output_stream()
1143 pthread_mutex_unlock(&out->common.lock); in adev_close_output_stream()
1157 INFO("state %d", out->common.state); in adev_set_parameters()
1159 retval = out->stream.common.set_parameters((struct audio_stream *)out, kvpairs); in adev_set_parameters()
1277 in->stream.common.get_sample_rate = in_get_sample_rate; in adev_open_input_stream()
1278 in->stream.common.set_sample_rate = in_set_sample_rate; in adev_open_input_stream()
1279 in->stream.common.get_buffer_size = in_get_buffer_size; in adev_open_input_stream()
1280 in->stream.common.get_channels = in_get_channels; in adev_open_input_stream()
1281 in->stream.common.get_format = in_get_format; in adev_open_input_stream()
1282 in->stream.common.set_format = in_set_format; in adev_open_input_stream()
1283 in->stream.common.standby = in_standby; in adev_open_input_stream()
1284 in->stream.common.dump = in_dump; in adev_open_input_stream()
1285 in->stream.common.set_parameters = in_set_parameters; in adev_open_input_stream()
1286 in->stream.common.get_parameters = in_get_parameters; in adev_open_input_stream()
1287 in->stream.common.add_audio_effect = in_add_audio_effect; in adev_open_input_stream()
1288 in->stream.common.remove_audio_effect = in_remove_audio_effect; in adev_open_input_stream()
1294 a2dp_stream_common_init(&in->common); in adev_open_input_stream()
1299 a2dp_open_ctrl_path(&in->common); in adev_open_input_stream()
1300 if (in->common.ctrl_fd == AUDIO_SKT_DISCONNECTED) in adev_open_input_stream()
1307 if (a2dp_read_audio_config(&in->common) < 0) { in adev_open_input_stream()
1329 a2dp_state_t state = in->common.state; in adev_close_input_stream()
1334 stop_audio_datapath(&in->common); in adev_close_input_stream()
1336 skt_disconnect(in->common.ctrl_fd); in adev_close_input_stream()
1381 adev->device.common.tag = HARDWARE_DEVICE_TAG; in adev_open()
1382 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0; in adev_open()
1383 adev->device.common.module = (struct hw_module_t *) module; in adev_open()
1384 adev->device.common.close = adev_close; in adev_open()
1404 *device = &adev->device.common; in adev_open()
1414 .common = {