Skip to content

Commit 175c9f5

Browse files
committed
Clarifying record_queue_f32
1 parent 33dfdcc commit 175c9f5

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

AudioConvert_F32.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
#ifndef _AudioConvert_I16toF32_h
33
#define _AudioConvert_I16toF32_h
44

5-
65
#include <AudioStream_F32.h>
76

87
class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits Float
98
{
109
//GUI: inputs:1, outputs:1 //this line used for automatic generation of GUI node
1110
public:
1211
AudioConvert_I16toF32(void) : AudioStream_F32(1, inputQueueArray_f32) { };
13-
void update(void) {
12+
void update(void) {
1413
//get the Int16 block
1514
audio_block_t *int_block;
1615
int_block = AudioStream::receiveReadOnly(); //int16 data block
17-
if (!int_block) return;
16+
if (int_block==NULL) return;
1817

1918
//allocate a float block
2019
audio_block_f32_t *float_block;
2120
float_block = AudioStream_F32::allocate_f32();
22-
if (float_block == NULL) return;
21+
if (float_block == NULL) {
22+
AudioStream::release(int_block);
23+
return;
24+
}
2325

2426
//convert to float
2527
convertAudio_I16toF32(int_block, float_block, AUDIO_BLOCK_SAMPLES);
@@ -57,7 +59,10 @@ class AudioConvert_F32toI16 : public AudioStream_F32 //receive Float and transmi
5759
//allocate a Int16 block
5860
audio_block_t *int_block;
5961
int_block = AudioStream::allocate();
60-
if (int_block == NULL) return;
62+
if (int_block == NULL) {
63+
AudioStream_F32::release(float_block);
64+
return;
65+
}
6166

6267
//convert back to int16
6368
convertAudio_F32toI16(float_block, int_block, AUDIO_BLOCK_SAMPLES);

record_queue_f32.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ void AudioRecordQueue_F32::clear(void)
4343
uint32_t t;
4444

4545
if (userblock) {
46-
release(userblock);
46+
AudioStream_F32::release(userblock);
4747
userblock = NULL;
4848
}
4949
t = tail;
5050
while (t != head) {
5151
if (++t >= 53) t = 0;
52-
release(queue[t]);
52+
AudioStream_F32::release(queue[t]);
5353
}
5454
tail = t;
5555
}
@@ -72,7 +72,7 @@ audio_block_f32_t * AudioRecordQueue_F32::getAudioBlock(void)
7272
{
7373
uint32_t t;
7474

75-
if (userblock) return NULL;
75+
if (userblock != NULL) return NULL;
7676
t = tail;
7777
if (t == head) return NULL;
7878
if (++t >= 53) t = 0;
@@ -84,7 +84,7 @@ audio_block_f32_t * AudioRecordQueue_F32::getAudioBlock(void)
8484
void AudioRecordQueue_F32::freeBuffer(void)
8585
{
8686
if (userblock == NULL) return;
87-
release(userblock);
87+
AudioStream_F32::release(userblock);
8888
userblock = NULL;
8989
}
9090

@@ -98,15 +98,15 @@ void AudioRecordQueue_F32::update(void)
9898
uint32_t h;
9999

100100
block = receiveReadOnly_f32();
101-
if (!block) return;
101+
if (block==NULL) return;
102102
if (!enabled) {
103-
release(block);
103+
AudioStream_F32::release(block);
104104
return;
105105
}
106106
h = head + 1;
107107
if (h >= 53) h = 0;
108108
if (h == tail) {
109-
release(block);
109+
AudioStream_F32::release(block);
110110
} else {
111111
queue[h] = block;
112112
head = h;

0 commit comments

Comments
 (0)