Lines Matching defs:out

133  * the ha_stream_common (out or in) mutex.
876 struct ha_stream_out* out = (struct ha_stream_out*)stream;
880 DEBUG("write %zu bytes (fd %d)", bytes, out->common.audio_fd);
882 std::unique_lock<std::recursive_mutex> lock(*out->common.mutex);
883 if (out->common.state == AUDIO_HA_STATE_SUSPENDED ||
884 out->common.state == AUDIO_HA_STATE_STOPPING) {
890 if ((out->common.state == AUDIO_HA_STATE_STOPPED) ||
891 (out->common.state == AUDIO_HA_STATE_STANDBY)) {
892 if (start_audio_datapath(&out->common) < 0) {
895 } else if (out->common.state != AUDIO_HA_STATE_STARTED) {
901 if (out->common.cfg.is_stereo_to_mono) {
910 out->common.audio_fd);
914 sent = skt_write(out->common.audio_fd, buffer, write_bytes);
918 skt_disconnect(out->common.audio_fd);
919 out->common.audio_fd = AUDIO_SKT_DISCONNECTED;
920 if ((out->common.state != AUDIO_HA_STATE_SUSPENDED) &&
921 (out->common.state != AUDIO_HA_STATE_STOPPING)) {
922 out->common.state = AUDIO_HA_STATE_STOPPED;
931 out->frames_rendered += frames;
932 out->frames_presented += frames;
935 // If send didn't work out, sleep to emulate write delay.
937 const int us_delay = calc_audiotime_usec(out->common.cfg, bytes);
945 struct ha_stream_out* out = (struct ha_stream_out*)stream;
947 DEBUG("rate %" PRIu32, out->common.cfg.rate);
949 return out->common.cfg.rate;
953 struct ha_stream_out* out = (struct ha_stream_out*)stream;
957 out->common.cfg.rate = rate;
963 struct ha_stream_out* out = (struct ha_stream_out*)stream;
966 out->common.buffer_sz / AUDIO_STREAM_OUTPUT_BUFFER_PERIODS;
968 DEBUG("socket buffer size: %zu period size: %zu", out->common.buffer_sz,
1081 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1083 DEBUG("channels 0x%" PRIx32, out->common.cfg.channel_mask);
1085 return out->common.cfg.channel_mask;
1089 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1090 DEBUG("format 0x%x", out->common.cfg.format);
1091 return (audio_format_t)out->common.cfg.format;
1101 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1106 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1108 if (out->common.state != AUDIO_HA_STATE_SUSPENDED)
1109 retVal = suspend_audio_datapath(&out->common, true);
1110 out->frames_rendered = 0; // rendered is reset, presented is not
1123 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1125 INFO("state %d kvpairs %s", out->common.state, kvpairs);
1133 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1140 out->common.state = AUDIO_HA_STATE_STOPPING;
1144 if (out->common.state == AUDIO_HA_STATE_STARTED)
1145 status = suspend_audio_datapath(&out->common, false);
1150 if (out->common.state == AUDIO_HA_STATE_SUSPENDED)
1151 out->common.state = AUDIO_HA_STATE_STANDBY;
1165 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1173 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1175 if (ha_read_output_audio_config(&out->common, &codec_config,
1284 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1289 ((out->common.buffer_sz * 1000) /
1290 audio_stream_out_frame_size(&out->stream) / out->common.cfg.rate) *
1308 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1314 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1316 (uint64_t)out_get_latency(stream) * out->common.cfg.rate / 1000;
1317 if (out->frames_presented >= latency_frames) {
1318 *frames = out->frames_presented - latency_frames;
1328 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1333 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1335 (uint64_t)out_get_latency(stream) * out->common.cfg.rate / 1000;
1336 if (out->frames_rendered >= latency_frames) {
1337 *dsp_frames = (uint32_t)(out->frames_rendered - latency_frames);
1476 DEBUG("read time out - return zeros");
1482 DEBUG("read %d bytes out of %zu bytes", read, bytes);
1523 struct ha_stream_out* out;
1529 out = (struct ha_stream_out*)calloc(1, sizeof(struct ha_stream_out));
1531 if (!out) return -ENOMEM;
1533 out->stream.common.get_sample_rate = out_get_sample_rate;
1534 out->stream.common.set_sample_rate = out_set_sample_rate;
1535 out->stream.common.get_buffer_size = out_get_buffer_size;
1536 out->stream.common.get_channels = out_get_channels;
1537 out->stream.common.get_format = out_get_format;
1538 out->stream.common.set_format = out_set_format;
1539 out->stream.common.standby = out_standby;
1540 out->stream.common.dump = out_dump;
1541 out->stream.common.set_parameters = out_set_parameters;
1542 out->stream.common.get_parameters = out_get_parameters;
1543 out->stream.common.add_audio_effect = out_add_audio_effect;
1544 out->stream.common.remove_audio_effect = out_remove_audio_effect;
1545 out->stream.get_latency = out_get_latency;
1546 out->stream.set_volume = out_set_volume;
1547 out->stream.write = out_write;
1548 out->stream.get_render_position = out_get_render_position;
1549 out->stream.get_presentation_position = out_get_presentation_position;
1552 ha_stream_common_init(&out->common);
1557 if (ha_read_output_audio_config(&out->common, &codec_config,
1570 if (config->format != 0) out->common.cfg.format = config->format;
1571 if (config->sample_rate != 0) out->common.cfg.rate = config->sample_rate;
1573 out->common.cfg.channel_mask = config->channel_mask;
1574 if ((out->common.cfg.format != 0) || (out->common.cfg.rate != 0) ||
1575 (out->common.cfg.channel_mask != 0)) {
1576 if (ha_write_output_audio_config(&out->common) < 0) {
1582 if (ha_read_output_audio_config(&out->common, &codec_config,
1590 config->format = out_get_format((const struct audio_stream*)&out->stream);
1592 out_get_sample_rate((const struct audio_stream*)&out->stream);
1594 out_get_channels((const struct audio_stream*)&out->stream);
1600 out->common.buffer_sz);
1602 *stream_out = &out->stream;
1603 ha_dev->output = out;
1612 ha_stream_common_destroy(&out->common);
1613 free(out);
1623 struct ha_stream_out* out = (struct ha_stream_out*)stream;
1628 std::lock_guard<std::recursive_mutex> lock(*out->common.mutex);
1629 const ha_state_t state = out->common.state;
1633 stop_audio_datapath(&out->common);
1636 skt_disconnect(out->common.ctrl_fd);
1637 out->common.ctrl_fd = AUDIO_SKT_DISCONNECTED;
1640 ha_stream_common_destroy(&out->common);
1654 struct ha_stream_out* out = ha_dev->output;
1656 if (out == NULL) return retval;
1658 INFO("state %d", out->common.state);
1661 out->stream.common.set_parameters((struct audio_stream*)out, kvpairs);