Lines Matching refs:dev_stream
67 struct dev_stream *dev_stream_create(struct cras_rstream *stream, in dev_stream_create()
73 struct dev_stream *out; in dev_stream_create()
150 void dev_stream_destroy(struct dev_stream *dev_stream) in dev_stream_destroy() argument
152 cras_rstream_dev_detach(dev_stream->stream, dev_stream->dev_id); in dev_stream_destroy()
153 if (dev_stream->conv) { in dev_stream_destroy()
154 cras_audio_area_destroy(dev_stream->conv_area); in dev_stream_destroy()
155 cras_fmt_conv_destroy(&dev_stream->conv); in dev_stream_destroy()
156 byte_buffer_destroy(&dev_stream->conv_buffer); in dev_stream_destroy()
158 free(dev_stream); in dev_stream_destroy()
161 void dev_stream_set_dev_rate(struct dev_stream *dev_stream, in dev_stream_set_dev_rate() argument
167 if (dev_stream->dev_id == dev_stream->stream->master_dev.dev_id) { in dev_stream_set_dev_rate()
169 dev_stream->conv, in dev_stream_set_dev_rate()
173 cras_rstream_get_cb_threshold(dev_stream->stream), in dev_stream_set_dev_rate()
174 dev_stream->stream->format.frame_rate * dev_rate_ratio, in dev_stream_set_dev_rate()
175 &dev_stream->stream->sleep_interval_ts); in dev_stream_set_dev_rate()
181 dev_stream->conv, in dev_stream_set_dev_rate()
188 int dev_stream_mix(struct dev_stream *dev_stream, in dev_stream_mix() argument
193 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_mix()
204 fr_in_buf = dev_stream_playback_frames(dev_stream); in dev_stream_mix()
210 buffer_offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_mix()
213 mix_vol = cras_rstream_get_volume_scaler(dev_stream->stream); in dev_stream_mix()
223 if (cras_fmt_conversion_needed(dev_stream->conv)) { in dev_stream_mix()
226 dev_stream->conv, in dev_stream_mix()
228 dev_stream->conv_buffer->bytes, in dev_stream_mix()
231 src = dev_stream->conv_buffer->bytes; in dev_stream_mix()
244 cras_rstream_dev_offset_update(rstream, fr_read, dev_stream->dev_id); in dev_stream_mix()
252 static unsigned int capture_with_fmt_conv(struct dev_stream *dev_stream, in capture_with_fmt_conv() argument
265 source_format = cras_fmt_conv_in_format(dev_stream->conv); in capture_with_fmt_conv()
267 dst_format = cras_fmt_conv_out_format(dev_stream->conv); in capture_with_fmt_conv()
270 dev_stream->conv_area->num_channels = dst_format->num_channels; in capture_with_fmt_conv()
273 buffer = buf_write_pointer_size(dev_stream->conv_buffer, in capture_with_fmt_conv()
281 dev_stream->conv, in capture_with_fmt_conv()
288 buf_increment_write(dev_stream->conv_buffer, in capture_with_fmt_conv()
298 struct dev_stream *dev_stream, in capture_copy_converted_to_stream() argument
314 fmt = cras_fmt_conv_out_format(dev_stream->conv); in capture_copy_converted_to_stream()
317 offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in capture_copy_converted_to_stream()
324 buf_queued(dev_stream->conv_buffer) / in capture_copy_converted_to_stream()
334 buf_read_pointer_size(dev_stream->conv_buffer, in capture_copy_converted_to_stream()
339 cras_audio_area_config_buf_pointers(dev_stream->conv_area, in capture_copy_converted_to_stream()
342 cras_audio_area_config_channels(dev_stream->conv_area, fmt); in capture_copy_converted_to_stream()
343 dev_stream->conv_area->frames = write_frames; in capture_copy_converted_to_stream()
351 dev_stream->conv_area, 0, in capture_copy_converted_to_stream()
354 buf_increment_read(dev_stream->conv_buffer, in capture_copy_converted_to_stream()
358 dev_stream->dev_id); in capture_copy_converted_to_stream()
359 offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id); in capture_copy_converted_to_stream()
369 unsigned int dev_stream_capture(struct dev_stream *dev_stream, in dev_stream_capture() argument
374 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture()
380 if (cras_fmt_conversion_needed(dev_stream->conv)) { in dev_stream_capture()
383 fr_to_capture = dev_stream_capture_avail(dev_stream); in dev_stream_capture()
387 cras_fmt_conv_in_format(dev_stream->conv)); in dev_stream_capture()
389 dev_stream, in dev_stream_capture()
393 capture_copy_converted_to_stream(dev_stream, rstream, in dev_stream_capture()
397 cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_capture()
419 dev_stream->dev_id); in dev_stream_capture()
425 int dev_stream_attached_devs(const struct dev_stream *dev_stream) in dev_stream_attached_devs() argument
427 return dev_stream->stream->num_attached_devs; in dev_stream_attached_devs()
430 void dev_stream_update_frames(const struct dev_stream *dev_stream) in dev_stream_update_frames() argument
432 cras_rstream_update_queued_frames(dev_stream->stream); in dev_stream_update_frames()
435 int dev_stream_playback_frames(const struct dev_stream *dev_stream) in dev_stream_playback_frames() argument
439 frames = cras_rstream_playable_frames(dev_stream->stream, in dev_stream_playback_frames()
440 dev_stream->dev_id); in dev_stream_playback_frames()
444 if (!dev_stream->conv) in dev_stream_playback_frames()
447 return cras_fmt_conv_in_frames_to_out(dev_stream->conv, frames); in dev_stream_playback_frames()
450 unsigned int dev_stream_cb_threshold(const struct dev_stream *dev_stream) in dev_stream_cb_threshold() argument
452 const struct cras_rstream *rstream = dev_stream->stream; in dev_stream_cb_threshold()
456 return cras_fmt_conv_in_frames_to_out(dev_stream->conv, in dev_stream_cb_threshold()
459 return cras_fmt_conv_out_frames_to_in(dev_stream->conv, in dev_stream_cb_threshold()
463 unsigned int dev_stream_capture_avail(const struct dev_stream *dev_stream) in dev_stream_capture_avail() argument
466 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture_avail()
472 cras_rstream_dev_offset(rstream, dev_stream->dev_id); in dev_stream_capture_avail()
480 if (!dev_stream->conv) in dev_stream_capture_avail()
484 cras_fmt_conv_out_format(dev_stream->conv)); in dev_stream_capture_avail()
488 conv_buf_level = buf_queued(dev_stream->conv_buffer) / in dev_stream_capture_avail()
496 buf_available(dev_stream->conv_buffer) / in dev_stream_capture_avail()
499 return cras_fmt_conv_out_frames_to_in(dev_stream->conv, frames_avail); in dev_stream_capture_avail()
503 static void check_next_wake_time(struct dev_stream *dev_stream) in check_next_wake_time() argument
505 struct cras_rstream *rstream = dev_stream->stream; in check_next_wake_time()
516 int dev_stream_playback_update_rstream(struct dev_stream *dev_stream) in dev_stream_playback_update_rstream() argument
518 cras_rstream_update_output_read_pointer(dev_stream->stream); in dev_stream_playback_update_rstream()
522 static int late_enough_for_capture_callback(struct dev_stream *dev_stream) in late_enough_for_capture_callback() argument
525 struct cras_rstream *rstream = dev_stream->stream; in late_enough_for_capture_callback()
531 int dev_stream_capture_update_rstream(struct dev_stream *dev_stream) in dev_stream_capture_update_rstream() argument
533 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_capture_update_rstream()
547 !late_enough_for_capture_callback(dev_stream)) in dev_stream_capture_update_rstream()
575 check_next_wake_time(dev_stream); in dev_stream_capture_update_rstream()
621 void dev_stream_set_delay(const struct dev_stream *dev_stream, in dev_stream_set_delay() argument
624 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_set_delay()
630 stream_frames = cras_fmt_conv_out_frames_to_in(dev_stream->conv, in dev_stream_set_delay()
638 stream_frames = cras_fmt_conv_in_frames_to_out(dev_stream->conv, in dev_stream_set_delay()
648 int dev_stream_can_fetch(struct dev_stream *dev_stream) in dev_stream_can_fetch() argument
650 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_can_fetch()
660 int dev_stream_request_playback_samples(struct dev_stream *dev_stream, in dev_stream_request_playback_samples() argument
663 struct cras_rstream *rstream = dev_stream->stream; in dev_stream_request_playback_samples()
666 rc = cras_rstream_request_audio(dev_stream->stream, now); in dev_stream_request_playback_samples()
672 check_next_wake_time(dev_stream); in dev_stream_request_playback_samples()
677 int dev_stream_poll_stream_fd(const struct dev_stream *dev_stream) in dev_stream_poll_stream_fd() argument
679 const struct cras_rstream *stream = dev_stream->stream; in dev_stream_poll_stream_fd()
702 static int get_input_wake_time(struct dev_stream *dev_stream, in get_input_wake_time() argument
709 struct cras_rstream *rstream = dev_stream->stream; in get_input_wake_time()
713 needed_frames_from_device = dev_stream_capture_avail(dev_stream); in get_input_wake_time()
770 dev_stream->dev_rate, in get_input_wake_time()
786 int dev_stream_wake_time(struct dev_stream *dev_stream, in dev_stream_wake_time() argument
793 if (dev_stream->stream->direction == CRAS_STREAM_OUTPUT) { in dev_stream_wake_time()
802 return get_input_wake_time(dev_stream, curr_level, level_tstamp, in dev_stream_wake_time()
807 int dev_stream_is_pending_reply(const struct dev_stream *dev_stream) in dev_stream_is_pending_reply() argument
809 return cras_rstream_is_pending_reply(dev_stream->stream); in dev_stream_is_pending_reply()
812 int dev_stream_flush_old_audio_messages(struct dev_stream *dev_stream) in dev_stream_flush_old_audio_messages() argument
814 return cras_rstream_flush_old_audio_messages(dev_stream->stream); in dev_stream_flush_old_audio_messages()