diff options
author | Vidyakumar Athota <vathota@codeaurora.org> | 2020-04-15 21:25:49 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2021-01-19 12:08:55 +0100 |
commit | 8a03c49eec159347c4f480bec5791b709bce4982 (patch) | |
tree | 1746ca9f5d2ed40ebf9f439274fbac7b7e5861ad | |
parent | 1d53207fda30b5b8783c89df09dbf1c1042c4625 (diff) | |
download | tinyalsa-8a03c49eec159347c4f480bec5791b709bce4982.tar.gz |
tinyalsa : update event_cnt before eventfd_write()
Update event_cnt before eventfd_write() to avoid count mismatch dueto
context switch.
Bug: 166482201
Test: audio smoke tests
Change-Id: I7b5b5941d49da129e1705231e89c4b7ec94ddf4f
Merged-In: I7b5b5941d49da129e1705231e89c4b7ec94ddf4f
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
-rw-r--r-- | mixer_plugin.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mixer_plugin.c b/mixer_plugin.c index 90f332f..015120a 100644 --- a/mixer_plugin.c +++ b/mixer_plugin.c @@ -132,8 +132,8 @@ static int mixer_plug_info_integer(struct snd_control *ctl, void mixer_plug_notifier_cb(struct mixer_plugin *plugin) { - eventfd_write(plugin->eventfd, 1); plugin->event_cnt++; + eventfd_write(plugin->eventfd, 1); } /* In consume_event/read, do not call eventfd_read until all events are read from list. @@ -149,8 +149,10 @@ static ssize_t mixer_plug_read_event(void *data, struct snd_ctl_event *ev, size_ if (result > 0) { plugin->event_cnt -= result / sizeof(struct snd_ctl_event); - if (plugin->event_cnt == 0) + if (plugin->event_cnt <= 0) { + plugin->event_cnt = 0; eventfd_read(plugin->eventfd, &evfd); + } } return result; |