CRAS: Format stream
Reformat codes with the .clang-format we just introduced.
To format whole files provided in-place:
clang-format -i -style=file [<file> ...]
BUG=chromium:950858
TEST=Add directory to check_format_error and run
FEATURES="test" USE=asan emerge-${BOARD} -v media-sound/adhd
Change-Id: I6b6479ceee554130e7dc27b7c9bcfa142c7cf864
Reviewed-on: https://chromium-review.googlesource.com/1670628
Tested-by: En-Shuo Hsu <enshuo@google.com>
Commit-Ready: En-Shuo Hsu <enshuo@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
diff --git a/cras/src/server/cras_rstream.c b/cras/src/server/cras_rstream.c
index ec7a4eb..c4bba28 100644
--- a/cras/src/server/cras_rstream.c
+++ b/cras/src/server/cras_rstream.c
@@ -65,8 +65,7 @@
static int verify_rstream_parameters(enum CRAS_STREAM_DIRECTION direction,
const struct cras_audio_format *format,
enum CRAS_STREAM_TYPE stream_type,
- size_t buffer_frames,
- size_t cb_threshold,
+ size_t buffer_frames, size_t cb_threshold,
struct cras_rclient *client,
struct cras_rstream **stream_out)
{
@@ -133,8 +132,8 @@
* A negative error code if read fails or the message from client
* has errors.
*/
-static int get_audio_request_reply(
- const struct cras_rstream *stream, struct audio_message *msg)
+static int get_audio_request_reply(const struct cras_rstream *stream,
+ struct audio_message *msg)
{
int rc;
@@ -155,8 +154,8 @@
* A negative error code if read fails or the message from client
* has errors.
*/
-static int read_and_handle_client_message(struct cras_rstream *stream) {
-
+static int read_and_handle_client_message(struct cras_rstream *stream)
+{
struct audio_message msg;
int rc;
@@ -230,9 +229,10 @@
}
stream->buf_state = buffer_share_create(stream->buffer_frames);
- stream->apm_list = (stream->direction == CRAS_STREAM_INPUT)
- ? cras_apm_list_create(stream, config->effects)
- : NULL;
+ stream->apm_list =
+ (stream->direction == CRAS_STREAM_INPUT) ?
+ cras_apm_list_create(stream, config->effects) :
+ NULL;
syslog(LOG_DEBUG, "stream %x frames %zu, cb_thresh %zu",
config->stream_id, config->buffer_frames, config->cb_threshold);
@@ -260,13 +260,13 @@
unsigned int cras_rstream_get_effects(const struct cras_rstream *stream)
{
- return stream->apm_list
- ? cras_apm_list_get_effects(stream->apm_list)
- : 0;
+ return stream->apm_list ? cras_apm_list_get_effects(stream->apm_list) :
+ 0;
}
-struct cras_audio_format *cras_rstream_post_processing_format(
- const struct cras_rstream *stream, void *dev_ptr)
+struct cras_audio_format *
+cras_rstream_post_processing_format(const struct cras_rstream *stream,
+ void *dev_ptr)
{
struct cras_apm *apm;
@@ -292,8 +292,7 @@
}
static void init_audio_message(struct audio_message *msg,
- enum CRAS_AUDIO_MESSAGE_ID id,
- uint32_t frames)
+ enum CRAS_AUDIO_MESSAGE_ID id, uint32_t frames)
{
memset(msg, 0, sizeof(*msg));
msg->id = id;
@@ -346,8 +345,7 @@
return rc;
}
-void cras_rstream_dev_attach(struct cras_rstream *rstream,
- unsigned int dev_id,
+void cras_rstream_dev_attach(struct cras_rstream *rstream, unsigned int dev_id,
void *dev_ptr)
{
if (buffer_share_add_id(rstream->buf_state, dev_id, dev_ptr) == 0)
@@ -386,24 +384,23 @@
}
void cras_rstream_dev_offset_update(struct cras_rstream *rstream,
- unsigned int frames,
- unsigned int dev_id)
+ unsigned int frames, unsigned int dev_id)
{
buffer_share_offset_update(rstream->buf_state, dev_id, frames);
}
void cras_rstream_update_input_write_pointer(struct cras_rstream *rstream)
{
- unsigned int nwritten = buffer_share_get_new_write_point(
- rstream->buf_state);
+ unsigned int nwritten =
+ buffer_share_get_new_write_point(rstream->buf_state);
cras_shm_buffer_written(rstream->shm, nwritten);
}
void cras_rstream_update_output_read_pointer(struct cras_rstream *rstream)
{
- unsigned int nwritten = buffer_share_get_new_write_point(
- rstream->buf_state);
+ unsigned int nwritten =
+ buffer_share_get_new_write_point(rstream->buf_state);
cras_shm_buffer_read(rstream->shm, nwritten);
}
@@ -424,7 +421,7 @@
unsigned int dev_id)
{
return rstream->queued_frames -
- cras_rstream_dev_offset(rstream, dev_id);
+ cras_rstream_dev_offset(rstream, dev_id);
}
float cras_rstream_get_volume_scaler(struct cras_rstream *rstream)
@@ -433,8 +430,7 @@
}
uint8_t *cras_rstream_get_readable_frames(struct cras_rstream *rstream,
- unsigned int offset,
- size_t *frames)
+ unsigned int offset, size_t *frames)
{
return cras_shm_get_readable_frames(rstream->shm, offset, frames);
}
diff --git a/cras/src/server/cras_rstream.h b/cras/src/server/cras_rstream.h
index e06e7c9..af50f74 100644
--- a/cras/src/server/cras_rstream.h
+++ b/cras/src/server/cras_rstream.h
@@ -130,29 +130,29 @@
void cras_rstream_destroy(struct cras_rstream *stream);
/* Gets the id of the stream */
-static inline cras_stream_id_t cras_rstream_id(
- const struct cras_rstream *stream)
+static inline cras_stream_id_t
+cras_rstream_id(const struct cras_rstream *stream)
{
return stream->stream_id;
}
/* Gets the total buffer size in frames for the given client stream. */
-static inline size_t cras_rstream_get_buffer_frames(
- const struct cras_rstream *stream)
+static inline size_t
+cras_rstream_get_buffer_frames(const struct cras_rstream *stream)
{
return stream->buffer_frames;
}
/* Gets the callback threshold in frames for the given client stream. */
-static inline size_t cras_rstream_get_cb_threshold(
- const struct cras_rstream *stream)
+static inline size_t
+cras_rstream_get_cb_threshold(const struct cras_rstream *stream)
{
return stream->cb_threshold;
}
/* Gets the max write size for the stream. */
-static inline size_t cras_rstream_get_max_write_frames(
- const struct cras_rstream *stream)
+static inline size_t
+cras_rstream_get_max_write_frames(const struct cras_rstream *stream)
{
if (stream->flags & BULK_AUDIO_OK)
return cras_rstream_get_buffer_frames(stream);
@@ -160,15 +160,15 @@
}
/* Gets the stream type of this stream. */
-static inline enum CRAS_STREAM_TYPE cras_rstream_get_type(
- const struct cras_rstream *stream)
+static inline enum CRAS_STREAM_TYPE
+cras_rstream_get_type(const struct cras_rstream *stream)
{
return stream->stream_type;
}
/* Gets the direction (input/output/loopback) of the stream. */
-static inline enum CRAS_STREAM_DIRECTION cras_rstream_get_direction(
- const struct cras_rstream *stream)
+static inline enum CRAS_STREAM_DIRECTION
+cras_rstream_get_direction(const struct cras_rstream *stream)
{
return stream->direction;
}
@@ -195,15 +195,15 @@
}
/* Gets the is_draning flag. */
-static inline
-int cras_rstream_get_is_draining(const struct cras_rstream *stream)
+static inline int
+cras_rstream_get_is_draining(const struct cras_rstream *stream)
{
return stream->is_draining;
}
/* Sets the is_draning flag. */
static inline void cras_rstream_set_is_draining(struct cras_rstream *stream,
- int is_draining)
+ int is_draining)
{
stream->is_draining = is_draining;
}
@@ -222,8 +222,8 @@
}
/* Gets the total size of shm memory allocated. */
-static inline size_t cras_rstream_get_total_shm_size(
- const struct cras_rstream *stream)
+static inline size_t
+cras_rstream_get_total_shm_size(const struct cras_rstream *stream)
{
return cras_shm_total_size(stream->shm);
}
@@ -249,8 +249,9 @@
unsigned int cras_rstream_get_effects(const struct cras_rstream *stream);
/* Gets the format of data after stream specific processing. */
-struct cras_audio_format *cras_rstream_post_processing_format(
- const struct cras_rstream *stream, void *dev_ptr);
+struct cras_audio_format *
+cras_rstream_post_processing_format(const struct cras_rstream *stream,
+ void *dev_ptr);
/* Checks how much time has passed since last stream fetch and records
* the longest fetch interval. */
@@ -265,15 +266,13 @@
int cras_rstream_audio_ready(struct cras_rstream *stream, size_t count);
/* Let the rstream know when a device is added or removed. */
-void cras_rstream_dev_attach(struct cras_rstream *rstream,
- unsigned int dev_id,
+void cras_rstream_dev_attach(struct cras_rstream *rstream, unsigned int dev_id,
void *dev_ptr);
void cras_rstream_dev_detach(struct cras_rstream *rstream, unsigned int dev_id);
/* A device using this stream has read or written samples. */
void cras_rstream_dev_offset_update(struct cras_rstream *rstream,
- unsigned int frames,
- unsigned int dev_id);
+ unsigned int frames, unsigned int dev_id);
void cras_rstream_update_input_write_pointer(struct cras_rstream *rstream);
void cras_rstream_update_output_read_pointer(struct cras_rstream *rstream);
@@ -308,8 +307,7 @@
/* Returns a pointer to readable frames, fills frames with the number of frames
* available. */
uint8_t *cras_rstream_get_readable_frames(struct cras_rstream *rstream,
- unsigned int offset,
- size_t *frames);
+ unsigned int offset, size_t *frames);
/* Returns non-zero if the stream is muted. */
int cras_rstream_get_mute(const struct cras_rstream *rstream);
diff --git a/cras/src/server/dev_stream.c b/cras/src/server/dev_stream.c
index 11e974a..47e2adb 100644
--- a/cras/src/server/dev_stream.c
+++ b/cras/src/server/dev_stream.c
@@ -36,7 +36,8 @@
*/
unsigned int max_frames_for_conversion(unsigned int stream_frames,
unsigned int stream_rate,
- unsigned int device_rate) {
+ unsigned int device_rate)
+{
/*
* There are multiple temp buffers in the format converter,
* which are all the same size. Some of these contain audio
@@ -45,26 +46,24 @@
* enough to hold either.
*/
return MAX(
- // Number of stream frames does not require conversion.
- stream_frames,
- // Calculate corresponding number of frames at device rate.
- cras_frames_at_rate(stream_rate,
- stream_frames,
- device_rate))
- /*
- * Add 1 because the linear resampler's frame rate
- * conversion does this, and is used to calculate
- * how many frames to read from the device.
- * See linear_resampler_{in,out}_frames_to_{out,in}(..)
- */
- + 1;
+ // Number of stream frames does not require conversion.
+ stream_frames,
+ // Calculate corresponding number of frames at device rate.
+ cras_frames_at_rate(stream_rate, stream_frames,
+ device_rate))
+ /*
+ * Add 1 because the linear resampler's frame rate
+ * conversion does this, and is used to calculate
+ * how many frames to read from the device.
+ * See linear_resampler_{in,out}_frames_to_{out,in}(..)
+ */
+ + 1;
}
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)
{
struct dev_stream *out;
struct cras_audio_format *stream_fmt = &stream->format;
@@ -83,24 +82,18 @@
dev_fmt->frame_rate);
if (stream->direction == CRAS_STREAM_OUTPUT) {
- rc = config_format_converter(&out->conv,
- stream->direction,
- stream_fmt,
- dev_fmt,
- max_frames);
+ rc = config_format_converter(&out->conv, stream->direction,
+ stream_fmt, dev_fmt, max_frames);
} else {
/*
* For input, take into account the stream specific processing
* like AEC. Use the post processing format to configure format
* converter.
*/
- ofmt = cras_rstream_post_processing_format(
- stream, dev_ptr) ? : dev_fmt,
- rc = config_format_converter(&out->conv,
- stream->direction,
- ofmt,
- stream_fmt,
- max_frames);
+ ofmt = cras_rstream_post_processing_format(stream, dev_ptr) ?:
+ dev_fmt,
+ rc = config_format_converter(&out->conv, stream->direction,
+ ofmt, stream_fmt, max_frames);
}
if (rc) {
free(out);
@@ -109,14 +102,15 @@
ofmt = cras_fmt_conv_out_format(out->conv);
- dev_frames = (stream->direction == CRAS_STREAM_OUTPUT)
- ? cras_fmt_conv_in_frames_to_out(out->conv,
- stream->buffer_frames)
- : cras_fmt_conv_out_frames_to_in(out->conv,
- stream->buffer_frames);
+ dev_frames =
+ (stream->direction == CRAS_STREAM_OUTPUT) ?
+ cras_fmt_conv_in_frames_to_out(out->conv,
+ stream->buffer_frames) :
+ cras_fmt_conv_out_frames_to_in(out->conv,
+ stream->buffer_frames);
- out->conv_buffer_size_frames = 2 * MAX(dev_frames,
- stream->buffer_frames);
+ out->conv_buffer_size_frames =
+ 2 * MAX(dev_frames, stream->buffer_frames);
/* Create conversion buffer and area using the output format
* of the format converter. Note that this format might not be
@@ -126,8 +120,7 @@
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);
+ stream_fmt->frame_rate, &stream->sleep_interval_ts);
stream->next_cb_ts = *cb_ts;
cras_rstream_dev_attach(stream, dev_id, dev_ptr);
@@ -147,35 +140,27 @@
}
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)
+ unsigned int dev_rate, double dev_rate_ratio,
+ double master_rate_ratio, int coarse_rate_adjust)
{
if (dev_stream->dev_id == dev_stream->stream->master_dev.dev_id) {
- cras_fmt_conv_set_linear_resample_rates(
- dev_stream->conv,
- dev_rate,
- dev_rate);
+ cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
+ dev_rate, dev_rate);
cras_frames_to_time_precise(
cras_rstream_get_cb_threshold(dev_stream->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;
- cras_fmt_conv_set_linear_resample_rates(
- dev_stream->conv,
- dev_rate,
- new_rate);
+ double new_rate =
+ dev_rate * dev_rate_ratio / master_rate_ratio +
+ coarse_rate_adjust_step * coarse_rate_adjust;
+ cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
+ dev_rate, new_rate);
}
-
}
int dev_stream_mix(struct dev_stream *dev_stream,
- const struct cras_audio_format *fmt,
- uint8_t *dst,
+ const struct cras_audio_format *fmt, uint8_t *dst,
unsigned int num_to_write)
{
struct cras_rstream *rstream = dev_stream->stream;
@@ -205,17 +190,15 @@
while (fr_written < num_to_write) {
unsigned int read_frames;
src = cras_rstream_get_readable_frames(
- rstream, buffer_offset + fr_read, &frames);
+ rstream, buffer_offset + fr_read, &frames);
if (frames == 0)
break;
if (cras_fmt_conversion_needed(dev_stream->conv)) {
read_frames = frames;
dev_frames = cras_fmt_conv_convert_frames(
- dev_stream->conv,
- src,
- dev_stream->conv_buffer->bytes,
- &read_frames,
- num_to_write - fr_written);
+ dev_stream->conv, src,
+ dev_stream->conv_buffer->bytes, &read_frames,
+ num_to_write - fr_written);
src = dev_stream->conv_buffer->bytes;
} else {
dev_frames = MIN(frames, num_to_write - fr_written);
@@ -230,8 +213,7 @@
}
cras_rstream_dev_offset_update(rstream, fr_read, dev_stream->dev_id);
- ATLOG(atlog, AUDIO_THREAD_DEV_STREAM_MIX,
- fr_written, fr_read, 0);
+ ATLOG(atlog, AUDIO_THREAD_DEV_STREAM_MIX, fr_written, fr_read, 0);
return fr_written;
}
@@ -266,11 +248,8 @@
read_frames = num_frames - total_read;
write_frames = cras_fmt_conv_convert_frames(
- dev_stream->conv,
- source_samples,
- buffer,
- &read_frames,
- write_frames);
+ dev_stream->conv, source_samples, buffer, &read_frames,
+ write_frames);
total_read += read_frames;
source_samples += read_frames * source_frame_bytes;
buf_increment_write(dev_stream->conv_buffer,
@@ -282,10 +261,10 @@
/* Copy from the converted buffer to the stream shm. These have the same format
* at this point. */
-static unsigned int capture_copy_converted_to_stream(
- struct dev_stream *dev_stream,
- struct cras_rstream *rstream,
- float software_gain_scaler)
+static unsigned int
+capture_copy_converted_to_stream(struct dev_stream *dev_stream,
+ struct cras_rstream *rstream,
+ float software_gain_scaler)
{
struct cras_audio_shm *shm;
uint8_t *stream_samples;
@@ -305,38 +284,30 @@
offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id);
stream_samples = cras_shm_get_writeable_frames(
- shm,
- cras_rstream_get_cb_threshold(rstream),
- &rstream->audio_area->frames);
+ shm, cras_rstream_get_cb_threshold(rstream),
+ &rstream->audio_area->frames);
num_frames = MIN(rstream->audio_area->frames - offset,
- buf_queued(dev_stream->conv_buffer) /
- frame_bytes);
+ buf_queued(dev_stream->conv_buffer) / frame_bytes);
- ATLOG(atlog, AUDIO_THREAD_CONV_COPY,
- shm->area->write_buf_idx,
- rstream->audio_area->frames,
- offset);
+ ATLOG(atlog, AUDIO_THREAD_CONV_COPY, shm->area->write_buf_idx,
+ rstream->audio_area->frames, offset);
while (total_written < num_frames) {
- converted_samples =
- buf_read_pointer_size(dev_stream->conv_buffer,
- &write_frames);
+ converted_samples = buf_read_pointer_size(
+ dev_stream->conv_buffer, &write_frames);
write_frames /= frame_bytes;
write_frames = MIN(write_frames, num_frames - total_written);
- cras_audio_area_config_buf_pointers(dev_stream->conv_area,
- fmt,
+ cras_audio_area_config_buf_pointers(dev_stream->conv_area, fmt,
converted_samples);
cras_audio_area_config_channels(dev_stream->conv_area, fmt);
dev_stream->conv_area->frames = write_frames;
- cras_audio_area_config_buf_pointers(rstream->audio_area,
- &rstream->format,
- stream_samples);
+ cras_audio_area_config_buf_pointers(
+ rstream->audio_area, &rstream->format, stream_samples);
cras_audio_area_copy(rstream->audio_area, offset,
- &rstream->format,
- dev_stream->conv_area, 0,
+ &rstream->format, dev_stream->conv_area, 0,
software_gain_scaler);
buf_increment_read(dev_stream->conv_buffer,
@@ -347,17 +318,15 @@
offset = cras_rstream_dev_offset(rstream, dev_stream->dev_id);
}
- ATLOG(atlog, AUDIO_THREAD_CAPTURE_WRITE,
- rstream->stream_id,
- total_written,
- cras_shm_frames_written(shm));
+ ATLOG(atlog, AUDIO_THREAD_CAPTURE_WRITE, rstream->stream_id,
+ total_written, cras_shm_frames_written(shm));
return total_written;
}
unsigned int dev_stream_capture(struct dev_stream *dev_stream,
- const struct cras_audio_area *area,
- unsigned int area_offset,
- float software_gain_scaler)
+ const struct cras_audio_area *area,
+ unsigned int area_offset,
+ float software_gain_scaler)
{
struct cras_rstream *rstream = dev_stream->stream;
struct cras_audio_shm *shm;
@@ -372,7 +341,7 @@
fr_to_capture = MIN(fr_to_capture, area->frames - area_offset);
format_bytes = cras_get_format_bytes(
- cras_fmt_conv_in_format(dev_stream->conv));
+ cras_fmt_conv_in_format(dev_stream->conv));
nread = capture_with_fmt_conv(
dev_stream,
area->channels[0].buf + area_offset * format_bytes,
@@ -387,22 +356,17 @@
/* Set up the shm area and copy to it. */
shm = cras_rstream_shm(rstream);
stream_samples = cras_shm_get_writeable_frames(
- shm,
- cras_rstream_get_cb_threshold(rstream),
- &rstream->audio_area->frames);
- cras_audio_area_config_buf_pointers(rstream->audio_area,
- &rstream->format,
- stream_samples);
+ shm, cras_rstream_get_cb_threshold(rstream),
+ &rstream->audio_area->frames);
+ cras_audio_area_config_buf_pointers(
+ rstream->audio_area, &rstream->format, stream_samples);
nread = cras_audio_area_copy(rstream->audio_area, offset,
&rstream->format, area,
- area_offset,
- software_gain_scaler);
+ area_offset, software_gain_scaler);
- ATLOG(atlog, AUDIO_THREAD_CAPTURE_WRITE,
- rstream->stream_id,
- nread,
- cras_shm_frames_written(shm));
+ ATLOG(atlog, AUDIO_THREAD_CAPTURE_WRITE, rstream->stream_id,
+ nread, cras_shm_frames_written(shm));
cras_rstream_dev_offset_update(rstream, nread,
dev_stream->dev_id);
}
@@ -469,20 +433,19 @@
return frames_avail;
format_bytes = cras_get_format_bytes(
- cras_fmt_conv_out_format(dev_stream->conv));
+ cras_fmt_conv_out_format(dev_stream->conv));
/* Sample rate conversion may cause some sample left in conv_buffer
* take this buffer into account. */
- conv_buf_level = buf_queued(dev_stream->conv_buffer) /
- format_bytes;
+ conv_buf_level = buf_queued(dev_stream->conv_buffer) / format_bytes;
if (frames_avail <= conv_buf_level)
return 0;
else
frames_avail -= conv_buf_level;
- frames_avail = MIN(frames_avail,
- buf_available(dev_stream->conv_buffer) /
- format_bytes);
+ frames_avail =
+ MIN(frames_avail,
+ buf_available(dev_stream->conv_buffer) / format_bytes);
return cras_fmt_conv_out_frames_to_in(dev_stream->conv, frames_avail);
}
@@ -515,7 +478,8 @@
if (rstream->direction == CRAS_STREAM_INPUT &&
!timespec_is_nonzero(&rstream->next_cb_ts)) {
clock_gettime(CLOCK_MONOTONIC_RAW, &rstream->next_cb_ts);
- add_timespecs(&rstream->next_cb_ts, &rstream->sleep_interval_ts);
+ add_timespecs(&rstream->next_cb_ts,
+ &rstream->sleep_interval_ts);
return;
}
/* Update next callback time according to perfect schedule. */
@@ -582,8 +546,7 @@
return 0;
}
-void cras_set_playback_timestamp(size_t frame_rate,
- size_t frames,
+void cras_set_playback_timestamp(size_t frame_rate, size_t frames,
struct cras_timespec *ts)
{
cras_clock_gettime(CLOCK_MONOTONIC_RAW, ts);
@@ -598,8 +561,7 @@
}
}
-void cras_set_capture_timestamp(size_t frame_rate,
- size_t frames,
+void cras_set_capture_timestamp(size_t frame_rate, size_t frames,
struct cras_timespec *ts)
{
long tmp;
@@ -636,17 +598,16 @@
delay_frames);
cras_set_playback_timestamp(rstream->format.frame_rate,
stream_frames +
- cras_shm_get_frames(shm),
+ cras_shm_get_frames(shm),
&shm->area->ts);
} else {
shm = cras_rstream_shm(rstream);
stream_frames = cras_fmt_conv_in_frames_to_out(dev_stream->conv,
delay_frames);
if (cras_shm_frames_written(shm) == 0)
- cras_set_capture_timestamp(
- rstream->format.frame_rate,
- stream_frames,
- &shm->area->ts);
+ cras_set_capture_timestamp(rstream->format.frame_rate,
+ stream_frames,
+ &shm->area->ts);
}
}
@@ -692,8 +653,7 @@
static int get_input_wake_time(struct dev_stream *dev_stream,
unsigned int curr_level,
struct timespec *level_tstamp,
- unsigned int cap_limit,
- int is_cap_limit_stream,
+ unsigned int cap_limit, int is_cap_limit_stream,
struct timespec *wake_time_out)
{
struct cras_rstream *rstream = dev_stream->stream;
@@ -742,7 +702,7 @@
*
*/
if ((rstream->flags & USE_DEV_TIMING) &&
- cras_rstream_is_pending_reply(rstream))
+ cras_rstream_is_pending_reply(rstream))
return 1;
*wake_time_out = rstream->next_cb_ts;
@@ -756,8 +716,7 @@
else
needed_frames_from_device -= curr_level;
- cras_frames_to_time(needed_frames_from_device,
- dev_stream->dev_rate,
+ cras_frames_to_time(needed_frames_from_device, dev_stream->dev_rate,
&time_for_sample);
add_timespecs(&time_for_sample, level_tstamp);
@@ -765,21 +724,20 @@
/* Select the time that is later so both sample and time conditions
* are met. */
if (timespec_after(&time_for_sample, &rstream->next_cb_ts))
- *wake_time_out = time_for_sample;
+ *wake_time_out = time_for_sample;
/* Using device timing means the stream neglects next callback time. */
if (rstream->flags & USE_DEV_TIMING)
- *wake_time_out = time_for_sample;
+ *wake_time_out = time_for_sample;
- ATLOG(atlog, AUDIO_THREAD_STREAM_SLEEP_TIME, dev_stream->stream->stream_id,
- wake_time_out->tv_sec, wake_time_out->tv_nsec);
+ ATLOG(atlog, AUDIO_THREAD_STREAM_SLEEP_TIME,
+ dev_stream->stream->stream_id, wake_time_out->tv_sec,
+ wake_time_out->tv_nsec);
return 0;
}
-int dev_stream_wake_time(struct dev_stream *dev_stream,
- unsigned int curr_level,
- struct timespec *level_tstamp,
- unsigned int cap_limit,
+int dev_stream_wake_time(struct dev_stream *dev_stream, unsigned int curr_level,
+ struct timespec *level_tstamp, unsigned int cap_limit,
int is_cap_limit_stream,
struct timespec *wake_time_out)
{
diff --git a/cras/src/server/dev_stream.h b/cras/src/server/dev_stream.h
index 776a1b3..c39a801 100644
--- a/cras/src/server/dev_stream.h
+++ b/cras/src/server/dev_stream.h
@@ -68,10 +68,8 @@
* sample rate should adjust to.
*/
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);
+ unsigned int dev_rate, double dev_rate_ratio,
+ double master_rate_ratio, int coarse_rate_adjust);
/*
* Renders count frames from shm into dst. Updates count if anything is
@@ -83,8 +81,7 @@
* num_to_write - The number of frames written.
*/
int dev_stream_mix(struct dev_stream *dev_stream,
- const struct cras_audio_format *fmt,
- uint8_t *dst,
+ const struct cras_audio_format *fmt, uint8_t *dst,
unsigned int num_to_write);
/*
@@ -96,9 +93,9 @@
* software_gain_scaler - The software gain scaler.
*/
unsigned int dev_stream_capture(struct dev_stream *dev_stream,
- const struct cras_audio_area *area,
- unsigned int area_offset,
- float software_gain_scaler);
+ const struct cras_audio_area *area,
+ unsigned int area_offset,
+ float software_gain_scaler);
/* Returns the number of iodevs this stream has attached to. */
int dev_stream_attached_devs(const struct dev_stream *dev_stream);
@@ -138,13 +135,11 @@
int dev_stream_playback_update_rstream(struct dev_stream *dev_stream);
/* Fill ts with the time the playback sample will be played. */
-void cras_set_playback_timestamp(size_t frame_rate,
- size_t frames,
+void cras_set_playback_timestamp(size_t frame_rate, size_t frames,
struct cras_timespec *ts);
/* Fill ts with the time the capture sample was recorded. */
-void cras_set_capture_timestamp(size_t frame_rate,
- size_t frames,
+void cras_set_capture_timestamp(size_t frame_rate, size_t frames,
struct cras_timespec *ts);
/* Fill shm ts with the time the playback sample will be played or the capture
@@ -176,10 +171,8 @@
* 0 on success; negative error code on failure.
* A positive value if there is no need to set wake up time for this stream.
*/
-int dev_stream_wake_time(struct dev_stream *dev_stream,
- unsigned int curr_level,
- struct timespec *level_tstamp,
- unsigned int cap_limit,
+int dev_stream_wake_time(struct dev_stream *dev_stream, unsigned int curr_level,
+ struct timespec *level_tstamp, unsigned int cap_limit,
int is_cap_limit_stream,
struct timespec *wake_time_out);
diff --git a/cras/src/server/server_stream.c b/cras/src/server/server_stream.c
index 242a34c..639f948 100644
--- a/cras/src/server/server_stream.c
+++ b/cras/src/server/server_stream.c
@@ -12,7 +12,6 @@
#include "server_stream.h"
#include "stream_list.h"
-
/* Parameters used for server stream. */
static unsigned int server_stream_block_size = 480;
@@ -22,8 +21,7 @@
* make pinned device open and let data flow through its dsp
* pipeline.
*/
-static struct cras_audio_format format =
-{
+static struct cras_audio_format format = {
SND_PCM_FORMAT_S16_LE,
48000,
2,
@@ -55,11 +53,11 @@
return;
}
- stream_config = (struct cras_rstream_config *)
- calloc(1, sizeof(*stream_config));
+ stream_config =
+ (struct cras_rstream_config *)calloc(1, sizeof(*stream_config));
stream_config->format = &format;
stream_config->stream_id =
- cras_get_stream_id(SERVER_STREAM_CLIENT_ID, 0);
+ cras_get_stream_id(SERVER_STREAM_CLIENT_ID, 0);
stream_config->stream_type = CRAS_STREAM_TYPE_DEFAULT;
stream_config->direction = CRAS_STREAM_INPUT;
stream_config->flags = SERVER_ONLY;
diff --git a/cras/src/server/stream_list.c b/cras/src/server/stream_list.c
index cdad9d1..d247ec8 100644
--- a/cras/src/server/stream_list.c
+++ b/cras/src/server/stream_list.c
@@ -26,7 +26,7 @@
struct stream_list *list = (struct stream_list *)data;
int max_drain_delay = 0;
- DL_FOREACH(list->streams_to_delete, to_delete) {
+ DL_FOREACH (list->streams_to_delete, to_delete) {
int drain_delay;
drain_delay = list->stream_removed_cb(to_delete);
@@ -40,8 +40,10 @@
list->drain_timer = NULL;
if (max_drain_delay)
- list->drain_timer = cras_tm_create_timer(list->timer_manager,
- MAX(max_drain_delay, 10), delete_streams, list);
+ list->drain_timer =
+ cras_tm_create_timer(list->timer_manager,
+ MAX(max_drain_delay, 10),
+ delete_streams, list);
}
/*
@@ -118,7 +120,7 @@
struct cras_rstream *to_remove;
int rc = 0;
- DL_FOREACH(list->streams, to_remove) {
+ DL_FOREACH (list->streams, to_remove) {
if (to_remove->client == rclient) {
DL_DELETE(list->streams, to_remove);
DL_APPEND(list->streams_to_delete, to_remove);
@@ -131,14 +133,13 @@
delete_streams(NULL, list);
return rc;
-
}
bool stream_list_has_pinned_stream(struct stream_list *list,
unsigned int dev_idx)
{
struct cras_rstream *rstream;
- DL_FOREACH(list->streams, rstream) {
+ DL_FOREACH (list->streams, rstream) {
if (!rstream->is_pinned)
continue;
if (rstream->pinned_dev_idx == dev_idx)
diff --git a/cras/src/server/stream_list.h b/cras/src/server/stream_list.h
index 25cefb8..858fbe3 100644
--- a/cras/src/server/stream_list.h
+++ b/cras/src/server/stream_list.h
@@ -14,10 +14,10 @@
struct cras_audio_format;
struct stream_list;
-typedef int (stream_callback)(struct cras_rstream *rstream);
-typedef int (stream_create_func)(struct cras_rstream_config *stream_config,
- struct cras_rstream **rstream);
-typedef void (stream_destroy_func)(struct cras_rstream *rstream);
+typedef int(stream_callback)(struct cras_rstream *rstream);
+typedef int(stream_create_func)(struct cras_rstream_config *stream_config,
+ struct cras_rstream **rstream);
+typedef void(stream_destroy_func)(struct cras_rstream *rstream);
struct stream_list *stream_list_create(stream_callback *add_cb,
stream_callback *rm_cb,