summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsamr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109>2008-11-25 23:02:33 +0000
committersamr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109>2008-11-25 23:02:33 +0000
commit05075c366990733e6c0aced5f8559cfd932e2bd4 (patch)
tree1428963ff6497d486304f622d17f82a1a4aec858 /test
parent4aa52837906f909d00095e61b9def7781b83640c (diff)
downloadnohands-05075c366990733e6c0aced5f8559cfd932e2bd4.tar.gz
Add the stream snoop filter.
Fix the audiofile endpoint to support output. Fix minor problems in SoundIoPump, and the ALSA and OSS endpoints, discovered while testing streaming from files. Remove all non-character usage of char, replace with (u)int8_t. Update documentation. git-svn-id: http://nohands.svn.sourceforge.net/svnroot/nohands/trunk@43 126591fb-c623-4b62-a76d-97a8e4f34109
Diffstat (limited to 'test')
-rw-r--r--test/pumpunit.cpp81
1 files changed, 57 insertions, 24 deletions
diff --git a/test/pumpunit.cpp b/test/pumpunit.cpp
index 976e11a..a260852 100644
--- a/test/pumpunit.cpp
+++ b/test/pumpunit.cpp
@@ -205,10 +205,15 @@ public:
fillme.m_data = m_sink_buf.GetSpace(nbytes);
}
- void CheckOBuf(const uint8_t *buf, size_t len) {
+ void CheckOBuf(const uint8_t *ibuf, size_t ilen) {
int subsamp, bpr, count = 0;
+ const uint8_t *buf;
+ size_t len;
bool last_mismatch = false;
+ int mismatch_count = 0;
+ buf = ibuf;
+ len = ilen;
bpr = m_fmt.bytes_per_record;
assert(!(len % bpr));
@@ -224,6 +229,7 @@ public:
}
m_sink_seq = buf[0];
last_mismatch = true;
+ mismatch_count++;
} else {
last_mismatch = false;
}
@@ -236,6 +242,7 @@ public:
"expect: 0x%02x got: 0x%02x\n",
m_name, subsamp, m_sink_seq,
buf[subsamp]);
+ mismatch_count++;
}
}
@@ -307,15 +314,56 @@ public:
};
+void
+run_test(SoundIoPump *pump, SoundIoTestEp *bot, SoundIoTestEp *top,
+ SoundIoTestEp *div)
+{
+ bool res;
+ int i;
+
+ res = bot->SndOpen(true, true);
+ assert(res);
+ res = top->SndOpen(true, true);
+ assert(res);
+ res = pump->Start();
+ assert(res);
+ assert(bot->SndIsAsyncStarted());
+
+ for (i = 0; i < 10000; i++) {
+ bot->FillOutput();
+ bot->ConsumeInput();
+ bot->DoAsync();
+
+ top->FillOutput();
+ top->ConsumeInput();
+ top->DoAsync();
+
+ if (div)
+ div->ConsumeInput();
+
+ assert(pump->IsStarted());
+ }
+
+ pump->Stop();
+ bot->SndClose();
+ top->SndClose();
+}
+
int
main(int argc, char **argv)
{
IndepEventDispatcher disp;
- SoundIoTestEp top("Top", 10000), bot("Bot", 10000);
+ SoundIoTestEp top("Top", 10000), bot("Bot", 10000), div("Div", 10000);
SoundIoPump pump(&disp, &bot);
+ SoundIoFilter *fltp, *snoopp;
SoundIoFormat xfmt;
bool res;
- int i;
+
+ fltp = SoundIoFltCreateDummy();
+ assert(fltp);
+
+ snoopp = SoundIoCreateSnooper(&div, true, false);
+ assert(snoopp);
xfmt.samplerate = 10000;
xfmt.sampletype = SIO_PCM_U8;
@@ -327,31 +375,16 @@ main(int argc, char **argv)
top.SndSetFormat(xfmt);
res = pump.SetTop(&top);
assert(res);
- res = bot.SndOpen(true, true);
- assert(res);
- res = top.SndOpen(true, true);
- assert(res);
- res = pump.Start();
- assert(res);
- assert(bot.SndIsAsyncStarted());
- for (i = 0; i < 10000; i++) {
+ res = pump.AddBottom(fltp);
+ assert(res);
- if (i == 309)
- printf("Hi\n");
+ run_test(&pump, &bot, &top, 0);
- bot.FillOutput();
- bot.ConsumeInput();
- bot.DoAsync();
-
- top.FillOutput();
- top.ConsumeInput();
- top.DoAsync();
-
- assert(pump.IsStarted());
- }
+ res = pump.AddBottom(snoopp);
+ assert(res);
- pump.Stop();
+ run_test(&pump, &bot, &top, &div);
return 0;
}