Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up PortAudio backend #7444

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
359ca7b
Suggest the default low latency
sakertooth Aug 11, 2024
44da003
Remove verbose comments
sakertooth Aug 11, 2024
8af8bcb
Completely remove old PortAudio < v19 code
sakertooth Aug 11, 2024
f14188a
Remove redundant header guard
sakertooth Aug 11, 2024
5a6c2ff
Rename and move setup widget into gui namespace
sakertooth Aug 11, 2024
f9c5c4a
Fix naming of callback functions
sakertooth Aug 11, 2024
5badd59
Merge AudioPortAudioSetupWidget and AudioPortAudioSetupUtil
sakertooth Aug 11, 2024
7433c15
Fix naming in constructor
sakertooth Aug 11, 2024
7eb6089
Fix naming for parameters of callback functions
sakertooth Aug 11, 2024
a342db7
Move closing brace up
sakertooth Aug 11, 2024
71a4ab2
Clean up constructor
sakertooth Aug 11, 2024
12b9de4
Replace printf calls on error with std::cerr
sakertooth Aug 11, 2024
261642d
Use unique_ptr for m_outBuf
sakertooth Aug 11, 2024
9952bf8
Do not use multiple techniques to start and stop the stream
sakertooth Aug 12, 2024
849667d
Merge remote-tracking branch 'upstream/master' into cleanup-portaudio…
sakertooth Aug 12, 2024
a762042
Move back to using paComplete
sakertooth Aug 12, 2024
bb21cf4
Fix naming style
sakertooth Aug 12, 2024
b7963c7
Replace memset with std::fill_n
sakertooth Aug 12, 2024
4ff2725
Remove redundant frames variable
sakertooth Aug 12, 2024
333c081
Simplify nested for loop
sakertooth Aug 12, 2024
6c7c25c
Fix unsigned comparison
sakertooth Aug 12, 2024
0647ddc
Use Qt's combo boxes
sakertooth Aug 12, 2024
88aaace
Include memory header
sakertooth Aug 12, 2024
c43246b
Remove LcdSpinBox forward declaration
sakertooth Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 26 additions & 89 deletions include/AudioPortAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,137 +25,74 @@
#ifndef LMMS_AUDIO_PORTAUDIO_H
#define LMMS_AUDIO_PORTAUDIO_H

#include <QObject>

#include "lmmsconfig.h"
#include "ComboBoxModel.h"

#ifdef LMMS_HAVE_PORTAUDIO

# include <portaudio.h>

# include "AudioDevice.h"
# include "AudioDeviceSetupWidget.h"

# if defined paNeverDropInput || defined paNonInterleaved
# define PORTAUDIO_V19
# else
# define PORTAUDIO_V18
# endif
#include <QObject>
#include <memory>
#include <portaudio.h>

#endif
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"

class QComboBox;

namespace lmms
{

class AudioPortAudioSetupUtil : public QObject
namespace gui {

class AudioPortAudioSetupWidget : public gui::AudioDeviceSetupWidget
{
Q_OBJECT
public slots:
public:
AudioPortAudioSetupWidget(QWidget* _parent);

void updateBackends();
void updateDevices();
void updateChannels();

public:
ComboBoxModel m_backendModel;
ComboBoxModel m_deviceModel;
};


#ifdef LMMS_HAVE_PORTAUDIO


namespace gui
{
class ComboBox;
class LcdSpinBox;
}
void saveSettings() override;
void show() override;

private:
QComboBox* m_backendComboBox;
QComboBox* m_deviceComboBox;
};
} // namespace gui

class AudioPortAudio : public AudioDevice
{
public:
AudioPortAudio( bool & _success_ful, AudioEngine* audioEngine );
AudioPortAudio(bool& successful, AudioEngine* engine);
~AudioPortAudio() override;

inline static QString name()
{
return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "PortAudio" );
}

int process_callback(const float* _inputBuffer, float* _outputBuffer, f_cnt_t _framesPerBuffer);

class setupWidget : public gui::AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent );
~setupWidget() override;

void saveSettings() override;
void show() override;

private:
gui::ComboBox * m_backend;
gui::ComboBox * m_device;
AudioPortAudioSetupUtil m_setupUtil;

} ;

private:
void startProcessing() override;
void stopProcessing() override;

#ifdef PORTAUDIO_V19
static int _process_callback( const void *_inputBuffer, void * _outputBuffer,
unsigned long _framesPerBuffer,
const PaStreamCallbackTimeInfo * _timeInfo,
PaStreamCallbackFlags _statusFlags,
void *arg );

#else

#define paContinue 0
#define paComplete 1
#define Pa_GetDeviceCount Pa_CountDevices
#define Pa_GetDefaultInputDevice Pa_GetDefaultInputDeviceID
#define Pa_GetDefaultOutputDevice Pa_GetDefaultOutputDeviceID
#define Pa_IsStreamActive Pa_StreamActive

static int _process_callback( void * _inputBuffer, void * _outputBuffer,
unsigned long _framesPerBuffer, PaTimestamp _outTime, void * _arg );


using PaTime = double;
using PaDeviceIndex = PaDeviceID;

using PaStreamParameters = struct
{
PaDeviceIndex device;
int channelCount;
PaSampleFormat sampleFormat;
PaTime suggestedLatency;
void *hostApiSpecificStreamInfo;

} PaStreamParameters;
#endif // PORTAUDIO_V19
int processCallback(const float* inputBuffer, float* outputBuffer, f_cnt_t framesPerBuffer);
static int processCallback(const void* inputBuffer, void* outputBuffer, unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* arg);

PaStream * m_paStream;
PaStreamParameters m_outputParameters;
PaStreamParameters m_inputParameters;

bool m_wasPAInitError;

SampleFrame* m_outBuf;
std::unique_ptr<SampleFrame[]> m_outBuf;
std::size_t m_outBufPos;
fpp_t m_outBufSize;
};

bool m_stopped;

} ;
} // namespace lmms

#endif // LMMS_HAVE_PORTAUDIO

} // namespace lmms

#endif // LMMS_AUDIO_PORTAUDIO_H
Loading
Loading