some changes to the sound interface, changed names of macros for network buffer sizes

This commit is contained in:
Volker Fischer 2006-10-30 20:35:46 +00:00
parent 25e275edce
commit ab24ff7d00
10 changed files with 93 additions and 41 deletions

View file

@ -127,6 +127,24 @@ bool CSound::Read(CVector<short>& psData)
ret = snd_pcm_readi(rhandle, &psData[0], iBufferSizeIn);
//snd_pcm_sframes_t test = snd_pcm_avail_update ( rhandle );
//qDebug ( "test: %d", test );
//if ( test == 64 )
// snd_pcm_prepare ( rhandle );
/*
snd_pcm_status( rhandle, status );
snd_pcm_sframes_t test = snd_pcm_status_get_delay(status);
//qDebug ( "test: %d", test );
*/
//static FILE* pFile = fopen("test.dat", "w");
//fprintf(pFile, "%d\n", test);
//fflush(pFile);
if ( ret < 0 )
{
if ( ret == -EPIPE )
@ -312,6 +330,35 @@ bool CSound::Write ( CVector<short>& psData )
{
ret = snd_pcm_writei ( phandle, &psData[start], size );
//snd_pcm_sframes_t test = snd_pcm_avail_update ( phandle );
//qDebug ( "test: %d", test );
//if ( test == 64 )
// snd_pcm_prepare ( rhandle );
/*
snd_pcm_sframes_t delayp;
snd_pcm_delay ( phandle, &delayp ) ;
qDebug ( "test: %d", delayp );
*/
//snd_pcm_status_t* status;
//snd_pcm_status_alloca(&status);
//snd_pcm_status( phandle, status );
//snd_pcm_sframes_t test = snd_pcm_status_get_delay(status);
//qDebug ( "test: %d", test );
//snd_pcm_status( phandle, status );
//snd_pcm_sframes_t test = snd_pcm_status_get_delay(status);
//qDebug ( "test: %d", test );
//static FILE* pFile = fopen("test.dat", "w");
//fprintf(pFile, "%d\n", test);
//fflush(pFile);
if ( ret < 0 )
{
if ( ret == -EPIPE )

View file

@ -50,7 +50,7 @@ public:
iCurPeriodSizeOut(NUM_PERIOD_BLOCKS_OUT), bChangParamIn(true),
bChangParamOut(true)
#endif
{}
{snd_pcm_status_alloca(&status);}
virtual ~CSound() {Close();}
/* Not implemented yet, always return one device and default string */
@ -88,6 +88,12 @@ protected:
int iCurPeriodSizeIn;
bool bChangParamOut;
int iCurPeriodSizeOut;
// TEST
snd_pcm_status_t* status;
#else
/* Dummy definitions */
void SetInNumBuf(int iNewNum) {}

View file

@ -230,7 +230,7 @@ CChannel::CChannel()
{
// query all possible network in buffer sizes for determining if an
// audio packet was received
for ( int i = 0; i < NET_BLOCK_SIZE_FACTOR_MAX; i++ )
for ( int i = 0; i < MAX_NET_BLOCK_SIZE_FACTOR; i++ )
{
// network block size factor must start from 1 -> ( i + 1 )
vecNetwInBufSizes[i] = AudioCompressionIn.Init (
@ -241,14 +241,14 @@ CChannel::CChannel()
/* init time stamp index counter */
byTimeStampIdxCnt = 0;
iCurNetwInBlSiFact = NET_BLOCK_SIZE_FACTOR;
iCurNetwInBlSiFact = DEF_NET_BLOCK_SIZE_FACTOR;
/* init the socket buffer */
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
// set initial input and output block size factors
SetNetwBufSizeFactOut ( NET_BLOCK_SIZE_FACTOR );
SetNetwInBlSiFact ( NET_BLOCK_SIZE_FACTOR );
SetNetwBufSizeFactOut ( iCurNetwInBlSiFact );
SetNetwInBlSiFact ( iCurNetwInBlSiFact );
/* init time-out for the buffer with zero -> no connection */
iConTimeOut = 0;
@ -373,7 +373,7 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
bool bIsAudioPacket = false;
// check if this is an audio packet by checking all possible lengths
for ( int i = 0; i < NET_BLOCK_SIZE_FACTOR_MAX; i++ )
for ( int i = 0; i < MAX_NET_BLOCK_SIZE_FACTOR; i++ )
{
if ( iNumBytes == vecNetwInBufSizes[i] )
{

View file

@ -142,7 +142,7 @@ protected:
int iConTimeOut;
int iConTimeOutStartVal;
int vecNetwInBufSizes[NET_BLOCK_SIZE_FACTOR_MAX];
int vecNetwInBufSizes[MAX_NET_BLOCK_SIZE_FACTOR];
int iCurNetwInBlSiFact;
int iCurNetwOutBlSiFact;

View file

@ -30,7 +30,7 @@ CClient::CClient () : bRun ( false ), Socket ( &Channel ),
iAudioInFader ( AUD_FADER_IN_MAX / 2 ),
iReverbLevel ( AUD_REVERB_MAX / 6 ),
bReverbOnLeftChan ( false ),
iNetwBufSizeFactIn ( NET_BLOCK_SIZE_FACTOR )
iNetwBufSizeFactIn ( DEF_NET_BLOCK_SIZE_FACTOR )
{
// connection for protocol
QObject::connect ( &Channel, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),

View file

@ -63,12 +63,11 @@
#define MIN_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SAMPLE_RATE / 1000 )
#define MIN_SND_CRD_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000 )
/* first tests showed that with 24000 kHz a block time shorter than 5 ms leads to
much higher DSL network latencies. A length of 6 ms seems to be optimal */
#define NET_BLOCK_SIZE_FACTOR 3 // 3 * 2 ms = 6 ms
// maximum value of factor for network block size
#define NET_BLOCK_SIZE_FACTOR_MAX 8
#define MAX_NET_BLOCK_SIZE_FACTOR 8
/* default network block size factor */
#define DEF_NET_BLOCK_SIZE_FACTOR 3
/* maximum network buffer size (which can be chosen by slider) */
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */

View file

@ -99,7 +99,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));
/* network buffer size factor in */
SliderNetBufSiFactIn->setRange(1, NET_BLOCK_SIZE_FACTOR_MAX);
SliderNetBufSiFactIn->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
SliderNetBufSiFactIn->setValue(iCurNetBufSiFactIn);
TextNetBufSiFactIn->setText("In:\n" + QString().setNum(
@ -107,7 +107,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
" ms");
/* network buffer size factor out */
SliderNetBufSiFactOut->setRange(1, NET_BLOCK_SIZE_FACTOR_MAX);
SliderNetBufSiFactOut->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
SliderNetBufSiFactOut->setValue(iCurNetBufSiFactOut);
TextNetBufSiFactOut->setText("Out:\n" + QString().setNum(

View file

@ -83,12 +83,12 @@ void CSettings::ReadIniFile()
}
// network buffer size factor in
if ( GetNumericIniSet(ini, "Client", "netwbusifactin", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
if ( GetNumericIniSet(ini, "Client", "netwbusifactin", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFactIn ( iValue );
}
// network buffer size factor out
if ( GetNumericIniSet(ini, "Client", "netwbusifactout", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
if ( GetNumericIniSet(ini, "Client", "netwbusifactout", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFactOut ( iValue );
}
}

View file

@ -38,7 +38,7 @@
/* Definitions ****************************************************************/
/* maximum block size for network input buffer. Consider two bytes per sample */
#define MAX_SIZE_BYTES_NETW_BUF ( NET_BLOCK_SIZE_FACTOR_MAX * MIN_BLOCK_SIZE_SAMPLES * 2 )
#define MAX_SIZE_BYTES_NETW_BUF ( MAX_NET_BLOCK_SIZE_FACTOR * MIN_BLOCK_SIZE_SAMPLES * 2 )
/* Classes ********************************************************************/