summaryrefslogtreecommitdiff
path: root/cras/src/server/dev_stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'cras/src/server/dev_stream.c')
-rw-r--r--cras/src/server/dev_stream.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/cras/src/server/dev_stream.c b/cras/src/server/dev_stream.c
index 025aeddd..be5a6dab 100644
--- a/cras/src/server/dev_stream.c
+++ b/cras/src/server/dev_stream.c
@@ -63,7 +63,8 @@ unsigned int max_frames_for_conversion(unsigned int stream_frames,
struct dev_stream *dev_stream_create(struct cras_rstream *stream,
unsigned int dev_id,
const struct cras_audio_format *dev_fmt,
- void *dev_ptr, struct timespec *cb_ts)
+ void *dev_ptr, struct timespec *cb_ts,
+ const struct timespec *sleep_interval_ts)
{
struct dev_stream *out;
struct cras_audio_format *stream_fmt = &stream->format;
@@ -122,8 +123,15 @@ struct dev_stream *dev_stream_create(struct cras_rstream *stream,
out->conv_buffer = byte_buffer_create(buf_bytes);
out->conv_area = cras_audio_area_create(ofmt->num_channels);
- cras_frames_to_time(cras_rstream_get_cb_threshold(stream),
- stream_fmt->frame_rate, &stream->sleep_interval_ts);
+ /* Use sleep interval hint from argument if it is provided */
+ if (sleep_interval_ts) {
+ stream->sleep_interval_ts = *sleep_interval_ts;
+ } else {
+ cras_frames_to_time(cras_rstream_get_cb_threshold(stream),
+ stream_fmt->frame_rate,
+ &stream->sleep_interval_ts);
+ }
+
stream->next_cb_ts = *cb_ts;
/* Sets up the stream & dev pair. */
@@ -149,9 +157,9 @@ void dev_stream_destroy(struct dev_stream *dev_stream)
void dev_stream_set_dev_rate(struct dev_stream *dev_stream,
unsigned int dev_rate, double dev_rate_ratio,
- double master_rate_ratio, int coarse_rate_adjust)
+ double main_rate_ratio, int coarse_rate_adjust)
{
- if (dev_stream->dev_id == dev_stream->stream->master_dev.dev_id) {
+ if (dev_stream->dev_id == dev_stream->stream->main_dev.dev_id) {
cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
dev_rate, dev_rate);
cras_frames_to_time_precise(
@@ -159,9 +167,8 @@ void dev_stream_set_dev_rate(struct dev_stream *dev_stream,
dev_stream->stream->format.frame_rate * dev_rate_ratio,
&dev_stream->stream->sleep_interval_ts);
} else {
- double new_rate =
- dev_rate * dev_rate_ratio / master_rate_ratio +
- coarse_rate_adjust_step * coarse_rate_adjust;
+ double new_rate = dev_rate * dev_rate_ratio / main_rate_ratio +
+ coarse_rate_adjust_step * coarse_rate_adjust;
cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
dev_rate, new_rate);
}