]> git.alsa-project.org Git - tinycompress.git/commitdiff
cplay: Always write whole buffer requested by user
authorDaniel Baluta <daniel.baluta@nxp.com>
Mon, 5 Nov 2018 14:02:43 +0000 (16:02 +0200)
committerVinod Koul <vkoul@kernel.org>
Fri, 7 Dec 2018 05:22:36 +0000 (10:52 +0530)
cplay first writes frag * fragment_size and then
it only writes one fragment at a time.

This means for example than if the user supplied a buffer_size
it will only be used for the first write.

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
src/utils/cplay.c

index 9ffa1dd86f7f485a0281470fe824b2fa6137037a..3e9fcac4d424a4d79fdc24cda17774465943cf31 100644 (file)
@@ -347,15 +347,15 @@ void play_samples(char *name, unsigned int card, unsigned int device,
        };
        if (verbose)
                printf("%s: Opened compress device\n", __func__);
-       size = config.fragment_size;
-       buffer = malloc(size * config.fragments);
+       size = config.fragments * config.fragment_size;
+       buffer = malloc(size);
        if (!buffer) {
                fprintf(stderr, "Unable to allocate %d bytes\n", size);
                goto COMP_EXIT;
        }
 
        /* we will write frag fragment_size and then start */
-       num_read = fread(buffer, 1, size * config.fragments, file);
+       num_read = fread(buffer, 1, size, file);
        if (num_read > 0) {
                if (verbose)
                        printf("%s: Doing first buffer write of %d\n", __func__, num_read);
@@ -370,8 +370,8 @@ void play_samples(char *name, unsigned int card, unsigned int device,
                        fprintf(stderr, "We wrote %d, DSP accepted %d\n", num_read, wrote);
                }
        }
-       printf("Playing file %s On Card %u device %u, with buffer of %lu bytes\n",
-                       name, card, device, buffer_size);
+       printf("Playing file %s On Card %u device %u, with buffer of %d bytes\n",
+                       name, card, device, size);
        printf("Format %u Channels %u, %u Hz, Bit Rate %d\n",
                        codec.id, codec.ch_in, codec.sample_rate, codec.bit_rate);