I2S stream clk change problem

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

I2S stream clk change problem

Postby shabtronic » Mon Dec 16, 2019 6:43 pm

Hi All

I have a problem with i2s_stream_set_clk

I have 2 I2S streams - one for playing audio, one for recording from the line-in/mic

When I change the bitrate/samplerate on the play stream and then the rec stream to match - it hangs.

Code: Select all

i2s_stream_set_clk(i2s_writer, music_info.sample_rates, music_info.bits, music_info.channels);							
i2s_stream_set_clk(i2s_reader, music_info.sample_rates, music_info.bits, music_info.channels);
it hangs in I2S.c, play stream is waiting for RX (which is now tied up with my rec stream).

Code: Select all

    // wait all on-going writing finish
if ((p_i2s_obj[i2s_num]->mode & I2S_MODE_TX) && p_i2s_obj[i2s_num]->tx) {
       xSemaphoreTake(p_i2s_obj[i2s_num]->tx->mux, (portTickType)portMAX_DELAY);
  }
if ((p_i2s_obj[i2s_num]->mode & I2S_MODE_RX) && p_i2s_obj[i2s_num]->rx) {
      xSemaphoreTake(p_i2s_obj[i2s_num]->rx->mux, (portTickType)portMAX_DELAY);
 }

I there a easy solution around this?
Currenly I just comment those lines out and it works fine so far, but I know very little about
the internal I2S so, so I'm wondering if that's safe or a terrible hack :P

Shabby

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: I2S stream clk change problem

Postby shabtronic » Mon Dec 16, 2019 7:09 pm

Actually I was being really dumb there - there's a easy solution to stop the raw I2S rx/tx entanglement:


Code: Select all

audio_element_pause(i2s_writer);
audio_element_pause(i2s_reader);
i2s_stream_set_clk(i2s_writer, music_info.sample_rates, music_info.bits, music_info.channels);														
i2s_stream_set_clk(i2s_reader, music_info.sample_rates, music_info.bits, music_info.channels);
audio_element_resume(i2s_writer,0,0);
audio_element_resume(i2s_reader,0,0);
Works a treat - without having to comment out the I2S.c thread wait code :)

Linc08
Posts: 13
Joined: Mon May 20, 2024 7:54 am

Re: I2S stream clk change problem

Postby Linc08 » Fri Jul 26, 2024 3:19 am

shabtronic wrote:
Mon Dec 16, 2019 7:09 pm
Actually I was being really dumb there - there's a easy solution to stop the raw I2S rx/tx entanglement:


Code: Select all

audio_element_pause(i2s_writer);
audio_element_pause(i2s_reader);
i2s_stream_set_clk(i2s_writer, music_info.sample_rates, music_info.bits, music_info.channels);														
i2s_stream_set_clk(i2s_reader, music_info.sample_rates, music_info.bits, music_info.channels);
audio_element_resume(i2s_writer,0,0);
audio_element_resume(i2s_reader,0,0);
Works a treat - without having to comment out the I2S.c thread wait code :)
It works for me. Thanks!!

Who is online

Users browsing this forum: No registered users and 7 guests