All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] cplay: Always write frag * fragment_size
@ 2018-11-05 14:23 Daniel Baluta
  2018-11-08 14:37 ` Daniel Baluta
  2018-11-13 14:52 ` Vinod Koul
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Baluta @ 2018-11-05 14:23 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org
  Cc: S.j. Wang, vinod.koul@linux.intel.com, Daniel Baluta,
	vkoul@kernel.org

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.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
I noticed this while investigating why cplay prints buffer_size as
0 when not specified as command line argument to cplay.

I also noticed that cred always reads frag * frament_size, so I think
this patch should be OK, but marking it as RFC to get your thoughts.

 src/utils/cplay.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/utils/cplay.c b/src/utils/cplay.c
index 2a52b52..b016f52 100644
--- a/src/utils/cplay.c
+++ b/src/utils/cplay.c
@@ -435,15 +435,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);
@@ -459,7 +459,7 @@ void play_samples(char *name, unsigned int card, unsigned int device,
 		}
 	}
 	printf("Playing file %s On Card %u device %u, with buffer of %lu bytes\n",
-			name, card, device, buffer_size);
+			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);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-14  6:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05 14:23 [RFC PATCH] cplay: Always write frag * fragment_size Daniel Baluta
2018-11-08 14:37 ` Daniel Baluta
2018-11-08 15:21   ` Charles Keepax
2018-11-13 14:52 ` Vinod Koul
2018-11-14  6:59   ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.