* [tinycompress][PATCH 1/2] compress: copy final version of config struct
2013-06-05 12:08 [tinycompress][PATCH 0/2] Fixes for write loop logic Richard Fitzgerald
@ 2013-06-05 12:10 ` Richard Fitzgerald
2013-06-05 12:11 ` [tinycompress][PATCH 2/2] compress: do not poll if enough space to write remaining data Richard Fitzgerald
2013-06-07 0:30 ` [tinycompress][PATCH 0/2] Fixes for write loop logic Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2013-06-05 12:10 UTC (permalink / raw)
To: vinod.koul; +Cc: alsa-devel, ckeepax, pierre-louis.bossart
compress_open() should delay taking a copy of the
config struct until we've finished modifying it.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
compress.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/compress.c b/compress.c
index 7f56c78..373de85 100644
--- a/compress.c
+++ b/compress.c
@@ -235,7 +235,6 @@ struct compress *compress_open(unsigned int card, unsigned int device,
compress->config = calloc(1, sizeof(*config));
if (!compress->config)
goto input_fail;
- memcpy(compress->config, config, sizeof(*compress->config));
snprintf(fn, sizeof(fn), "/dev/snd/comprC%uD%u", card, device);
@@ -277,6 +276,8 @@ struct compress *compress_open(unsigned int card, unsigned int device,
goto codec_fail;
}
#endif
+
+ memcpy(compress->config, config, sizeof(*compress->config));
fill_compress_params(config, ¶ms);
if (ioctl(compress->fd, SNDRV_COMPRESS_SET_PARAMS, ¶ms)) {
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* [tinycompress][PATCH 2/2] compress: do not poll if enough space to write remaining data
2013-06-05 12:08 [tinycompress][PATCH 0/2] Fixes for write loop logic Richard Fitzgerald
2013-06-05 12:10 ` [tinycompress][PATCH 1/2] compress: copy final version of config struct Richard Fitzgerald
@ 2013-06-05 12:11 ` Richard Fitzgerald
2013-06-07 0:30 ` [tinycompress][PATCH 0/2] Fixes for write loop logic Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2013-06-05 12:11 UTC (permalink / raw)
To: vinod.koul; +Cc: alsa-devel, ckeepax, pierre-louis.bossart
Changes the poll logic in compress_write() to prevent
it polling if there is enough available space to write
all remaining data. Previously the logic always polled for
an entire fragment to become available before starting the
first write.
This change allows short writes of < frag_size, which is likely
at the end of a stream.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
compress.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/compress.c b/compress.c
index 373de85..bb68fa6 100644
--- a/compress.c
+++ b/compress.c
@@ -368,12 +368,10 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &avail))
return oops(compress, errno, "cannot get avail");
- if ( (avail.avail < frag_size)
- || ((to_write != 0) && (avail.avail < size)) ) {
- /* not enough space for one fragment, or we have done
- * a short write and there isn't enough space for all
- * the remaining data
- */
+ /* We can write if we have at least one fragment available
+ * or there is enough space for all remaining data
+ */
+ if ((avail.avail < frag_size) && (avail.avail < size)) {
ret = poll(&fds, 1, compress->max_poll_wait_ms);
/* A pause will cause -EBADFD or zero.
* This is not an error, just stop writing */
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [tinycompress][PATCH 0/2] Fixes for write loop logic
2013-06-05 12:08 [tinycompress][PATCH 0/2] Fixes for write loop logic Richard Fitzgerald
2013-06-05 12:10 ` [tinycompress][PATCH 1/2] compress: copy final version of config struct Richard Fitzgerald
2013-06-05 12:11 ` [tinycompress][PATCH 2/2] compress: do not poll if enough space to write remaining data Richard Fitzgerald
@ 2013-06-07 0:30 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2013-06-07 0:30 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: alsa-devel, pierre-louis.bossart, ckeepax
On Wed, Jun 05, 2013 at 01:08:27PM +0100, Richard Fitzgerald wrote:
> Two small patches which correct the logic of compress_write()
> so that it will work correctly if asked to write a buffer
> shorter than the fragment length. The first patch is needed
> to ensure that if the client requests auto-configuration
> of fragment size the internal copy of the config contains the
> configured fragment size. The second patch contains the actual
> fix to the write loop logic.
>
> Richard Fitzgerald (2):
> compress: copy final version of config struct
> compress: do not poll if enough space to write remaining data
Applied thanks
--
~Vinod
>
> compress.c | 13 ++++++-------
> 1 files changed, 6 insertions(+), 7 deletions(-)
>
> --
> 1.7.2.5
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
--
^ permalink raw reply [flat|nested] 4+ messages in thread