@@ -89,22 +89,9 @@ int callback(const void* input, void* output, frame_t frameCount
8989
9090 const bool playing = action -> type == PLAY_BUFFER
9191 || action -> type == PLAY_RINGBUFFER ;
92- const bool recording = action -> type == RECORD_BUFFER
93- || action -> type == RECORD_RINGBUFFER ;
94- const bool using_buffer = action -> type == PLAY_BUFFER
95- || action -> type == RECORD_BUFFER ;
96- const bool using_ringbuffer = action -> type == PLAY_RINGBUFFER
97- || action -> type == RECORD_RINGBUFFER ;
98- PaTime io_time = 0 ;
99- if (playing )
100- {
101- io_time = timeInfo -> outputBufferDacTime ;
102- }
103- if (recording )
104- {
105- io_time = timeInfo -> inputBufferAdcTime ;
106- }
10792
93+ PaTime io_time = playing ? timeInfo -> outputBufferDacTime
94+ : timeInfo -> inputBufferAdcTime ;
10895 frame_t offset = 0 ;
10996
11097 if (action -> done_frames == 0 )
@@ -139,17 +126,6 @@ int callback(const void* input, void* output, frame_t frameCount
139126 }
140127 }
141128
142- float * device_data = NULL ;
143-
144- if (playing )
145- {
146- device_data = (float * )output + offset * state -> output_channels ;
147- }
148- else if (recording )
149- {
150- device_data = (float * )input + offset * state -> input_channels ;
151- }
152-
153129 frame_t frames = action -> total_frames - action -> done_frames ;
154130
155131 if (frameCount < frames )
@@ -162,11 +138,15 @@ int callback(const void* input, void* output, frame_t frameCount
162138 frames = frameCount - offset ;
163139 }
164140
165- if (using_buffer )
141+ float * device_data
142+ = playing ? (float * )output + offset * state -> output_channels
143+ : (float * ) input + offset * state -> input_channels ;
144+
145+ if (action -> type == PLAY_BUFFER || action -> type == RECORD_BUFFER )
166146 {
167147 float * buffer = action -> buffer + action -> done_frames * action -> channels ;
168148 action -> done_frames += frames ;
169- if (playing )
149+ if (action -> type == PLAY_BUFFER )
170150 {
171151 while (frames -- )
172152 {
@@ -177,8 +157,10 @@ int callback(const void* input, void* output, frame_t frameCount
177157 device_data += state -> output_channels ;
178158 }
179159 }
180- else if ( recording )
160+ else
181161 {
162+ CALLBACK_ASSERT (action -> type == RECORD_BUFFER );
163+
182164 while (frames -- )
183165 {
184166 for (frame_t c = 0 ; c < action -> channels ; c ++ )
@@ -189,15 +171,18 @@ int callback(const void* input, void* output, frame_t frameCount
189171 }
190172 }
191173 }
192- else if ( using_ringbuffer )
174+ else
193175 {
176+ CALLBACK_ASSERT (action -> type == PLAY_RINGBUFFER
177+ || action -> type == RECORD_RINGBUFFER );
178+
194179 float * block1 = NULL ;
195180 float * block2 = NULL ;
196181 ring_buffer_size_t size1 = 0 ;
197182 ring_buffer_size_t size2 = 0 ;
198183 ring_buffer_size_t totalsize = 0 ;
199184
200- if (playing )
185+ if (action -> type == PLAY_RINGBUFFER )
201186 {
202187 totalsize = PaUtil_GetRingBufferReadRegions (action -> ringbuffer
203188 , (ring_buffer_size_t )frames
@@ -222,8 +207,10 @@ int callback(const void* input, void* output, frame_t frameCount
222207 action -> done_frames += (frame_t )totalsize ;
223208 PaUtil_AdvanceRingBufferReadIndex (action -> ringbuffer , totalsize );
224209 }
225- else if ( recording )
210+ else
226211 {
212+ CALLBACK_ASSERT (action -> type == RECORD_RINGBUFFER );
213+
227214 totalsize = PaUtil_GetRingBufferWriteRegions (action -> ringbuffer
228215 , (ring_buffer_size_t )frames
229216 , (void * * )& block1 , & size1 , (void * * )& block2 , & size2 );
0 commit comments