qahw: test: Add bitwidth user option
Enable user option to specify bitwidth of clip
and some bug fixes.
Change-Id: I4ffdaa9f89324af7327b3376c401aedb71ba720d
diff --git a/qahw_api/test/qahw_multi_record_test.c b/qahw_api/test/qahw_multi_record_test.c
index eab100d..81924a3 100644
--- a/qahw_api/test/qahw_multi_record_test.c
+++ b/qahw_api/test/qahw_multi_record_test.c
@@ -339,6 +339,7 @@
while(true) {
if(time_elapsed < params->record_delay) {
usleep(1000000*(params->record_delay - time_elapsed));
+ time_elapsed = difftime(time(0), start_time);
continue;
} else if (time_elapsed > params->record_delay + params->record_length) {
fprintf(log_file, "\n Test for session with handle(%d) completed.\n", params->handle);
diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c
index a739970..0a7f2dd 100644
--- a/qahw_api/test/qahw_playback_test.c
+++ b/qahw_api/test/qahw_playback_test.c
@@ -524,6 +524,7 @@
printf(" -r --sample-rate <sampling rate> - Required for Non-WAV streams\n");
printf(" For AAC-HE pls specify half the sample rate\n\n");
printf(" -c --channel count <channels> - Required for Non-WAV streams\n\n");
+ printf(" -b --bitwidth <bitwidth> - Give either 16 or 24.Default value is 16.\n\n");
printf(" -v --volume <float volume level> - Volume level float value between 0.0 - 1.0.\n");
printf(" -d --device <decimal value> - see system/media/audio/include/system/audio.h for device values\n");
printf(" Optional Argument and Default value is 2, i.e Speaker\n\n");
@@ -604,6 +605,7 @@
int filetype = FILE_WAV;
int sample_rate = 44100;
int channels = 2;
+ int bitwidth = 16;
aac_format_type_t format_type = AAC_LC;
log_file = stdout;
audio_devices_t output_device = AUDIO_DEVICE_OUT_SPEAKER;
@@ -616,6 +618,7 @@
{"device", required_argument, 0, 'd'},
{"sample-rate", required_argument, 0, 'r'},
{"channels", required_argument, 0, 'c'},
+ {"bitwidth", required_argument, 0, 'b'},
{"volume", required_argument, 0, 'v'},
{"log-file", required_argument, 0, 'l'},
{"dump-file", required_argument, 0, 'D'},
@@ -645,7 +648,7 @@
proxy_params.hdr.data_sz = 0;
while ((opt = getopt_long(argc,
argv,
- "-f:r:c:d:v:l:t:a:k:D:KF:h",
+ "-f:r:c:b:d:v:l:t:a:k:D:KF:h",
long_options,
&option_index)) != -1) {
switch (opt) {
@@ -655,9 +658,12 @@
case 'r':
sample_rate = atoi(optarg);
break;
- case 'c':;
+ case 'c':
channels = atoi(optarg);
break;
+ case 'b':
+ bitwidth = atoi(optarg);
+ break;
case 'd':
output_device = atoll(optarg);
break;
@@ -717,6 +723,7 @@
fprintf(stdout, "Sample Rate:%d\n", sample_rate);
fprintf(stdout, "Channels:%d\n", channels);
+ fprintf(stdout, "Bitwidth:%d\n", bitwidth);
fprintf(stdout, "Log file:%s\n", log_filename);
fprintf(stdout, "Volume level:%f\n", vol_level);
fprintf(stdout, "Output Device:%d\n", output_device);
@@ -771,7 +778,13 @@
}
memcpy (&channels, &header[22], 2);
memcpy (&sample_rate, &header[24], 4);
- config.offload_info.format = AUDIO_FORMAT_PCM_16_BIT;
+ memcpy (&bitwidth, &header[34], 2);
+ if (bitwidth == 32)
+ config.offload_info.format = AUDIO_FORMAT_PCM_32_BIT;
+ else if (bitwidth == 24)
+ config.offload_info.format = AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ else
+ config.offload_info.format = AUDIO_FORMAT_PCM_16_BIT;
if (!flags_set)
flags = AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD;
break;
@@ -824,6 +837,7 @@
config.format = config.offload_info.format;
config.offload_info.channel_mask = config.channel_mask;
config.offload_info.sample_rate = sample_rate;
+ config.offload_info.bit_width = bitwidth;
config.offload_info.version = AUDIO_OFFLOAD_INFO_VERSION_CURRENT;
config.offload_info.size = sizeof(audio_offload_info_t);