summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/test-resample.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-02-17 14:57:27 -0800
committerGlenn Kasten <gkasten@google.com>2014-02-19 16:11:10 -0800
commit56df9ff31d583ad3eae4f279a3df550273c58e1e (patch)
treee2af7c78f0e5e30532791b1d197d8ed234f3a238 /services/audioflinger/test-resample.cpp
parentd20db4c4d8eb2593b5d0214890420a49e0b01796 (diff)
downloadframeworks_av-56df9ff31d583ad3eae4f279a3df550273c58e1e.zip
frameworks_av-56df9ff31d583ad3eae4f279a3df550273c58e1e.tar.gz
frameworks_av-56df9ff31d583ad3eae4f279a3df550273c58e1e.tar.bz2
Allow specifying frames per call to resample()
Bug: 13073201 Change-Id: Id2f0fcd7562d9ba5a58c128d71bbba42dfea86cc
Diffstat (limited to 'services/audioflinger/test-resample.cpp')
-rw-r--r--services/audioflinger/test-resample.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp
index 66fcd90..74d5702 100644
--- a/services/audioflinger/test-resample.cpp
+++ b/services/audioflinger/test-resample.cpp
@@ -34,7 +34,7 @@ bool gVerbose = false;
static int usage(const char* name) {
fprintf(stderr,"Usage: %s [-p] [-h] [-v] [-s] [-q {dq|lq|mq|hq|vhq|dlq|dmq|dhq}]"
- " [-i input-sample-rate] [-o output-sample-rate] [<input-file>]"
+ " [-i input-sample-rate] [-o output-sample-rate] [-O #] [<input-file>]"
" <output-file>\n", name);
fprintf(stderr," -p enable profiling\n");
fprintf(stderr," -h create wav file\n");
@@ -51,6 +51,7 @@ static int usage(const char* name) {
fprintf(stderr," dhq : dynamic high quality\n");
fprintf(stderr," -i input file sample rate (ignored if input file is specified)\n");
fprintf(stderr," -o output file sample rate\n");
+ fprintf(stderr," -O # frames output per call to resample()\n");
return -1;
}
@@ -64,9 +65,10 @@ int main(int argc, char* argv[]) {
int input_freq = 0;
int output_freq = 0;
AudioResampler::src_quality quality = AudioResampler::DEFAULT_QUALITY;
+ size_t framesPerCall = 0;
int ch;
- while ((ch = getopt(argc, argv, "pfhvsq:i:o:")) != -1) {
+ while ((ch = getopt(argc, argv, "pfhvsq:i:o:O:")) != -1) {
switch (ch) {
case 'p':
profileResample = true;
@@ -111,6 +113,9 @@ int main(int argc, char* argv[]) {
case 'o':
output_freq = atoi(optarg);
break;
+ case 'O':
+ framesPerCall = atoi(optarg);
+ break;
case '?':
default:
usage(progname);
@@ -343,7 +348,14 @@ int main(int argc, char* argv[]) {
if (gVerbose) {
printf("resample() %u output frames\n", out_frames);
}
- resampler->resample((int*) output_vaddr, out_frames, &provider);
+ if (framesPerCall == 0 || framesPerCall > out_frames) {
+ framesPerCall = out_frames;
+ }
+ for (size_t i = 0; i < out_frames; ) {
+ size_t thisFrames = framesPerCall <= out_frames - i ? framesPerCall : out_frames - i;
+ resampler->resample((int*) output_vaddr + 2*i, thisFrames, &provider);
+ i += thisFrames;
+ }
if (gVerbose) {
printf("resample() complete\n");
}