Closed jian-yuan-cmd closed 2 months ago
Thanks for your feedback. I noticed the same issue recently when reviewing the code. With FIFOs it's good to have a defined output in the case of underflow/overflow or at least some way to notify the user that the data is valid and the FIFO is behaving normally so the application code can decide what to output. In audio systems, a random DC value is not desirable when idle.
I'll discuss this internally and keep you posted.
The FIFO can potentially be used for data other than PCM (eg. DSD). So setting to zero is not always a good idea. We think the best thing to do will be to return a flag from asynchronous_fifo_consumer_get() which the application can then best decide what to do with. In PCM cases, zeroing the samples makes sense of course.
@jian-yuan-cmd is this acceptable?
If so we can update the FIFO code and ASRC task in lib_src. We are making changes at the moment anyway.
Yes, I think your idea is very good. I agree with your idea completely, thanks.
Some projects need the input audio stream from ADAT or SPDIF ,and sent to I2S after SRC. I found that the I2S data wasn't set to 0 after removing the optical cable. So I modified the asynchronous_fifo_consumer_get() function in lib_src: After copying the ASRC output data to the sending BUF of I2S, I fill 0 to buffer of ASRC output that data has used recently. After the above modification and verification, it was found that the I2S output data was setted to 0 after removing the optical cable. This results meet expectations, so I provide feedback hereby. The code is as follows. void asynchronous_fifo_consumer_get(asynchronous_fifo_t state, int32_t samples, int32_t timestamp) { ... ... ... ... ... ...
ifdef XS2A
else
endif
// clear the asrc_buffer for clr outpul_Val after optical-cable had removed _jian 20240819 memset( state->buffer + read_ptr channel_count, 0, channel_count sizeof(int32_t) ); // added _jian 20240819
... ... }