mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-05-12 10:37:20 +00:00
crash fixed with no input device
This commit is contained in:
parent
5eecc279ad
commit
905548bd36
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include "process_thread.h"
|
#include "process_thread.h"
|
||||||
#include "audio_thread.h"
|
#include "audio_thread.h"
|
||||||
//#include "pitchshift.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -34,8 +33,6 @@ int main( int argc , char *argv[] ){
|
|||||||
|
|
||||||
cerr<<"Qt version: "<<qVersion()<<endl;
|
cerr<<"Qt version: "<<qVersion()<<endl;
|
||||||
|
|
||||||
//pitchshift::init(44100);
|
|
||||||
|
|
||||||
process_thread pt;
|
process_thread pt;
|
||||||
audio_thread at(pt);
|
audio_thread at(pt);
|
||||||
pt.register_renderer(at.m_left_renderer, at.m_right_renderer, at.m_block_stream);
|
pt.register_renderer(at.m_left_renderer, at.m_right_renderer, at.m_block_stream);
|
||||||
|
@ -58,27 +58,27 @@ bool portaudio_client::attach(const string &client_name, const device_options &d
|
|||||||
PaDeviceIndex output_device_num = Pa_GetDefaultOutputDevice();
|
PaDeviceIndex output_device_num = Pa_GetDefaultOutputDevice();
|
||||||
PaDeviceIndex input_device_num = Pa_GetDefaultInputDevice();
|
PaDeviceIndex input_device_num = Pa_GetDefaultInputDevice();
|
||||||
|
|
||||||
//output_device_num = 4;
|
|
||||||
//input_device_num = 4;
|
|
||||||
|
|
||||||
PaStreamParameters output_parameters;
|
PaStreamParameters output_parameters;
|
||||||
output_parameters.device = output_device_num;
|
output_parameters.device = output_device_num;
|
||||||
if (output_parameters.device == paNoDevice) {
|
if (output_parameters.device == paNoDevice) {
|
||||||
cerr<<"error: no default output device."<<endl;
|
cerr<<"error: no default output device."<<endl;
|
||||||
|
} else {
|
||||||
|
output_parameters.channelCount = 2; /* stereo output */
|
||||||
|
output_parameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
||||||
|
output_parameters.suggestedLatency = Pa_GetDeviceInfo( output_parameters.device )->defaultLowOutputLatency;
|
||||||
|
output_parameters.hostApiSpecificStreamInfo = NULL;
|
||||||
|
cerr<<"Connecting to "<<Pa_GetDeviceInfo( output_parameters.device )->name<<" for output"<<endl;
|
||||||
}
|
}
|
||||||
output_parameters.channelCount = 2; /* stereo output */
|
|
||||||
output_parameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
|
||||||
output_parameters.suggestedLatency = Pa_GetDeviceInfo( output_parameters.device )->defaultLowOutputLatency;
|
|
||||||
output_parameters.hostApiSpecificStreamInfo = NULL;
|
|
||||||
|
|
||||||
cerr<<"Connecting to "<<Pa_GetDeviceInfo( output_parameters.device )->name<<" for output"<<endl;
|
|
||||||
|
|
||||||
PaStreamParameters input_parameters;
|
PaStreamParameters input_parameters;
|
||||||
|
PaStreamParameters *input_p=&input_parameters;
|
||||||
input_parameters.device = input_device_num;
|
input_parameters.device = input_device_num;
|
||||||
if (input_parameters.device == paNoDevice) {
|
if (input_parameters.device == paNoDevice) {
|
||||||
cerr<<"error: no default input device."<<endl;
|
cerr<<"error: no default input device."<<endl;
|
||||||
|
input_p=0;
|
||||||
} else {
|
} else {
|
||||||
input_parameters.channelCount = 2; /* stereo output */
|
input_parameters.channelCount = 2; /* stereo output */
|
||||||
input_parameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
input_parameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
||||||
input_parameters.suggestedLatency = Pa_GetDeviceInfo( input_parameters.device )->defaultLowInputLatency;
|
input_parameters.suggestedLatency = Pa_GetDeviceInfo( input_parameters.device )->defaultLowInputLatency;
|
||||||
input_parameters.hostApiSpecificStreamInfo = NULL;
|
input_parameters.hostApiSpecificStreamInfo = NULL;
|
||||||
@ -88,7 +88,7 @@ bool portaudio_client::attach(const string &client_name, const device_options &d
|
|||||||
PaStream *stream;
|
PaStream *stream;
|
||||||
|
|
||||||
err = Pa_OpenStream(&stream,
|
err = Pa_OpenStream(&stream,
|
||||||
&input_parameters,
|
input_p,
|
||||||
&output_parameters,
|
&output_parameters,
|
||||||
dopt.samplerate,
|
dopt.samplerate,
|
||||||
dopt.buffer_size,
|
dopt.buffer_size,
|
||||||
@ -147,7 +147,7 @@ int portaudio_client::process(const void *input_buffer, void *output_buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_right_in_data && m_left_in_data) {
|
if (input_buffer && m_right_in_data && m_left_in_data) {
|
||||||
float *in = (float*)input_buffer;
|
float *in = (float*)input_buffer;
|
||||||
for (unsigned int n=0; n<m_buffer_size; n++) {
|
for (unsigned int n=0; n<m_buffer_size; n++) {
|
||||||
m_left_in_data[n]=*in;
|
m_left_in_data[n]=*in;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user