From 8c7e1114a3a07c3cb071df461d42e75b7ef3feae Mon Sep 17 00:00:00 2001 From: Viswanath L Date: Fri, 31 Oct 2014 13:07:39 +0530 Subject: usbaudio: Return 0 bytes on failure in capture Return 0 bytes from in_read() in failure conditions so that invalid data is not recorded. Change-Id: I9a6294e4162fa642fd7e160a32d1ad16f255ff62 --- modules/usbaudio/audio_hw.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/usbaudio') diff --git a/modules/usbaudio/audio_hw.c b/modules/usbaudio/audio_hw.c index 35f7705..78fa7c5 100644 --- a/modules/usbaudio/audio_hw.c +++ b/modules/usbaudio/audio_hw.c @@ -852,6 +852,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte num_read_buff_bytes = convert_32_to_16(read_buff, num_read_buff_bytes / 4, out_buff); } else { + LOG_ALWAYS_FATAL("Unsupported format"); + num_read_buff_bytes = 0; goto err; } } @@ -875,6 +877,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte /* no need to acquire in->dev->lock to read mic_muted here as we don't change its state */ if (num_read_buff_bytes > 0 && in->dev->mic_muted) memset(buffer, 0, num_read_buff_bytes); + } else { + num_read_buff_bytes = 0; } err: -- cgit v1.1