AudioJack: Basic implementation of capture (without AUDIO_PORT_SUPPORT)

This commit is contained in:
Shmuel H
2017-11-06 22:41:13 +02:00
parent 5a08e9ed9f
commit 44fa0c5e53
2 changed files with 44 additions and 2 deletions

View File

@@ -38,6 +38,8 @@
#include <QtCore/QList>
#include <QtCore/QMap>
#include <memory>
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
@@ -110,7 +112,10 @@ private:
MidiJack *m_midiClient;
QVector<jack_port_t *> m_outputPorts;
QVector<jack_port_t *> m_inputPorts;
jack_default_audio_sample_t * * m_tempOutBufs;
jack_default_audio_sample_t * * m_tempInBufs;
std::unique_ptr<sampleFrame[]> m_inBuffer;
surroundSampleFrame * m_outBuf;
f_cnt_t m_framesDoneInCurBuf;

View File

@@ -47,7 +47,8 @@ AudioJack::AudioJack( bool & _success_ful, Mixer* _mixer ) :
AudioDevice( tLimit<int>( ConfigManager::inst()->value(
"audiojack", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
_mixer,
true /* supportsCapture */),
m_client( NULL ),
m_active( false ),
m_midiClient( NULL ),
@@ -187,11 +188,28 @@ bool AudioJack::initJackClient()
JackPortIsOutput, 0 ) );
if( m_outputPorts.back() == NULL )
{
printf( "no more JACK-ports available!\n" );
printf( "no more out JACK-ports available!\n" );
return false;
}
}
// Register In ports
for( ch_cnt_t ch = 0; ch < channels(); ++ch )
{
QString name = QString( "master in " ) +
( ( ch % 2 ) ? "R" : "L" ) +
QString::number( ch / 2 + 1 );
m_inputPorts.push_back( jack_port_register( m_client,
name.toLatin1().constData(),
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsInput, 0 ) );
if( m_inputPorts.back() == NULL )
{
printf( "no more in JACK-ports available!\n" );
return false;
}
}
return true;
}
@@ -351,6 +369,10 @@ int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata )
m_tempOutBufs[c] =
(jack_default_audio_sample_t *) jack_port_get_buffer(
m_outputPorts[c], _nframes );
m_tempInBufs[c] =
(jack_default_audio_sample_t *) jack_port_get_buffer(
m_inputPorts[c], _nframes );
}
#ifdef AUDIO_PORT_SUPPORT
@@ -405,6 +427,21 @@ int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata )
}
}
m_inBuffer.reset (new sampleFrame[_nframes]);
const float gain = mixer()->masterGain();
for( int c = 0; c < channels(); ++c ) {
jack_default_audio_sample_t *channel_buffer = m_tempInBufs[c];
for( jack_nframes_t frame = 0; frame < _nframes; ++frame )
{
m_inBuffer[frame][c] = channel_buffer[frame] /*/ gain*/;
}
}
mixer()->pushInputFrames (m_inBuffer.get (), _nframes);
if( m_stopped == true )
{
for( int c = 0; c < channels(); ++c )