first working version of sound card channel selection
This commit is contained in:
parent
1345eac823
commit
bd6508c58f
7 changed files with 220 additions and 17 deletions
|
@ -54,8 +54,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void OpenCoreAudio();
|
void OpenCoreAudio();
|
||||||
void CloseCoreAudio();
|
void CloseCoreAudio();
|
||||||
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, const bool bIsInput,
|
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, const bool bIsInput,
|
||||||
UInt32 iPrefBufferSize );
|
UInt32 iPrefBufferSize );
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
static OSStatus processInput ( void* inRefCon,AudioUnitRenderActionFlags* ioActionFlags,
|
static OSStatus processInput ( void* inRefCon,AudioUnitRenderActionFlags* ioActionFlags,
|
||||||
|
|
|
@ -255,6 +255,86 @@ QString CClient::SetSndCrdDev ( const int iNewDev )
|
||||||
return strReturn;
|
return strReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClient::SetSndCrdLeftInputChannel ( const int iNewChan )
|
||||||
|
{
|
||||||
|
// if client was running then first
|
||||||
|
// stop it and restart again after new initialization
|
||||||
|
const bool bWasRunning = Sound.IsRunning();
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
Sound.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound.SetLeftInputChannel ( iNewChan );
|
||||||
|
Init();
|
||||||
|
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
// restart client
|
||||||
|
Sound.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient::SetSndCrdRightInputChannel ( const int iNewChan )
|
||||||
|
{
|
||||||
|
// if client was running then first
|
||||||
|
// stop it and restart again after new initialization
|
||||||
|
const bool bWasRunning = Sound.IsRunning();
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
Sound.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound.SetRightInputChannel ( iNewChan );
|
||||||
|
Init();
|
||||||
|
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
// restart client
|
||||||
|
Sound.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient::SetSndCrdLeftOutputChannel ( const int iNewChan )
|
||||||
|
{
|
||||||
|
// if client was running then first
|
||||||
|
// stop it and restart again after new initialization
|
||||||
|
const bool bWasRunning = Sound.IsRunning();
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
Sound.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound.SetLeftOutputChannel ( iNewChan );
|
||||||
|
Init();
|
||||||
|
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
// restart client
|
||||||
|
Sound.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient::SetSndCrdRightOutputChannel ( const int iNewChan )
|
||||||
|
{
|
||||||
|
// if client was running then first
|
||||||
|
// stop it and restart again after new initialization
|
||||||
|
const bool bWasRunning = Sound.IsRunning();
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
Sound.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound.SetRightOutputChannel ( iNewChan );
|
||||||
|
Init();
|
||||||
|
|
||||||
|
if ( bWasRunning )
|
||||||
|
{
|
||||||
|
// restart client
|
||||||
|
Sound.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CClient::OnSndCrdReinitRequest()
|
void CClient::OnSndCrdReinitRequest()
|
||||||
{
|
{
|
||||||
// if client was running then first
|
// if client was running then first
|
||||||
|
|
16
src/client.h
16
src/client.h
|
@ -132,6 +132,7 @@ public:
|
||||||
|
|
||||||
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
||||||
|
|
||||||
|
// sound card device selection
|
||||||
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
||||||
QString GetSndCrdDeviceName ( const int iDiD )
|
QString GetSndCrdDeviceName ( const int iDiD )
|
||||||
{ return Sound.GetDeviceName ( iDiD ); }
|
{ return Sound.GetDeviceName ( iDiD ); }
|
||||||
|
@ -140,6 +141,21 @@ public:
|
||||||
int GetSndCrdDev() { return Sound.GetDev(); }
|
int GetSndCrdDev() { return Sound.GetDev(); }
|
||||||
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
||||||
|
|
||||||
|
// sound card channel selection
|
||||||
|
int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); }
|
||||||
|
QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); }
|
||||||
|
void SetSndCrdLeftInputChannel ( const int iNewChan );
|
||||||
|
void SetSndCrdRightInputChannel ( const int iNewChan );
|
||||||
|
int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); }
|
||||||
|
int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); }
|
||||||
|
|
||||||
|
int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); }
|
||||||
|
QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); }
|
||||||
|
void SetSndCrdLeftOutputChannel ( const int iNewChan );
|
||||||
|
void SetSndCrdRightOutputChannel ( const int iNewChan );
|
||||||
|
int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); }
|
||||||
|
int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); }
|
||||||
|
|
||||||
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
|
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
|
||||||
int GetSndCrdPrefFrameSizeFactor()
|
int GetSndCrdPrefFrameSizeFactor()
|
||||||
{ return iSndCrdPrefFrameSizeFactor; }
|
{ return iSndCrdPrefFrameSizeFactor; }
|
||||||
|
|
|
@ -224,6 +224,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
}
|
}
|
||||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||||
|
|
||||||
|
// init sound card channel selection frame
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
|
|
||||||
// "OpenChatOnNewMessage" check box
|
// "OpenChatOnNewMessage" check box
|
||||||
if ( pClient->GetOpenChatOnNewMessage() )
|
if ( pClient->GetOpenChatOnNewMessage() )
|
||||||
{
|
{
|
||||||
|
@ -309,6 +312,18 @@ cbGUIDesignFancy->setVisible ( false );
|
||||||
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
|
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
|
||||||
this, SLOT ( OnSoundCrdSelection ( int ) ) );
|
this, SLOT ( OnSoundCrdSelection ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( cbLInChan, SIGNAL ( activated ( int ) ),
|
||||||
|
this, SLOT ( OnSndCrdLeftInChannelSelection ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( cbRInChan, SIGNAL ( activated ( int ) ),
|
||||||
|
this, SLOT ( OnSndCrdRightInChannelSelection ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( cbLOutChan, SIGNAL ( activated ( int ) ),
|
||||||
|
this, SLOT ( OnSndCrdLeftOutChannelSelection ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( cbROutChan, SIGNAL ( activated ( int ) ),
|
||||||
|
this, SLOT ( OnSndCrdRightOutChannelSelection ( int ) ) );
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
QObject::connect ( ButtonDriverSetup, SIGNAL ( clicked() ),
|
QObject::connect ( ButtonDriverSetup, SIGNAL ( clicked() ),
|
||||||
this, SLOT ( OnDriverSetupBut() ) );
|
this, SLOT ( OnDriverSetupBut() ) );
|
||||||
|
@ -386,6 +401,54 @@ void CClientSettingsDlg::UpdateSoundCardFrame()
|
||||||
pClient->GetFraSiFactSafeSupported() );
|
pClient->GetFraSiFactSafeSupported() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
int iSndChanIdx;
|
||||||
|
|
||||||
|
// Definition: The channel selection frame shall only be visible,
|
||||||
|
// if more than two input or output channels are available
|
||||||
|
const int iNumInChannels = pClient->GetSndCrdNumInputChannels();
|
||||||
|
const int iNumOutChannels = pClient->GetSndCrdNumOutputChannels();
|
||||||
|
|
||||||
|
if ( ( iNumInChannels <= 2 ) && ( iNumOutChannels <= 2 ) )
|
||||||
|
{
|
||||||
|
// as defined, make settings invisible
|
||||||
|
FrameSoundcardChannelSelection->setVisible ( false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// update combo boxes
|
||||||
|
FrameSoundcardChannelSelection->setVisible ( true );
|
||||||
|
|
||||||
|
// input
|
||||||
|
cbLInChan->clear();
|
||||||
|
cbRInChan->clear();
|
||||||
|
for ( iSndChanIdx = 0; iSndChanIdx < pClient->GetSndCrdNumInputChannels(); iSndChanIdx++ )
|
||||||
|
{
|
||||||
|
cbLInChan->addItem ( pClient->GetSndCrdInputChannelName ( iSndChanIdx ) );
|
||||||
|
cbRInChan->addItem ( pClient->GetSndCrdInputChannelName ( iSndChanIdx ) );
|
||||||
|
}
|
||||||
|
cbLInChan->setCurrentIndex ( pClient->GetSndCrdLeftInputChannel() );
|
||||||
|
cbRInChan->setCurrentIndex ( pClient->GetSndCrdRightInputChannel() );
|
||||||
|
|
||||||
|
// output
|
||||||
|
cbLOutChan->clear();
|
||||||
|
cbROutChan->clear();
|
||||||
|
for ( iSndChanIdx = 0; iSndChanIdx < pClient->GetSndCrdNumOutputChannels(); iSndChanIdx++ )
|
||||||
|
{
|
||||||
|
cbLOutChan->addItem ( pClient->GetSndCrdOutputChannelName ( iSndChanIdx ) );
|
||||||
|
cbROutChan->addItem ( pClient->GetSndCrdOutputChannelName ( iSndChanIdx ) );
|
||||||
|
}
|
||||||
|
cbLOutChan->setCurrentIndex ( pClient->GetSndCrdLeftOutputChannel() );
|
||||||
|
cbROutChan->setCurrentIndex ( pClient->GetSndCrdRightOutputChannel() );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// for other OS, no sound card channel selection is supported
|
||||||
|
FrameSoundcardChannelSelection->setVisible ( false );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::showEvent ( QShowEvent* )
|
void CClientSettingsDlg::showEvent ( QShowEvent* )
|
||||||
{
|
{
|
||||||
// only activate ping timer if window is actually shown
|
// only activate ping timer if window is actually shown
|
||||||
|
@ -432,9 +495,34 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
||||||
// recover old selection
|
// recover old selection
|
||||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||||
}
|
}
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::OnSndCrdLeftInChannelSelection ( int iChanIdx )
|
||||||
|
{
|
||||||
|
pClient->SetSndCrdLeftInputChannel ( iChanIdx );
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::OnSndCrdRightInChannelSelection ( int iChanIdx )
|
||||||
|
{
|
||||||
|
pClient->SetSndCrdRightInputChannel ( iChanIdx );
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::OnSndCrdLeftOutChannelSelection ( int iChanIdx )
|
||||||
|
{
|
||||||
|
pClient->SetSndCrdLeftOutputChannel ( iChanIdx );
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientSettingsDlg::OnSndCrdRightOutChannelSelection ( int iChanIdx )
|
||||||
|
{
|
||||||
|
pClient->SetSndCrdRightOutputChannel ( iChanIdx );
|
||||||
|
UpdateSoundChannelSelectionFrame();
|
||||||
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnAutoJitBuf ( int value )
|
void CClientSettingsDlg::OnAutoJitBuf ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
|
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void UpdateJitterBufferFrame();
|
void UpdateJitterBufferFrame();
|
||||||
void UpdateSoundCardFrame();
|
void UpdateSoundCardFrame();
|
||||||
|
void UpdateSoundChannelSelectionFrame();
|
||||||
QString GenSndCrdBufferDelayString ( const int iFrameSize,
|
QString GenSndCrdBufferDelayString ( const int iFrameSize,
|
||||||
const QString strAddText = "" );
|
const QString strAddText = "" );
|
||||||
|
|
||||||
|
@ -92,6 +93,10 @@ protected:
|
||||||
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
||||||
void OnPingTimeResult ( int iPingTime );
|
void OnPingTimeResult ( int iPingTime );
|
||||||
void OnSoundCrdSelection ( int iSndDevIdx );
|
void OnSoundCrdSelection ( int iSndDevIdx );
|
||||||
|
void OnSndCrdLeftInChannelSelection ( int iChanIdx );
|
||||||
|
void OnSndCrdRightInChannelSelection ( int iChanIdx );
|
||||||
|
void OnSndCrdLeftOutChannelSelection ( int iChanIdx );
|
||||||
|
void OnSndCrdRightOutChannelSelection ( int iChanIdx );
|
||||||
void OnDriverSetupBut();
|
void OnDriverSetupBut();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -47,15 +47,29 @@ public:
|
||||||
virtual void Start();
|
virtual void Start();
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
|
|
||||||
// dummy implementation in base class
|
// dummy implementations in base class
|
||||||
virtual int GetNumDev() { return 1; }
|
virtual int GetNumDev() { return 1; }
|
||||||
virtual QString GetDeviceName ( const int ) { return "Default"; }
|
virtual QString GetDeviceName ( const int ) { return "Default"; }
|
||||||
virtual QString SetDev ( const int ) { return ""; }
|
virtual QString SetDev ( const int ) { return ""; }
|
||||||
virtual int GetDev() { return 0; }
|
virtual int GetDev() { return 0; }
|
||||||
|
|
||||||
bool IsRunning() const { return bRun; }
|
virtual int GetNumInputChannels() { return 2; }
|
||||||
|
virtual QString GetInputChannelName ( const int ) { return "Default"; }
|
||||||
|
virtual void SetLeftInputChannel ( const int ) {}
|
||||||
|
virtual void SetRightInputChannel ( const int ) {}
|
||||||
|
virtual int GetLeftInputChannel() { return 0; }
|
||||||
|
virtual int GetRightInputChannel() { return 1; }
|
||||||
|
|
||||||
virtual void OpenDriverSetup() {}
|
virtual int GetNumOutputChannels() { return 2; }
|
||||||
|
virtual QString GetOutputChannelName ( const int ) { return "Default"; }
|
||||||
|
virtual void SetLeftOutputChannel ( const int ) {}
|
||||||
|
virtual void SetRightOutputChannel ( const int ) {}
|
||||||
|
virtual int GetLeftOutputChannel() { return 0; }
|
||||||
|
virtual int GetRightOutputChannel() { return 1; }
|
||||||
|
|
||||||
|
virtual void OpenDriverSetup() {}
|
||||||
|
|
||||||
|
bool IsRunning() const { return bRun; }
|
||||||
|
|
||||||
// TODO this should be protected but since it is used
|
// TODO this should be protected but since it is used
|
||||||
// in a callback function it has to be public -> better solution
|
// in a callback function it has to be public -> better solution
|
||||||
|
|
|
@ -70,19 +70,19 @@ public:
|
||||||
virtual int GetDev() { return lCurDev; }
|
virtual int GetDev() { return lCurDev; }
|
||||||
|
|
||||||
// channel selection
|
// channel selection
|
||||||
int GetNumInputChannels() { return static_cast<int> ( lNumInChan ); }
|
virtual int GetNumInputChannels() { return static_cast<int> ( lNumInChan ); }
|
||||||
QString GetInputChannelName ( const int iDiD ) { return channelInfosInput[iDiD].name; }
|
virtual QString GetInputChannelName ( const int iDiD ) { return channelInfosInput[iDiD].name; }
|
||||||
void SetLeftInputChannel ( const int iNewChan );
|
virtual void SetLeftInputChannel ( const int iNewChan );
|
||||||
void SetRightInputChannel ( const int iNewChan );
|
virtual void SetRightInputChannel ( const int iNewChan );
|
||||||
int GetLeftInputChannel() { return vSelectedInputChannels[0]; }
|
virtual int GetLeftInputChannel() { return vSelectedInputChannels[0]; }
|
||||||
int GetRightInputChannel() { return vSelectedInputChannels[1]; }
|
virtual int GetRightInputChannel() { return vSelectedInputChannels[1]; }
|
||||||
|
|
||||||
int GetNumOutputChannels() { return static_cast<int> ( lNumOutChan ); }
|
virtual int GetNumOutputChannels() { return static_cast<int> ( lNumOutChan ); }
|
||||||
QString GetOutputChannelName ( const int iDiD ) { return channelInfosOutput[iDiD].name; }
|
virtual QString GetOutputChannelName ( const int iDiD ) { return channelInfosOutput[iDiD].name; }
|
||||||
void SetLeftOutputChannel ( const int iNewChan );
|
virtual void SetLeftOutputChannel ( const int iNewChan );
|
||||||
void SetRightOutputChannel ( const int iNewChan );
|
virtual void SetRightOutputChannel ( const int iNewChan );
|
||||||
int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; }
|
virtual int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; }
|
||||||
int GetRightOutputChannel() { return vSelectedOutputChannels[1]; }
|
virtual int GetRightOutputChannel() { return vSelectedOutputChannels[1]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVector<QString> LoadAndInitializeFirstValidDriver();
|
QVector<QString> LoadAndInitializeFirstValidDriver();
|
||||||
|
|
Loading…
Reference in a new issue