summaryrefslogtreecommitdiffstats
path: root/modules/usbaudio
diff options
context:
space:
mode:
authorPavan Chikkala <pavanc@codeaurora.org>2015-01-09 12:21:13 -0800
committerEric Laurent <elaurent@google.com>2015-01-09 14:14:41 -0800
commit83b47a6891a5bf3d546f0f7a8976132e45169075 (patch)
treef77950a41f508f9f07b0027d6fef162fc7688f7f /modules/usbaudio
parent781bb3f72e2706f07ee8bcc0c140201faf07c35c (diff)
downloadhardware_libhardware-83b47a6891a5bf3d546f0f7a8976132e45169075.zip
hardware_libhardware-83b47a6891a5bf3d546f0f7a8976132e45169075.tar.gz
hardware_libhardware-83b47a6891a5bf3d546f0f7a8976132e45169075.tar.bz2
usb audio: Fix incorrect bytes returned for recording
In a recording session , the number of bytes read is not updated when pcm_read() fails. This results in silence/invalid data being added during a device switch from USB headset to handset. Fix is to reset the number of bytes read if pcm_read() returns an error indicating removal of USB headset. Bug: 18611518 Change-Id: I10d578c3cf1037c90a891e63be2bd1c2b7e6126b
Diffstat (limited to 'modules/usbaudio')
-rw-r--r--modules/usbaudio/audio_hw.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/usbaudio/audio_hw.c b/modules/usbaudio/audio_hw.c
index 0ee44c5..49c99af 100644
--- a/modules/usbaudio/audio_hw.c
+++ b/modules/usbaudio/audio_hw.c
@@ -775,6 +775,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte
size_t num_read_buff_bytes = 0;
void * read_buff = buffer;
void * out_buff = buffer;
+ int ret = 0;
struct stream_in * in = (struct stream_in *)stream;
@@ -824,7 +825,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte
read_buff = in->conversion_buffer;
}
- if (proxy_read(&in->proxy, read_buff, num_read_buff_bytes) == 0) {
+ ret = proxy_read(&in->proxy, read_buff, num_read_buff_bytes);
+ if (ret == 0) {
/*
* Do any conversions necessary to send the data in the format specified to/by the HAL
* (but different from the ALSA format), such as 24bit ->16bit, or 4chan -> 2chan.
@@ -865,6 +867,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 if (ret == -ENODEV) {
+ num_read_buff_bytes = 0; //reset the value after USB headset is unplugged
}
err: