Add new tests to MediaTest

This commit is contained in:
Barrett17 2018-04-06 02:31:28 +02:00
parent 5ba361f8bf
commit 80e9e5f3e7

View File

@ -19,11 +19,15 @@
#define SNOOZE_FOR 10000000
#endif
#define MAX_MULTI_CLIENTS 3
static BSimpleMediaClient* sProducer = NULL;
static BSimpleMediaClient* sConsumer = NULL;
static BSimpleMediaClient* sFilter = NULL;
static BSimpleMediaClient* sProducers[MAX_MULTI_CLIENTS];
static BSimpleMediaClient* sConsumers[MAX_MULTI_CLIENTS];
void
_InitClients(bool hasFilter)
@ -38,6 +42,25 @@ _InitClients(bool hasFilter)
}
void
_InitClientsMulti(bool isMixer)
{
if (!isMixer) {
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
sConsumers[i] = new BSimpleMediaClient("Test Consumer");
}
sProducer = new BSimpleMediaClient("MediaClientProducer");
} else {
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
sProducers[i] = new BSimpleMediaClient("Test Producer");
}
sConsumer = new BSimpleMediaClient("MediaClientConsumer");
}
sFilter = new BSimpleMediaClient("MediaClientFilter");
}
void
_DeleteClients()
{
@ -47,6 +70,24 @@ _DeleteClients()
}
void
_DeleteClientsMulti(bool isMixer)
{
if (!isMixer) {
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
delete sConsumers[i];
}
delete sProducer;
} else {
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
delete sProducers[i];
}
delete sConsumer;
}
delete sFilter;
}
media_format
_BuildRawAudioFormat()
{
@ -126,6 +167,48 @@ _ProducerFilterConsumerTest()
}
void
_SplitterConfigurationTest()
{
_InitClientsMulti(false);
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
BMediaOutput* output = sFilter->BeginOutput();
assert(sFilter->Connect(output, sConsumers[i]->BeginInput()) == B_OK);
}
assert(sProducer->Connect(sProducer->BeginOutput(),
sFilter->BeginInput()) == B_OK);
#ifdef DELAYED_MODE
snooze(SNOOZE_FOR);
#endif
_DeleteClientsMulti(false);
}
void
_MixerConfigurationTest()
{
_InitClientsMulti(true);
for (int i = 0; i < MAX_MULTI_CLIENTS; i++) {
BMediaInput* input = sFilter->BeginInput();
assert(sFilter->Connect(input, sConsumers[i]->BeginInput()) == B_OK);
}
assert(sConsumer->Connect(sConsumer->BeginInput(),
sFilter->BeginOutput()) == B_OK);
#ifdef DELAYED_MODE
snooze(SNOOZE_FOR);
#endif
_DeleteClientsMulti(true);
}
void
media_test()
{
@ -137,4 +220,12 @@ media_test()
printf("Testing Simple (1:1:1) Producer-Filter-Consumer configuration: ");
_ProducerFilterConsumerTest();
printf("OK\n");
printf("Testing Splitter Configuration (N:1:1): ");
_SplitterConfigurationTest();
printf("OK\n");
printf("Testing Mixer Configuration (N:1:1): ");
_SplitterConfigurationTest();
printf("OK\n");
}