Lines Matching refs:dev_stream
63 struct dev_stream *dev_stream_create(struct cras_rstream *stream, in dev_stream_create()
69 struct dev_stream *out; in dev_stream_create()
143 void dev_stream_destroy(struct dev_stream *dev_stream) in dev_stream_destroy() argument
146 cras_rstream_dev_ptr(dev_stream->stream, dev_stream->dev_id); in dev_stream_destroy()
148 cras_apm_list_stop_apm(dev_stream->stream->apm_list, dev_ptr); in dev_stream_destroy()
149 cras_rstream_dev_detach(dev_stream->stream, dev_stream->dev_id); in dev_stream_destroy()
150 if (dev_stream->conv) { in dev_stream_destroy()
151 cras_audio_area_destroy(dev_stream->conv_area); in dev_stream_destroy()
152 cras_fmt_conv_destroy(&dev_stream->conv); in dev_stream_destroy()
153 byte_buffer_destroy(&dev_stream->conv_buffer); in dev_stream_destroy()
155 free(dev_stream); in dev_stream_destroy()
158 void dev_stream_set_dev_rate(struct dev_stream *dev_stream, in dev_stream_set_dev_rate() argument
162 if (dev_stream->dev_id == dev_stream->stream->main_dev.dev_id) { in dev_stream_set_dev_rate()
163 cras_fmt_conv_set_linear_resample_rates(dev_stream->conv, in dev_stream_set_dev_rate()
166 cras_rstream_get_cb_threshold(dev_stream->stream), in dev_stream_set_dev_rate()
167 dev_stream->stream->format.frame_rate * dev_rate_ratio, in dev_stream_set_dev_rate()
168 &dev_stream->stream->sleep_interval_ts); in dev_stream_set_dev_rate()
172 cras_fmt_conv_set_linear_resample_rates(dev_stream->conv, in dev_stream_set_dev_rate()
177 int dev_stream_mix(struct dev_stream *dev_stream, in dev_stream_mix() argument
181 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_mix()
192 fr_in_buf = dev_stream_playback_frames(dev_stream); in dev_stream_mix()
198 buffer_offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_mix()
201 mix_vol = cras_rstream_get_volume_scaler(dev_stream->stream); in dev_stream_mix()
211 if (cras_fmt_conversion_needed(dev_stream->conv)) { in dev_stream_mix()
214 dev_stream->conv, src, in dev_stream_mix()
215 dev_stream->conv_buffer->bytes, &read_frames, in dev_stream_mix()
217 src = dev_stream->conv_buffer->bytes; in dev_stream_mix()
230 cras_rstream_dev_offset_update(rstream, fr_read, dev_stream->dev_id); in dev_stream_mix()
237 static unsigned int capture_with_fmt_conv(struct dev_stream *dev_stream, in capture_with_fmt_conv() argument
250 source_format = cras_fmt_conv_in_format(dev_stream->conv); in capture_with_fmt_conv()
252 dst_format = cras_fmt_conv_out_format(dev_stream->conv); in capture_with_fmt_conv()
255 dev_stream->conv_area->num_channels = dst_format->num_channels; in capture_with_fmt_conv()
258 buffer = buf_write_pointer_size(dev_stream->conv_buffer, in capture_with_fmt_conv()
266 dev_stream->conv, source_samples, buffer, &read_frames, in capture_with_fmt_conv()
270 buf_increment_write(dev_stream->conv_buffer, in capture_with_fmt_conv()
281 capture_copy_converted_to_stream(struct dev_stream *dev_stream, in capture_copy_converted_to_stream() argument
297 fmt = cras_fmt_conv_out_format(dev_stream->conv); in capture_copy_converted_to_stream()
300 offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in capture_copy_converted_to_stream()
306 buf_queued(dev_stream->conv_buffer) / frame_bytes); in capture_copy_converted_to_stream()
313 dev_stream->conv_buffer, &write_frames); in capture_copy_converted_to_stream()
317 cras_audio_area_config_buf_pointers(dev_stream->conv_area, fmt, in capture_copy_converted_to_stream()
319 cras_audio_area_config_channels(dev_stream->conv_area, fmt); in capture_copy_converted_to_stream()
320 dev_stream->conv_area->frames = write_frames; in capture_copy_converted_to_stream()
326 &rstream->format, dev_stream->conv_area, 0, in capture_copy_converted_to_stream()
329 buf_increment_read(dev_stream->conv_buffer, in capture_copy_converted_to_stream()
333 dev_stream->dev_id); in capture_copy_converted_to_stream()
334 offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in capture_copy_converted_to_stream()
342 unsigned int dev_stream_capture(struct dev_stream *dev_stream, in dev_stream_capture() argument
347 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture()
353 if (cras_fmt_conversion_needed(dev_stream->conv)) { in dev_stream_capture()
356 fr_to_capture = dev_stream_capture_avail(dev_stream); in dev_stream_capture()
360 cras_fmt_conv_in_format(dev_stream->conv)); in dev_stream_capture()
362 dev_stream, in dev_stream_capture()
366 capture_copy_converted_to_stream(dev_stream, rstream, in dev_stream_capture()
370 cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_capture()
387 dev_stream->dev_id); in dev_stream_capture()
393 int dev_stream_attached_devs(const struct dev_stream *dev_stream) in dev_stream_attached_devs() argument
395 return dev_stream->stream->num_attached_devs; in dev_stream_attached_devs()
398 void dev_stream_update_frames(const struct dev_stream *dev_stream) in dev_stream_update_frames() argument
400 cras_rstream_update_queued_frames(dev_stream->stream); in dev_stream_update_frames()
403 int dev_stream_playback_frames(const struct dev_stream *dev_stream) in dev_stream_playback_frames() argument
407 frames = cras_rstream_playable_frames(dev_stream->stream, in dev_stream_playback_frames()
408 dev_stream->dev_id); in dev_stream_playback_frames()
412 if (!dev_stream->conv) in dev_stream_playback_frames()
415 return cras_fmt_conv_in_frames_to_out(dev_stream->conv, frames); in dev_stream_playback_frames()
418 unsigned int dev_stream_cb_threshold(const struct dev_stream *dev_stream) in dev_stream_cb_threshold() argument
420 const struct cras_rstream *rstream = dev_stream->stream; in dev_stream_cb_threshold()
424 return cras_fmt_conv_in_frames_to_out(dev_stream->conv, in dev_stream_cb_threshold()
427 return cras_fmt_conv_out_frames_to_in(dev_stream->conv, in dev_stream_cb_threshold()
431 unsigned int dev_stream_capture_avail(const struct dev_stream *dev_stream) in dev_stream_capture_avail() argument
434 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture_avail()
440 cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_capture_avail()
448 if (!dev_stream->conv) in dev_stream_capture_avail()
452 cras_fmt_conv_out_format(dev_stream->conv)); in dev_stream_capture_avail()
456 conv_buf_level = buf_queued(dev_stream->conv_buffer) / format_bytes; in dev_stream_capture_avail()
464 buf_available(dev_stream->conv_buffer) / format_bytes); in dev_stream_capture_avail()
466 return cras_fmt_conv_out_frames_to_in(dev_stream->conv, frames_avail); in dev_stream_capture_avail()
470 static void check_next_wake_time(struct dev_stream *dev_stream) in check_next_wake_time() argument
472 struct cras_rstream *rstream = dev_stream->stream; in check_next_wake_time()
486 void dev_stream_update_next_wake_time(struct dev_stream *dev_stream) in dev_stream_update_next_wake_time() argument
488 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_update_next_wake_time()
504 check_next_wake_time(dev_stream); in dev_stream_update_next_wake_time()
507 int dev_stream_playback_update_rstream(struct dev_stream *dev_stream) in dev_stream_playback_update_rstream() argument
509 cras_rstream_update_output_read_pointer(dev_stream->stream); in dev_stream_playback_update_rstream()
513 static int late_enough_for_capture_callback(struct dev_stream *dev_stream) in late_enough_for_capture_callback() argument
516 struct cras_rstream *rstream = dev_stream->stream; in late_enough_for_capture_callback()
522 int dev_stream_capture_update_rstream(struct dev_stream *dev_stream) in dev_stream_capture_update_rstream() argument
524 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture_update_rstream()
538 !late_enough_for_capture_callback(dev_stream)) in dev_stream_capture_update_rstream()
560 dev_stream_update_next_wake_time(dev_stream); in dev_stream_capture_update_rstream()
604 void dev_stream_set_delay(const struct dev_stream *dev_stream, in dev_stream_set_delay() argument
607 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_set_delay()
613 stream_frames = cras_fmt_conv_out_frames_to_in(dev_stream->conv, in dev_stream_set_delay()
621 stream_frames = cras_fmt_conv_in_frames_to_out(dev_stream->conv, in dev_stream_set_delay()
630 int dev_stream_request_playback_samples(struct dev_stream *dev_stream, in dev_stream_request_playback_samples() argument
635 rc = cras_rstream_request_audio(dev_stream->stream, now); in dev_stream_request_playback_samples()
639 dev_stream_update_next_wake_time(dev_stream); in dev_stream_request_playback_samples()
644 int dev_stream_poll_stream_fd(const struct dev_stream *dev_stream) in dev_stream_poll_stream_fd() argument
646 const struct cras_rstream *stream = dev_stream->stream; in dev_stream_poll_stream_fd()
669 static int get_input_wake_time(struct dev_stream *dev_stream, in get_input_wake_time() argument
675 struct cras_rstream *rstream = dev_stream->stream; in get_input_wake_time()
679 needed_frames_from_device = dev_stream_capture_avail(dev_stream); in get_input_wake_time()
735 cras_frames_to_time(needed_frames_from_device, dev_stream->dev_rate, in get_input_wake_time()
749 dev_stream->stream->stream_id, wake_time_out->tv_sec, in get_input_wake_time()
755 int dev_stream_wake_time(struct dev_stream *dev_stream, unsigned int curr_level, in dev_stream_wake_time() argument
760 if (dev_stream->stream->direction == CRAS_STREAM_OUTPUT) { in dev_stream_wake_time()
769 return get_input_wake_time(dev_stream, curr_level, level_tstamp, in dev_stream_wake_time()
774 int dev_stream_is_pending_reply(const struct dev_stream *dev_stream) in dev_stream_is_pending_reply() argument
776 return cras_rstream_is_pending_reply(dev_stream->stream); in dev_stream_is_pending_reply()
779 int dev_stream_flush_old_audio_messages(struct dev_stream *dev_stream) in dev_stream_flush_old_audio_messages() argument
781 return cras_rstream_flush_old_audio_messages(dev_stream->stream); in dev_stream_flush_old_audio_messages()