Skip to content

Commit 3ab2062

Browse files
committed
Portaudio error corrections
1 parent 12c61ca commit 3ab2062

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

examples-desktop/generator/generator.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ void setup(void) {
1414
Serial.begin(115200);
1515

1616
// open output
17-
auto config = out.defaultConfig();
17+
PortAudioInfo config = out.defaultConfig();
1818
config.sample_rate = sample_rate;
1919
config.channels = channels;
2020
config.bits_per_sample = sizeof(int16_t)*8;
21-
out.begin();
21+
out.begin(config);
2222

2323
// Setup sine wave
2424
sineWave.begin(sample_rate, B4);

src/AudioTools/PortAudioStream.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
*
1414
*/
1515
class PortAudioInfo : public AudioBaseInfo {
16-
bool is_input = false;
17-
bool is_output = true;
16+
public:
17+
bool is_input = false;
18+
bool is_output = true;
1819
};
1920

2021
/**
@@ -49,20 +50,17 @@ class PortAudioStream : BufferedStream {
4950

5051
/* Open an audio I/O stream. */
5152
err = Pa_OpenDefaultStream( &stream,
52-
info.is_input ? info.channels : 0, /* no input channels */
53-
info.is_output ? info.channels : 0, /* stereo output */
54-
getFormat(info.bits_per_sample), /* 32 bit integer */
55-
info.sample_rate,
56-
paFramesPerBufferUnspecified, /* frames per buffer, i.e. the number
57-
of sample frames that PortAudio will
58-
request from the callback. Many apps
59-
may want to use
60-
paFramesPerBufferUnspecified, which
61-
tells PortAudio to pick the best,
62-
possibly changing, buffer size.*/
63-
nullptr, /* this is your callback function */
64-
nullptr ); /*This is a pointer that will be passed to
65-
your callback*/
53+
info.is_input ? info.channels : 0, /* no input channels */
54+
info.is_output ? info.channels : 0, /* stereo output */
55+
getFormat(info.bits_per_sample),
56+
info.sample_rate,
57+
paFramesPerBufferUnspecified, /* frames per buffer, i.e. the number
58+
of sample frames that PortAudio will
59+
request from the callback. Many apps
60+
may want to use*/
61+
nullptr, /* this is your callback function */
62+
nullptr ); /*This is a pointer that will be passed to
63+
your callback*/
6664
if( err != paNoError ) {
6765
LOGE( "PortAudio error: %s\n", Pa_GetErrorText( err ) );
6866
}
@@ -90,7 +88,6 @@ class PortAudioStream : BufferedStream {
9088
PaError err = paNoError;
9189
PortAudioInfo info;
9290

93-
9491
virtual size_t writeExt(const uint8_t* data, size_t len) {
9592
size_t result = 0;
9693
if (stream!=nullptr){

0 commit comments

Comments
 (0)