Lines Matching refs:rstream
362 void cras_rstream_record_fetch_interval(struct cras_rstream *rstream, in cras_rstream_record_fetch_interval() argument
367 if (rstream->last_fetch_ts.tv_sec || rstream->last_fetch_ts.tv_nsec) { in cras_rstream_record_fetch_interval()
368 subtract_timespecs(now, &rstream->last_fetch_ts, &ts); in cras_rstream_record_fetch_interval()
369 if (timespec_after(&ts, &rstream->longest_fetch_interval)) in cras_rstream_record_fetch_interval()
370 rstream->longest_fetch_interval = ts; in cras_rstream_record_fetch_interval()
428 void cras_rstream_dev_attach(struct cras_rstream *rstream, unsigned int dev_id, in cras_rstream_dev_attach() argument
431 if (buffer_share_add_id(rstream->buf_state, dev_id, dev_ptr) == 0) in cras_rstream_dev_attach()
432 rstream->num_attached_devs++; in cras_rstream_dev_attach()
437 if (rstream->main_dev.dev_id == NO_DEVICE) { in cras_rstream_dev_attach()
438 rstream->main_dev.dev_id = dev_id; in cras_rstream_dev_attach()
439 rstream->main_dev.dev_ptr = dev_ptr; in cras_rstream_dev_attach()
443 void cras_rstream_dev_detach(struct cras_rstream *rstream, unsigned int dev_id) in cras_rstream_dev_detach() argument
445 if (buffer_share_rm_id(rstream->buf_state, dev_id) == 0) in cras_rstream_dev_detach()
446 rstream->num_attached_devs--; in cras_rstream_dev_detach()
448 if (rstream->main_dev.dev_id == dev_id) { in cras_rstream_dev_detach()
453 rstream->main_dev.dev_id = NO_DEVICE; in cras_rstream_dev_detach()
454 rstream->main_dev.dev_ptr = NULL; in cras_rstream_dev_detach()
455 for (i = 0; i < rstream->buf_state->id_sz; i++) { in cras_rstream_dev_detach()
456 o = &rstream->buf_state->wr_idx[i]; in cras_rstream_dev_detach()
458 rstream->main_dev.dev_id = o->id; in cras_rstream_dev_detach()
459 rstream->main_dev.dev_ptr = o->data; in cras_rstream_dev_detach()
466 void cras_rstream_dev_offset_update(struct cras_rstream *rstream, in cras_rstream_dev_offset_update() argument
469 buffer_share_offset_update(rstream->buf_state, dev_id, frames); in cras_rstream_dev_offset_update()
472 void cras_rstream_update_input_write_pointer(struct cras_rstream *rstream) in cras_rstream_update_input_write_pointer() argument
475 buffer_share_get_new_write_point(rstream->buf_state); in cras_rstream_update_input_write_pointer()
477 cras_shm_buffer_written(rstream->shm, nwritten); in cras_rstream_update_input_write_pointer()
480 void cras_rstream_update_output_read_pointer(struct cras_rstream *rstream) in cras_rstream_update_output_read_pointer() argument
485 buffer_share_get_new_write_point(rstream->buf_state); in cras_rstream_update_output_read_pointer()
489 src = cras_shm_get_readable_frames(rstream->shm, 0, &nfr); in cras_rstream_update_output_read_pointer()
490 ewma_power_calculate(&rstream->ewma, (int16_t *)src, in cras_rstream_update_output_read_pointer()
491 rstream->format.num_channels, nwritten); in cras_rstream_update_output_read_pointer()
492 cras_shm_buffer_read(rstream->shm, nwritten); in cras_rstream_update_output_read_pointer()
495 unsigned int cras_rstream_dev_offset(const struct cras_rstream *rstream, in cras_rstream_dev_offset() argument
498 return buffer_share_id_offset(rstream->buf_state, dev_id); in cras_rstream_dev_offset()
501 void cras_rstream_update_queued_frames(struct cras_rstream *rstream) in cras_rstream_update_queued_frames() argument
503 rstream->queued_frames = in cras_rstream_update_queued_frames()
504 MIN(cras_shm_get_frames(rstream->shm), rstream->buffer_frames); in cras_rstream_update_queued_frames()
507 unsigned int cras_rstream_playable_frames(struct cras_rstream *rstream, in cras_rstream_playable_frames() argument
510 return rstream->queued_frames - in cras_rstream_playable_frames()
511 cras_rstream_dev_offset(rstream, dev_id); in cras_rstream_playable_frames()
514 float cras_rstream_get_volume_scaler(struct cras_rstream *rstream) in cras_rstream_get_volume_scaler() argument
516 return cras_shm_get_volume_scaler(rstream->shm); in cras_rstream_get_volume_scaler()
519 uint8_t *cras_rstream_get_readable_frames(struct cras_rstream *rstream, in cras_rstream_get_readable_frames() argument
522 return cras_shm_get_readable_frames(rstream->shm, offset, frames); in cras_rstream_get_readable_frames()
525 int cras_rstream_get_mute(const struct cras_rstream *rstream) in cras_rstream_get_mute() argument
527 return cras_shm_get_mute(rstream->shm); in cras_rstream_get_mute()