summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-04-18 11:01:03 +0100
committerTakashi Iwai <tiwai@suse.de>2013-04-21 09:52:43 +0200
commit5b1f79f70b0fa0b7ddb28c9ac54c57598fed6347 (patch)
tree01d22a5085feeeb3427232308f0659ff15d0f1a7 /sound
parent4c28e32d6c4da1d2bc92d3062690e770c18493e6 (diff)
downloadlinux-5b1f79f70b0fa0b7ddb28c9ac54c57598fed6347.tar.gz
linux-5b1f79f70b0fa0b7ddb28c9ac54c57598fed6347.tar.bz2
linux-5b1f79f70b0fa0b7ddb28c9ac54c57598fed6347.zip
ALSA: compress_core: Calculate avail correctly for capture streams
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/compress_offload.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 27bd81ad2841..1f69863a83d2 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -153,7 +153,10 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
pr_debug("dsp consumed till %d total %d bytes\n",
tstamp->byte_offset, tstamp->copied_total);
stream->runtime->hw_pointer = tstamp->byte_offset;
- stream->runtime->total_bytes_transferred = tstamp->copied_total;
+ if (stream->direction == SND_COMPRESS_PLAYBACK)
+ stream->runtime->total_bytes_transferred = tstamp->copied_total;
+ else
+ stream->runtime->total_bytes_available = tstamp->copied_total;
return 0;
}
@@ -164,12 +167,9 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
snd_compr_update_tstamp(stream, &avail->tstamp);
/* Still need to return avail even if tstamp can't be filled in */
- /* FIXME: This needs to be different for capture stream,
- available is # of compressed data, for playback it's
- remainder of buffer */
-
if (stream->runtime->total_bytes_available == 0 &&
- stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+ stream->runtime->state == SNDRV_PCM_STATE_SETUP &&
+ stream->direction == SND_COMPRESS_PLAYBACK) {
pr_debug("detected init and someone forgot to do a write\n");
return stream->runtime->buffer_size;
}
@@ -178,13 +178,20 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
stream->runtime->total_bytes_transferred);
if (stream->runtime->total_bytes_available ==
stream->runtime->total_bytes_transferred) {
- pr_debug("both pointers are same, returning full avail\n");
- return stream->runtime->buffer_size;
+ if (stream->direction == SND_COMPRESS_PLAYBACK) {
+ pr_debug("both pointers are same, returning full avail\n");
+ return stream->runtime->buffer_size;
+ } else {
+ pr_debug("both pointers are same, returning no avail\n");
+ return 0;
+ }
}
- avail->avail = stream->runtime->buffer_size -
- (stream->runtime->total_bytes_available -
- stream->runtime->total_bytes_transferred);
+ avail->avail = stream->runtime->total_bytes_available -
+ stream->runtime->total_bytes_transferred;
+ if (stream->direction == SND_COMPRESS_PLAYBACK)
+ avail->avail = stream->runtime->buffer_size - avail->avail;
+
pr_debug("ret avail as %lld\n", avail->avail);
return avail->avail;
}