Lines Matching defs:out

426 static void do_out_standby(struct stream_out *out);
432 * out stream(s) in enum output_type order
434 * TODO investigate whether we ever actually take both in stream and out stream
474 static int read_hdmi_channel_masks(struct audio_device *adev, struct stream_out *out) {
494 out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_5POINT1;
496 out->supported_channel_masks[1] = AUDIO_CHANNEL_OUT_7POINT1;
628 /* must be called with hw device outputs list, all out streams, and hw device mutexes locked */
632 struct stream_out *out;
635 out = adev->outputs[type];
636 if (type == OUTPUT_HDMI || !out)
639 do_out_standby(out);
707 static int start_output_stream(struct stream_out *out)
709 struct audio_device *adev = out->dev;
712 if (out == adev->outputs[OUTPUT_HDMI]) {
715 out->disabled = true;
719 out->disabled = false;
721 if (out->device & (AUDIO_DEVICE_OUT_SPEAKER |
727 out->pcm[PCM_CARD] = pcm_open(PCM_CARD, out->pcm_device,
728 PCM_OUT | PCM_MONOTONIC, &out->config);
730 if (out->pcm[PCM_CARD] && !pcm_is_ready(out->pcm[PCM_CARD])) {
732 pcm_get_error(out->pcm[PCM_CARD]));
733 pcm_close(out->pcm[PCM_CARD]);
738 if (out->device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
739 out->pcm[PCM_CARD_SPDIF] = pcm_open(PCM_CARD_SPDIF, out->pcm_device,
740 PCM_OUT | PCM_MONOTONIC, &out->config);
742 if (out->pcm[PCM_CARD_SPDIF] &&
743 !pcm_is_ready(out->pcm[PCM_CARD_SPDIF])) {
745 pcm_get_error(out->pcm[PCM_CARD_SPDIF]));
746 pcm_close(out->pcm[PCM_CARD_SPDIF]);
751 adev->out_device |= out->device;
754 if (out->device & AUDIO_DEVICE_OUT_ALL_SCO)
757 if (out->device & AUDIO_DEVICE_OUT_AUX_DIGITAL)
758 set_hdmi_channels(adev, out->config.channels);
933 struct stream_out *out = (struct stream_out *)stream;
935 return out->config.rate;
945 struct stream_out *out = (struct stream_out *)stream;
947 return out->config.period_size *
953 struct stream_out *out = (struct stream_out *)stream;
955 return out->channel_mask;
969 * other than out. Assumes out is non-NULL and out->dev is locked.
971 static audio_devices_t output_devices(struct stream_out *out)
973 struct audio_device *dev = out->dev;
979 if (other && (other != out) && !other->standby) {
992 /* must be called with hw device outputs list, all out streams, and hw device mutex locked */
993 static void do_out_standby(struct stream_out *out)
995 struct audio_device *adev = out->dev;
998 if (!out->standby) {
1000 if (out->pcm[i]) {
1001 pcm_close(out->pcm[i]);
1002 out->pcm[i] = NULL;
1005 out->standby = true;
1007 if (out == adev->outputs[OUTPUT_HDMI]) {
1013 if (out->device & AUDIO_DEVICE_OUT_ALL_SCO)
1017 adev->out_device = output_devices(out);
1031 struct stream_out *out = adev->outputs[type];
1032 if (out)
1033 pthread_mutex_lock(&out->lock);
1045 struct stream_out *out = adev->outputs[--type];
1046 if (out && out != except)
1047 pthread_mutex_unlock(&out->lock);
1054 struct stream_out *out = (struct stream_out *)stream;
1055 struct audio_device *adev = out->dev;
1059 do_out_standby(out);
1073 struct stream_out *out = (struct stream_out *)stream;
1074 struct audio_device *adev = out->dev;
1087 if ((out->device != val) && (val != 0)) {
1093 do_out_standby(out);
1098 (out->device & AUDIO_DEVICE_OUT_ALL_SCO)) {
1099 do_out_standby(out);
1102 if (!out->standby && (out == adev->outputs[OUTPUT_HDMI] ||
1105 adev->out_device = output_devices(out) | val;
1108 out->device = val;
1119 struct stream_out *out = (struct stream_out *)stream;
1133 while (out->supported_channel_masks[i] != 0) {
1135 if (out_channels_name_to_enum_table[j].value == out->supported_channel_masks[i]) {
1159 struct stream_out *out = (struct stream_out *)stream;
1161 return (out->config.period_size * out->config.period_count * 1000) /
1162 out->config.rate;
1168 struct stream_out *out = (struct stream_out *)stream;
1169 struct audio_device *adev = out->dev;
1175 bool is_HDMI = out == adev->outputs[OUTPUT_HDMI];
1179 out->muted = (left == 0.0f);
1189 struct stream_out *out = (struct stream_out *)stream;
1190 struct audio_device *adev = out->dev;
1199 pthread_mutex_lock(&out->lock);
1200 if (out->standby) {
1201 pthread_mutex_unlock(&out->lock);
1203 if (!out->standby) {
1204 unlock_all_outputs(adev, out);
1207 ret = start_output_stream(out);
1212 out->standby = false;
1213 unlock_all_outputs(adev, out);
1217 if (out->disabled) {
1222 if (out->muted)
1227 if (out->pcm[i]) {
1228 ret = pcm_write(out->pcm[i], (void *)buffer, bytes);
1233 out->written += bytes / (out->config.channels * sizeof(short));
1236 pthread_mutex_unlock(&out->lock);
1272 struct stream_out *out = (struct stream_out *)stream;
1275 pthread_mutex_lock(&out->lock);
1283 if (out->pcm[i]) {
1285 if (pcm_get_htimestamp(out->pcm[i], &avail, timestamp) == 0) {
1286 size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
1288 int64_t signed_frames = out->written - kernel_buffer_size + avail;
1298 pthread_mutex_unlock(&out->lock);
1585 struct stream_out *out;
1589 out = (struct stream_out *)calloc(1, sizeof(struct stream_out));
1590 if (!out)
1593 out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
1594 out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
1597 out->device = devices;
1602 ret = read_hdmi_channel_masks(adev, out);
1610 out->channel_mask = config->channel_mask;
1611 out->config = pcm_config_hdmi_multi;
1612 out->config.rate = config->sample_rate;
1613 out->config.channels = audio_channel_count_from_out_mask(config->channel_mask);
1614 out->pcm_device = PCM_DEVICE;
1617 out->config = pcm_config_deep;
1618 out->pcm_device = PCM_DEVICE_DEEP;
1621 out->config = pcm_config;
1622 out->pcm_device = PCM_DEVICE;
1626 out->stream.common.get_sample_rate = out_get_sample_rate;
1627 out->stream.common.set_sample_rate = out_set_sample_rate;
1628 out->stream.common.get_buffer_size = out_get_buffer_size;
1629 out->stream.common.get_channels = out_get_channels;
1630 out->stream.common.get_format = out_get_format;
1631 out->stream.common.set_format = out_set_format;
1632 out->stream.common.standby = out_standby;
1633 out->stream.common.dump = out_dump;
1634 out->stream.common.set_parameters = out_set_parameters;
1635 out->stream.common.get_parameters = out_get_parameters;
1636 out->stream.common.add_audio_effect = out_add_audio_effect;
1637 out->stream.common.remove_audio_effect = out_remove_audio_effect;
1638 out->stream.get_latency = out_get_latency;
1639 out->stream.set_volume = out_set_volume;
1640 out->stream.write = out_write;
1641 out->stream.get_render_position = out_get_render_position;
1642 out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
1643 out->stream.get_presentation_position = out_get_presentation_position;
1645 out->dev = adev;
1647 config->format = out_get_format(&out->stream.common);
1648 config->channel_mask = out_get_channels(&out->stream.common);
1649 config->sample_rate = out_get_sample_rate(&out->stream.common);
1651 out->standby = true;
1652 /* out->muted = false; by calloc() */
1653 /* out->written = 0; by calloc() */
1661 adev->outputs[type] = out;
1664 *stream_out = &out->stream;
1669 free(out);