audio: get_buffer_size and get_latency Interface optimization [2/2]
PD#TV-110799
Problem:
The interface output does not meet expectations
Solution:
1.Modify and optimize the interface
2.test cmd: halplay -f 1 -c 2 -r 48000 -d 1 xxx.wav
Verify:
t5w-at301
Change-Id: I1d7d0c67c85859d4c5d5de5303b1b797c4962609
Signed-off-by: haiyang.ren <haiyang.ren@amlogic.com>
diff --git a/src/halplay.c b/src/halplay.c
index e2b3c77..248d336 100644
--- a/src/halplay.c
+++ b/src/halplay.c
@@ -101,6 +101,18 @@
close(fd);
}
+int debug = 0;
+static void get_buffer_size(struct audio_stream_out *stream)
+{
+ int buffer_size = 0;
+ int buffer_latency = 0;
+ if (debug) {
+ buffer_size = stream->common.get_buffer_size(&(stream->common));
+ buffer_latency = stream->get_latency(stream);
+ printf("buffer_size: %d, buffer_latency: %d.", buffer_size, buffer_latency);
+ }
+}
+
int isstop = 0;
static int test_stream(struct audio_stream_out *stream, unsigned char *buf, int size)
{
@@ -133,6 +145,8 @@
printf("stream writing %d \n", s);
len -= s;
data += s;
+
+ get_buffer_size(stream);
}
isstop = 0;
return 0;
@@ -177,12 +191,12 @@
int fd = -1;
if (argc == 1) {
- printf("Usage: halplay -f <format> -c <channel number> -r <sample rate> <filename>\n");
+ printf("Usage: halplay -f <format> -c <channel number> -r <sample rate> -d <debug flag> <filename> \n");
printf("more param Info: halplay -h\n");
return 0;
}
- while ((c = getopt(argc, argv, "f:c:r:h")) != -1) {
+ while ((c = getopt(argc, argv, "f:c:r:d:h")) != -1) {
switch (c) {
case 'f':
format = atoi(optarg);
@@ -193,6 +207,9 @@
case 'r':
sr = atoi(optarg);
break;
+ case 'd':
+ debug = atoi(optarg);
+ break;
case 'h':
help = 1;
break;
@@ -204,7 +221,7 @@
}
}
if (help == 1) {
- printf("Usage: halplay -f <format> -c <channel number> -r <sample rate> <filename>\n");
+ printf("Usage: halplay -f <format> -c <channel number> -r <sample rate> -d <debug flag> <filename>\n");
printf("\n-h, help\n");
printf("-f, sample format\n");
printf("-c, channels\n");
@@ -214,6 +231,7 @@
printf("the available params for PCM16 and PCM32 are:\n");
printf("-c 1,2,6,8\n");
printf("-r 32000,44100,48000\n");
+ printf("-d debug flag: 1/0\n");
return 0;
}
if (optind < argc) {