AudioPortAudio: adapt to AudiBackend/AudioOutputContext API
Things have changed a bit for audio backend implementations in the master branch. Therefore adapt AudioPortAudio to the new API.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* AudioPortAudio.h - device-class that performs PCM-output via PortAudio
|
||||
*
|
||||
* Copyright (c) 2008 Csaba Hruska <csaba.hruska/at/gmail.com>
|
||||
* Copyright (c) 2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -26,6 +27,7 @@
|
||||
#define _AUDIO_PORTAUDIO_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSemaphore>
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
#include "ComboBoxModel.h"
|
||||
@@ -63,7 +65,7 @@ class lcdSpinBox;
|
||||
class AudioPortAudio : public AudioBackend
|
||||
{
|
||||
public:
|
||||
AudioPortAudio( bool & _success_ful, mixer * _mixer );
|
||||
AudioPortAudio( bool & _success_ful, AudioOutputContext *context );
|
||||
virtual ~AudioPortAudio();
|
||||
|
||||
inline static QString name()
|
||||
|
||||
@@ -48,23 +48,24 @@ void AudioPortAudioSetupUtil::updateChannels()
|
||||
#include "templates.h"
|
||||
#include "combobox.h"
|
||||
#include "lcd_spinbox.h"
|
||||
#include "Cpu.h"
|
||||
|
||||
|
||||
AudioPortAudio::AudioPortAudio( bool & _success_ful, mixer * _mixer ) :
|
||||
AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioOutputContext *context ) :
|
||||
AudioBackend( tLimit<ch_cnt_t>(
|
||||
configManager::inst()->value( "audioportaudio",
|
||||
"channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
context ),
|
||||
m_paStream( NULL ),
|
||||
m_wasPAInitError( false ),
|
||||
m_outBuf( CPU::allocFrames( getMixer()->framesPerPeriod() ) ),
|
||||
m_outBuf( CPU::allocFrames( mixer()->framesPerPeriod() ) ),
|
||||
m_outBufPos( 0 ),
|
||||
m_stopSemaphore( 1 )
|
||||
{
|
||||
_success_ful = false;
|
||||
|
||||
m_outBufSize = getMixer()->framesPerPeriod();
|
||||
m_outBufSize = mixer()->framesPerPeriod();
|
||||
|
||||
PaError err = Pa_Initialize();
|
||||
|
||||
@@ -111,12 +112,12 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, mixer * _mixer ) :
|
||||
return;
|
||||
}
|
||||
|
||||
double inLatency = 0;//(double)getMixer()->framesPerPeriod() / (double)sampleRate();
|
||||
double outLatency = 0;//(double)getMixer()->framesPerPeriod() / (double)sampleRate();
|
||||
double inLatency = 0;//(double)mixer()->framesPerPeriod() / (double)sampleRate();
|
||||
double outLatency = 0;//(double)mixer()->framesPerPeriod() / (double)sampleRate();
|
||||
|
||||
//inLatency = Pa_GetDeviceInfo( inDevIdx )->defaultLowInputLatency;
|
||||
//outLatency = Pa_GetDeviceInfo( outDevIdx )->defaultLowOutputLatency;
|
||||
const int samples = getMixer()->framesPerPeriod();
|
||||
const int samples = mixer()->framesPerPeriod();
|
||||
|
||||
// Configure output parameters.
|
||||
m_outputParameters.device = outDevIdx;
|
||||
@@ -233,8 +234,8 @@ void AudioPortAudio::applyQualitySettings()
|
||||
if( hqAudio() )
|
||||
{
|
||||
|
||||
setSampleRate( engine::getMixer()->processingSampleRate() );
|
||||
int samples = getMixer()->framesPerPeriod();
|
||||
setSampleRate( engine::mixer()->processingSampleRate() );
|
||||
int samples = mixer()->framesPerPeriod();
|
||||
|
||||
PaError err = Pa_OpenStream(
|
||||
&m_paStream,
|
||||
@@ -253,7 +254,7 @@ void AudioPortAudio::applyQualitySettings()
|
||||
}
|
||||
}
|
||||
|
||||
AudioDevice::applyQualitySettings();
|
||||
AudioBackend::applyQualitySettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +266,7 @@ int AudioPortAudio::process_callback(
|
||||
{
|
||||
if( supportsCapture() )
|
||||
{
|
||||
getMixer()->pushInputFrames( (sampleFrame*)_inputBuffer,
|
||||
mixer()->pushInputFrames( (sampleFrame*)_inputBuffer,
|
||||
_framesPerBuffer );
|
||||
}
|
||||
|
||||
@@ -295,14 +296,14 @@ int AudioPortAudio::process_callback(
|
||||
const int min_len = qMin( (int)_framesPerBuffer,
|
||||
m_outBufSize - m_outBufPos );
|
||||
|
||||
float master_gain = getMixer()->masterGain();
|
||||
float master_gain = mixer()->masterGain();
|
||||
|
||||
for( fpp_t frame = 0; frame < min_len; ++frame )
|
||||
{
|
||||
for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl )
|
||||
{
|
||||
( _outputBuffer + frame * channels() )[chnl] =
|
||||
mixer::clip( m_outBuf[frame][chnl] *
|
||||
Mixer::clip( m_outBuf[frame][chnl] *
|
||||
master_gain );
|
||||
}
|
||||
}
|
||||
@@ -390,7 +391,7 @@ void AudioPortAudioSetupUtil::updateChannels()
|
||||
|
||||
|
||||
AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) :
|
||||
AudioDevice::setupWidget( AudioPortAudio::name(), _parent )
|
||||
AudioBackend::setupWidget( AudioPortAudio::name(), _parent )
|
||||
{
|
||||
m_backend = new comboBox( this, "BACKEND" );
|
||||
m_backend->setGeometry( 64, 15, 260, 20 );
|
||||
|
||||
Reference in New Issue
Block a user