Skip to content

Commit

Permalink
cras: add ops helper for flush_buffer
Browse files Browse the repository at this point in the history
The age old forgot to check nullity bug. Add a helper so people don't
have to think about it.

BUG=oss-fuzz:68995
TEST=None

Change-Id: I9f016a1c77b7d036e766a391e108f375b6323235
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5767195
Tested-by: [email protected] <[email protected]>
Tested-by: Curtis Malainey <[email protected]>
Auto-Submit: Curtis Malainey <[email protected]>
Reviewed-by: Li-Yu Yu <[email protected]>
Commit-Queue: Li-Yu Yu <[email protected]>
  • Loading branch information
cujomalainey authored and Chromeos LUCI committed Aug 8, 2024
1 parent 7e8f18e commit 33bf62f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cras/src/server/cras_iodev.h
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,20 @@ void cras_iodev_set_dsp_offload_disallow_by_aec_ref(struct cras_iodev* iodev,
int cras_iodev_fill_odev_zeros(struct cras_iodev* odev,
unsigned int frames,
bool processing);
/*
* Flush buffer for alignment purposes
* Args:
* dev - The device.
* Returns:
* Number of frames flushed, negative errno if failed.
*/
static inline int cras_iodev_flush_buffer(struct cras_iodev* dev) {
if (dev->flush_buffer) {
return dev->flush_buffer(dev);
}
return 0;
}

/*
* The default implementation of frames_to_play_in_sleep ops, used when an
* iodev doesn't have its own logic.
Expand Down
2 changes: 1 addition & 1 deletion cras/src/server/dev_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ int dev_io_append_stream(struct open_dev** odevs,
* buffer level.
*/
if ((stream->direction == CRAS_STREAM_INPUT) && !dev->streams) {
int num_flushed = dev->flush_buffer(dev);
int num_flushed = cras_iodev_flush_buffer(dev);
if (num_flushed < 0) {
rc = -EIO;
break;
Expand Down

0 comments on commit 33bf62f

Please sign in to comment.