Home | History | Annotate | Download | only in audio

Lines Matching defs:out

225 static void do_out_standby(struct stream_out *out)
227 struct audio_device *adev = out->dev;
229 if (!out->standby) {
230 pcm_close(out->pcm);
231 out->pcm = NULL;
233 if (out->resampler) {
234 release_resampler(out->resampler);
235 out->resampler = NULL;
237 if (out->buffer) {
238 free(out->buffer);
239 out->buffer = NULL;
241 out->standby = true;
267 static int start_output_stream(struct stream_out *out)
269 struct audio_device *adev = out->dev;
281 out->pcm_config = &pcm_config_sco;
284 out->pcm_config = &pcm_config_out;
285 out->buffer_type = OUT_BUFFER_TYPE_UNKNOWN;
298 if (((out->pcm_config->rate % 8000 == 0) &&
300 ((out->pcm_config->rate % 11025 == 0) &&
306 out->pcm = pcm_open(PCM_CARD, device, PCM_OUT | PCM_NORESTART | PCM_MONOTONIC, out->pcm_config);
308 if (out->pcm && !pcm_is_ready(out->pcm)) {
309 ALOGE("pcm_open(out) failed: %s", pcm_get_error(out->pcm));
310 pcm_close(out->pcm);
318 if (out_get_sample_rate(&out->stream.common) != out->pcm_config->rate) {
319 ret = create_resampler(out_get_sample_rate(&out->stream.common),
320 out->pcm_config->rate,
321 out->pcm_config->channels,
324 &out->resampler);
325 out->buffer_frames = (pcm_config_out.period_size * out->pcm_config->rate) /
326 out_get_sample_rate(&out->stream.common) + 1;
328 out->buffer = malloc(pcm_frames_to_bytes(out->pcm, out->buffer_frames));
331 adev->active_out = out;
364 struct stream_out *out = adev->active_out;
365 pthread_mutex_lock(&out->lock);
367 (out->pcm_config->rate % 8000) != 0) ||
369 (out->pcm_config->rate % 11025) != 0))
370 do_out_standby(out);
371 pthread_mutex_unlock(&out->lock);
540 struct stream_out *out = (struct stream_out *)stream;
542 pthread_mutex_lock(&out->dev->lock);
543 pthread_mutex_lock(&out->lock);
544 do_out_standby(out);
545 pthread_mutex_unlock(&out->lock);
546 pthread_mutex_unlock(&out->dev->lock);
558 struct stream_out *out = (struct stream_out *)stream;
559 struct audio_device *adev = out->dev;
579 pthread_mutex_lock(&out->lock);
580 do_out_standby(out);
581 pthread_mutex_unlock(&out->lock);
601 struct stream_out *out = (struct stream_out *)stream;
602 struct audio_device *adev = out->dev;
627 struct stream_out *out = (struct stream_out *)stream;
628 struct audio_device *adev = out->dev;
644 pthread_mutex_lock(&out->lock);
645 if (out->standby) {
646 ret = start_output_stream(out);
651 out->standby = false;
660 if (!sco_on && (buffer_type != out->buffer_type)) {
668 out->write_threshold = out->pcm_config->period_size * period_count;
670 if (out->buffer_type == OUT_BUFFER_TYPE_UNKNOWN)
671 out->cur_write_threshold = out->write_threshold;
672 out->buffer_type = buffer_type;
677 (int)out->pcm_config->channels) {
689 if (out_get_sample_rate(&stream->common) != out->pcm_config->rate) {
690 out_frames = out->buffer_frames;
691 out->resampler->resample_from_input(out->resampler,
693 out->buffer, &out_frames);
694 in_buffer = out->buffer;
701 size_t period_size = out->pcm_config->period_size;
703 /* do not allow more than out->cur_write_threshold frames in kernel
707 if (pcm_get_htimestamp(out->pcm,
711 kernel_frames = pcm_get_buffer_size(out->pcm) - kernel_frames;
713 if (kernel_frames > out->cur_write_threshold) {
715 (int)(((int64_t)(kernel_frames - out->cur_write_threshold)
716 * 1000000) / out->pcm_config->rate);
729 } while ((kernel_frames > out->cur_write_threshold) &&
739 if (out->cur_write_threshold > out->write_threshold) {
740 out->cur_write_threshold -= period_size / 4;
741 if (out->cur_write_threshold < out->write_threshold) {
742 out->cur_write_threshold = out->write_threshold;
744 } else if (out->cur_write_threshold < out->write_threshold) {
745 out->cur_write_threshold += period_size / 4;
746 if (out->cur_write_threshold > out->write_threshold) {
747 out->cur_write_threshold = out->write_threshold;
749 } else if ((kernel_frames < out->write_threshold) &&
750 ((out->write_threshold - kernel_frames) >
752 out->cur_write_threshold = (kernel_frames / period_size + 1) * period_size;
753 out->cur_write_threshold += period_size / 4;
757 ret = pcm_write(out->pcm, in_buffer, out_frames * frame_size);
760 pthread_mutex_unlock(&out->lock);
764 out->written += out_frames;
768 pthread_mutex_unlock(&out->lock);
803 struct stream_out *out = (struct stream_out *)stream;
806 pthread_mutex_lock(&out->lock);
809 if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
810 size_t kernel_buffer_size = out->pcm_config->period_size * out->pcm_config->period_count;
812 int64_t signed_frames = out->written - kernel_buffer_size + avail;
820 pthread_mutex_unlock(&out->lock);
1030 struct stream_out *out;
1033 out = (struct stream_out *)calloc(1, sizeof(struct stream_out));
1034 if (!out)
1037 out->stream.common.get_sample_rate = out_get_sample_rate;
1038 out->stream.common.set_sample_rate = out_set_sample_rate;
1039 out->stream.common.get_buffer_size = out_get_buffer_size;
1040 out->stream.common.get_channels = out_get_channels;
1041 out->stream.common.get_format = out_get_format;
1042 out->stream.common.set_format = out_set_format;
1043 out->stream.common.standby = out_standby;
1044 out->stream.common.dump = out_dump;
1045 out->stream.common.set_parameters = out_set_parameters;
1046 out
1047 out->stream.common.add_audio_effect = out_add_audio_effect;
1048 out->stream.common.remove_audio_effect = out_remove_audio_effect;
1049 out->stream.get_latency = out_get_latency;
1050 out->stream.set_volume = out_set_volume;
1051 out->stream.write = out_write;
1052 out->stream.get_render_position = out_get_render_position;
1053 out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
1054 out->stream.get_presentation_position = out_get_presentation_position;
1056 out->dev = adev;
1058 config->format = out_get_format(&out->stream.common);
1059 config->channel_mask = out_get_channels(&out->stream.common);
1060 config->sample_rate = out_get_sample_rate(&out->stream.common);
1062 out->standby = true;
1063 /* out->written = 0; by calloc() */
1065 *stream_out = &out->stream;
1069 free(out);