aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/compress_offload.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-04-18 06:01:03 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-21 03:52:43 -0400
commit5b1f79f70b0fa0b7ddb28c9ac54c57598fed6347 (patch)
tree01d22a5085feeeb3427232308f0659ff15d0f1a7 /sound/core/compress_offload.c
parent4c28e32d6c4da1d2bc92d3062690e770c18493e6 (diff)
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/core/compress_offload.c')
-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,
153 pr_debug("dsp consumed till %d total %d bytes\n", 153 pr_debug("dsp consumed till %d total %d bytes\n",
154 tstamp->byte_offset, tstamp->copied_total); 154 tstamp->byte_offset, tstamp->copied_total);
155 stream->runtime->hw_pointer = tstamp->byte_offset; 155 stream->runtime->hw_pointer = tstamp->byte_offset;
156 stream->runtime->total_bytes_transferred = tstamp->copied_total; 156 if (stream->direction == SND_COMPRESS_PLAYBACK)
157 stream->runtime->total_bytes_transferred = tstamp->copied_total;
158 else
159 stream->runtime->total_bytes_available = tstamp->copied_total;
157 return 0; 160 return 0;
158} 161}
159 162
@@ -164,12 +167,9 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
164 snd_compr_update_tstamp(stream, &avail->tstamp); 167 snd_compr_update_tstamp(stream, &avail->tstamp);
165 /* Still need to return avail even if tstamp can't be filled in */ 168 /* Still need to return avail even if tstamp can't be filled in */
166 169
167 /* FIXME: This needs to be different for capture stream,
168 available is # of compressed data, for playback it's
169 remainder of buffer */
170
171 if (stream->runtime->total_bytes_available == 0 && 170 if (stream->runtime->total_bytes_available == 0 &&
172 stream->runtime->state == SNDRV_PCM_STATE_SETUP) { 171 stream->runtime->state == SNDRV_PCM_STATE_SETUP &&
172 stream->direction == SND_COMPRESS_PLAYBACK) {
173 pr_debug("detected init and someone forgot to do a write\n"); 173 pr_debug("detected init and someone forgot to do a write\n");
174 return stream->runtime->buffer_size; 174 return stream->runtime->buffer_size;
175 } 175 }
@@ -178,13 +178,20 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
178 stream->runtime->total_bytes_transferred); 178 stream->runtime->total_bytes_transferred);
179 if (stream->runtime->total_bytes_available == 179 if (stream->runtime->total_bytes_available ==
180 stream->runtime->total_bytes_transferred) { 180 stream->runtime->total_bytes_transferred) {
181 pr_debug("both pointers are same, returning full avail\n"); 181 if (stream->direction == SND_COMPRESS_PLAYBACK) {
182 return stream->runtime->buffer_size; 182 pr_debug("both pointers are same, returning full avail\n");
183 return stream->runtime->buffer_size;
184 } else {
185 pr_debug("both pointers are same, returning no avail\n");
186 return 0;
187 }
183 } 188 }
184 189
185 avail->avail = stream->runtime->buffer_size - 190 avail->avail = stream->runtime->total_bytes_available -
186 (stream->runtime->total_bytes_available - 191 stream->runtime->total_bytes_transferred;
187 stream->runtime->total_bytes_transferred); 192 if (stream->direction == SND_COMPRESS_PLAYBACK)
193 avail->avail = stream->runtime->buffer_size - avail->avail;
194
188 pr_debug("ret avail as %lld\n", avail->avail); 195 pr_debug("ret avail as %lld\n", avail->avail);
189 return avail->avail; 196 return avail->avail;
190} 197}