Lines Matching refs:out
260 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_sample_rate() local
261 return out->req_config.sample_rate; in out_get_sample_rate()
271 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_buffer_size() local
272 int size = out->pcm_config.period_size * in out_get_buffer_size()
273 audio_stream_out_frame_size(&out->stream); in out_get_buffer_size()
280 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_channels() local
281 return out->req_config.channel_mask; in out_get_channels()
286 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_format() local
288 return out->req_config.format; in out_get_format()
298 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_dump() local
299 pthread_mutex_lock(&out->lock); in out_dump()
310 if (out->num_devices == 0) { in out_dump()
313 for (uint32_t i = 0; i < out->num_devices; i++) { in out_dump()
317 dprintf(fd, "%08x", out->devices[i]); in out_dump()
321 dprintf(fd, "\t\taudio dev: %p\n\n", out->dev); in out_dump()
322 pthread_mutex_unlock(&out->lock); in out_dump()
360 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_parameters() local
370 pthread_mutex_lock(&out->lock); in out_get_parameters()
372 for (uint32_t i = 0; i < out->num_devices; i++) { in out_get_parameters()
373 device |= out->devices[i]; in out_get_parameters()
376 pthread_mutex_unlock(&out->lock); in out_get_parameters()
408 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_latency() local
409 return (out->pcm_config.period_size * 1000) / out->pcm_config.rate; in out_get_latency()
420 struct generic_stream_out *out = (struct generic_stream_out *)args; in out_write_worker() local
428 pthread_mutex_lock(&out->lock); in out_write_worker()
429 while (out->worker_standby || restart) { in out_write_worker()
437 if (out->worker_exit) { in out_write_worker()
440 pthread_cond_wait(&out->worker_wake, &out->lock); in out_write_worker()
443 if (out->worker_exit) { in out_write_worker()
444 if (!out->worker_standby) { in out_write_worker()
450 while (!shutdown && audio_vbuffer_live(&out->buffer) == 0) { in out_write_worker()
451 pthread_cond_wait(&out->worker_wake, &out->lock); in out_write_worker()
455 pthread_mutex_unlock(&out->lock); in out_write_worker()
461 PCM_OUT | PCM_MONOTONIC, &out->pcm_config); in out_write_worker()
465 out->pcm_config.channels, in out_write_worker()
466 out->pcm_config.format, in out_write_worker()
467 out->pcm_config.rate in out_write_worker()
469 pthread_mutex_unlock(&out->lock); in out_write_worker()
472 buffer_frames = out->pcm_config.period_size; in out_write_worker()
477 pthread_mutex_unlock(&out->lock); in out_write_worker()
481 int frames = audio_vbuffer_read(&out->buffer, buffer, buffer_frames); in out_write_worker()
482 pthread_mutex_unlock(&out->lock); in out_write_worker()
497 static void get_current_output_position(struct generic_stream_out *out, in get_current_output_position() argument
507 if (out->standby) { in get_current_output_position()
510 const int64_t first_us = (out->underrun_time.tv_sec * 1000000000LL + in get_current_output_position()
511 out->underrun_time.tv_nsec) / 1000; in get_current_output_position()
513 out_get_sample_rate(&out->stream.common) / in get_current_output_position()
519 *position = out->underrun_position + position_since_underrun; in get_current_output_position()
523 if (*position > out->frames_written) { in get_current_output_position()
526 *position, out->frames_written); in get_current_output_position()
528 *position = out->frames_written; in get_current_output_position()
529 out->underrun_position = *position; in get_current_output_position()
530 out->underrun_time = curtime; in get_current_output_position()
531 out->frames_total_buffered = 0; in get_current_output_position()
539 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_write() local
542 pthread_mutex_lock(&out->lock); in out_write()
544 if (out->worker_standby) { in out_write()
545 out->worker_standby = false; in out_write()
551 get_current_output_position(out, ¤t_position, ¤t_time); in out_write()
554 if (out->standby) { in out_write()
555 out->standby = false; in out_write()
556 out->underrun_time = current_time; in out_write()
557 out->frames_rendered = 0; in out_write()
558 out->frames_total_buffered = 0; in out_write()
561 size_t frames_written = audio_vbuffer_write(&out->buffer, buffer, frames); in out_write()
562 pthread_cond_signal(&out->worker_wake); in out_write()
565 out->frames_written += frames; in out_write()
566 out->frames_rendered += frames; in out_write()
567 out->frames_total_buffered += frames; in out_write()
574 int frames_sleep = out->frames_total_buffered < out->buffer.frame_count ? 0 : frames; in out_write()
581 uint64_t time_since_last_write_us = now_us - out->last_write_time_us; in out_write()
587 out->last_write_time_us = now_us + sleep_time_us; in out_write()
589 pthread_mutex_unlock(&out->lock); in out_write()
610 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_presentation_position() local
612 pthread_mutex_lock(&out->lock); in out_get_presentation_position()
613 get_current_output_position(out, frames, timestamp); in out_get_presentation_position()
614 pthread_mutex_unlock(&out->lock); in out_get_presentation_position()
625 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_render_position() local
626 pthread_mutex_lock(&out->lock); in out_get_render_position()
627 *dsp_frames = out->frames_rendered; in out_get_render_position()
628 pthread_mutex_unlock(&out->lock); in out_get_render_position()
633 static void do_out_standby(struct generic_stream_out *out) in do_out_standby() argument
637 if (out->standby) { in do_out_standby()
641 get_current_output_position(out, &out->underrun_position, NULL); in do_out_standby()
642 frames_sleep = out->frames_written - out->underrun_position; in do_out_standby()
649 out_get_sample_rate(&out->stream.common); in do_out_standby()
651 pthread_mutex_unlock(&out->lock); in do_out_standby()
653 pthread_mutex_lock(&out->lock); in do_out_standby()
655 out->worker_standby = true; in do_out_standby()
656 out->standby = true; in do_out_standby()
661 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_standby() local
662 pthread_mutex_lock(&out->lock); in out_standby()
663 do_out_standby(out); in out_standby()
664 pthread_mutex_unlock(&out->lock); in out_standby()
1196 struct generic_stream_out *out; in adev_open_output_stream() local
1206 out = (struct generic_stream_out *)calloc(1, sizeof(struct generic_stream_out)); in adev_open_output_stream()
1208 if (!out) in adev_open_output_stream()
1211 out->stream.common.get_sample_rate = out_get_sample_rate; in adev_open_output_stream()
1212 out->stream.common.set_sample_rate = out_set_sample_rate; in adev_open_output_stream()
1213 out->stream.common.get_buffer_size = out_get_buffer_size; in adev_open_output_stream()
1214 out->stream.common.get_channels = out_get_channels; in adev_open_output_stream()
1215 out->stream.common.get_format = out_get_format; in adev_open_output_stream()
1216 out->stream.common.set_format = out_set_format; in adev_open_output_stream()
1217 out->stream.common.standby = out_standby; in adev_open_output_stream()
1218 out->stream.common.dump = out_dump; in adev_open_output_stream()
1219 out->stream.common.set_parameters = out_set_parameters; in adev_open_output_stream()
1220 out->stream.common.get_parameters = out_get_parameters; in adev_open_output_stream()
1221 out->stream.common.add_audio_effect = out_add_audio_effect; in adev_open_output_stream()
1222 out->stream.common.remove_audio_effect = out_remove_audio_effect; in adev_open_output_stream()
1223 out->stream.get_latency = out_get_latency; in adev_open_output_stream()
1224 out->stream.set_volume = out_set_volume; in adev_open_output_stream()
1225 out->stream.write = out_write; in adev_open_output_stream()
1226 out->stream.get_render_position = out_get_render_position; in adev_open_output_stream()
1227 out->stream.get_presentation_position = out_get_presentation_position; in adev_open_output_stream()
1228 out->stream.get_next_write_timestamp = out_get_next_write_timestamp; in adev_open_output_stream()
1230 out->handle = handle; in adev_open_output_stream()
1232 pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL); in adev_open_output_stream()
1233 out->dev = adev; in adev_open_output_stream()
1235 out->num_devices = 1; in adev_open_output_stream()
1236 out->devices[0] = devices; in adev_open_output_stream()
1237 memcpy(&out->req_config, config, sizeof(struct audio_config)); in adev_open_output_stream()
1238 memcpy(&out->pcm_config, &pcm_config_out, sizeof(struct pcm_config)); in adev_open_output_stream()
1239 out->pcm_config.rate = config->sample_rate; in adev_open_output_stream()
1240 out->pcm_config.period_size = out->pcm_config.rate*OUT_PERIOD_MS/1000; in adev_open_output_stream()
1242 out->standby = true; in adev_open_output_stream()
1243 out->underrun_position = 0; in adev_open_output_stream()
1244 out->underrun_time.tv_sec = 0; in adev_open_output_stream()
1245 out->underrun_time.tv_nsec = 0; in adev_open_output_stream()
1246 out->last_write_time_us = 0; in adev_open_output_stream()
1247 out->frames_total_buffered = 0; in adev_open_output_stream()
1248 out->frames_written = 0; in adev_open_output_stream()
1249 out->frames_rendered = 0; in adev_open_output_stream()
1251 ret = audio_vbuffer_init(&out->buffer, in adev_open_output_stream()
1252 out->pcm_config.period_size*out->pcm_config.period_count, in adev_open_output_stream()
1253 out->pcm_config.channels * in adev_open_output_stream()
1254 pcm_format_to_bits(out->pcm_config.format) >> 3); in adev_open_output_stream()
1256 pthread_cond_init(&out->worker_wake, NULL); in adev_open_output_stream()
1257 out->worker_standby = true; in adev_open_output_stream()
1258 out->worker_exit = false; in adev_open_output_stream()
1259 pthread_create(&out->worker_thread, NULL, out_write_worker, out); in adev_open_output_stream()
1264 list_add_tail(&adev->out_streams, &out->stream_node); in adev_open_output_stream()
1267 *stream_out = &out->stream; in adev_open_output_stream()
1280 struct generic_stream_out *out = node_to_item( in get_stream_out_by_io_handle_l() local
1282 if (out->handle == handle) { in get_stream_out_by_io_handle_l()
1283 return out; in get_stream_out_by_io_handle_l()
1292 struct generic_stream_out *out = (struct generic_stream_out *)stream; in adev_close_output_stream() local
1293 pthread_mutex_lock(&out->lock); in adev_close_output_stream()
1294 do_out_standby(out); in adev_close_output_stream()
1296 out->worker_exit = true; in adev_close_output_stream()
1297 pthread_cond_signal(&out->worker_wake); in adev_close_output_stream()
1298 pthread_mutex_unlock(&out->lock); in adev_close_output_stream()
1300 pthread_join(out->worker_thread, NULL); in adev_close_output_stream()
1301 pthread_mutex_destroy(&out->lock); in adev_close_output_stream()
1302 audio_vbuffer_destroy(&out->buffer); in adev_close_output_stream()
1306 list_remove(&out->stream_node); in adev_close_output_stream()
1617 struct generic_stream_out *out = in adev_create_audio_patch() local
1619 if (out == NULL) { in adev_create_audio_patch()
1626 if (!generatedPatchHandle && out->patch_handle != *handle) { in adev_create_audio_patch()
1629 __func__, *handle, out->patch_handle, out->handle); in adev_create_audio_patch()
1631 pthread_mutex_unlock(&out->lock); in adev_create_audio_patch()
1634 pthread_mutex_lock(&out->lock); in adev_create_audio_patch()
1635 for (out->num_devices = 0; out->num_devices < num_sinks; out->num_devices++) { in adev_create_audio_patch()
1636 out->devices[out->num_devices] = sinks[out->num_devices].ext.device.type; in adev_create_audio_patch()
1638 pthread_mutex_unlock(&out->lock); in adev_create_audio_patch()
1639 out->patch_handle = *handle; in adev_create_audio_patch()
1656 struct generic_stream_out *out = node_to_item( in get_stream_out_by_patch_handle_l() local
1658 if (out->patch_handle == patch_handle) { in get_stream_out_by_patch_handle_l()
1659 return out; in get_stream_out_by_patch_handle_l()
1685 struct generic_stream_out *out = get_stream_out_by_patch_handle_l(adev, patch_handle); in adev_release_audio_patch() local
1686 if (out != NULL) { in adev_release_audio_patch()
1687 pthread_mutex_lock(&out->lock); in adev_release_audio_patch()
1688 out->num_devices = 0; in adev_release_audio_patch()
1689 memset(out->devices, 0, sizeof(out->devices)); in adev_release_audio_patch()
1690 pthread_mutex_unlock(&out->lock); in adev_release_audio_patch()
1691 out->patch_handle = AUDIO_PATCH_HANDLE_NONE; in adev_release_audio_patch()