tstAudioMixBuffer.cpp revision a3b592bbebcadf0cc7c1b9e295f4f8a032128ef0
/* $Id$ */
/** @file
* Audio testcase - Mixing buffer.
*/
/*
* Copyright (C) 2014-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
#include "../AudioMixBuffer.h"
#include "../DrvAudio.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
{
{
44100, /* Hz */
2 /* Channels */,
AUD_FMT_S16 /* Format */,
PDMAUDIOENDIANNESS_LITTLE /* ENDIANNESS */
};
/*
* General stuff.
*/
/*
* Absolute writes.
*/
written_abs = 0;
/* Beyond buffer. */
/*
* Circular writes.
*/
uint32_t cToWrite = audioMixBufSize(&mb) - written_abs - 1; /* -1 as padding plus -2 samples for above. */
{
}
/* Circular reads. */
{
}
}
{
{
44100, /* Hz */
2 /* Channels */,
AUD_FMT_S16 /* Format */,
PDMAUDIOENDIANNESS_LITTLE /* ENDIANNESS */
};
{
22100, /* Hz */
2 /* Channels */,
AUD_FMT_S16 /* Format */,
PDMAUDIOENDIANNESS_LITTLE /* ENDIANNESS */
};
{
48000, /* Hz */
2 /* Channels */,
AUD_FMT_S16 /* Format */,
PDMAUDIOENDIANNESS_LITTLE /* ENDIANNESS */
};
/*
*/
uint32_t cChild1Mixed = 0;
uint32_t cChild2Mixed = 0;
for (uint32_t i = 0; i < t; i++)
{
RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild1, ("Child1: Expected %RU32 written samples, got %RU32\n", cSamplesChild1, written));
RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child1) == temp, ("Child1: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child1), temp));
RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild2, ("Child2: Expected %RU32 written samples, got %RU32\n", cSamplesChild2, written));
RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child2) == temp, ("Child2: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child2), temp));
}
RTTESTI_CHECK(audioMixBufProcessed(&parent) == audioMixBufMixed(&child1) + audioMixBufMixed(&child2));
for (;;)
{
if (!read)
break;
}
}
{
/*
* Initialize IPRT and create the test.
*/
if (rc)
return rc;
if (RT_SUCCESS(rc))
/*
* Summary
*/
return RTTestSummaryAndDestroy(hTest);
}