From 80e9e5f3e772ea3c7d3d3478a3c70c2c86745954 Mon Sep 17 00:00:00 2001 From: Barrett17 Date: Fri, 6 Apr 2018 02:31:28 +0200 Subject: [PATCH] Add new tests to MediaTest --- src/bin/media_client/MediaTest.cpp | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/bin/media_client/MediaTest.cpp b/src/bin/media_client/MediaTest.cpp index 120b92a284..d940ca80da 100644 --- a/src/bin/media_client/MediaTest.cpp +++ b/src/bin/media_client/MediaTest.cpp @@ -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"); }