This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ALSA AUDIO CAPTURE ISSUE



Hi,

We booted the Vayu EVM j6 board with GLSDK 7.03 (alsa library version 1.0.27.1).When I run the  application code in j6,snd_pcm_readi() failed: Broken pipe occurs.This causes some background noise in playback.Can i have to Increase mcasp fifo level?

Kindly suggest me.

Thank you.

  • Doesn't increasing the ALSA buffer size (snd_pcm_hw_params_set_buffer_*) help?
  • Hi Clemens Ladisch,

    Thanks for your response.
    I creased the ALSA buffer size,but i faced the same behaviour.Is there any other way to solve this?
  • Hello,

    I am not aware with J6 but you could try to increase the priority.

    You could check:
    e2e.ti.com/.../256104

    This problem seems similar.

    processors.wiki.ti.com/.../AM335x_Audio_Driver's_Guide

    Hope this helps.

    BR
    Margarita
  • Hi Margarita,

    Thanks for your response.

    When the application code running in pc does not make any noise in playback.But the same application running in j6 causes mild background noise in playback.

    Case 1:
    PC capture -J6 playback --> smooth playback

    Case 2:
    J6 capture -PC playback --> background noise in playback

    Case 3:
    J6 capture -J6 playback --> background noise in playback

    Case 4:
    PC capture - PC playback --> smooth playback

    The above cases are observed for the same application.
    More over, the alsa library version for j6 1.0.27 and for PC 1.0.25. Does this library version change cause any issues?

    Regards,
    Mythili R
  • Hello,

    Here is the differences between both:

    Do you check the link in the previous post (links)?

    Do you increase the task priority?

    Could you try :

     period_size = 2048;
    	buf_size = period_size * 4;
    
    
    	snd_pcm_hw_params_set_buffer_size_near(handle, hw_params, &buf_size);
            snd_pcm_hw_params_set_period_size_near(handle, hw_params, &period_size, 0);

    BR

    Margarita

  • Margarita,

    Thanks much for your reply.

    I have checked the difference between the alsa lib versions.From that i didnt find root cause for this .

    Here I mentioned the alsa configuration.

    /* Number of Audio Samples per second (in Hz) */
    #define ALSA_AUDIO_SAMPLING_RATE (44100)

    /* Audio channels count */
    #define ALSA_AUDIO_CHANNELS (2)


    /******************************************************************************/
    /* ALSA configurations Section [This section can not be updated by user] */
    /******************************************************************************/
    /* set ALSA Access Type */
    #define ALSA_AUDIO_SAMPLES_ACCESS_TYPE (SND_PCM_ACCESS_RW_INTERLEAVED)

    /* Bytes per second */
    #define ALSA_SAMPLES_PER_SECOND (ALSA_AUDIO_SAMPLING_RATE)

    /* Frames per second */
    #define ALSA_FRAMES_PER_SECOND (ALSA_AUDIO_SAMPLING_RATE * ALSA_AUDIO_CHANNELS)


    /* Set ALSA Sample format as 16 bits per sample */
    #define ALSA_AUDIO_SAMPLES_FORMAT (SND_PCM_FORMAT_S16_LE)

    /**
    * One analogue sample is represented with 16 bits = 2 bytes, This can be
    * informed to ALSA as SND_PCM_FORMAT_S16_LE.
    * This should be informed to ALSA using snd_pcm_hw_params_set_format.
    */
    #define ALSA_BYTES_PER_SAMPLE (2)

    /* Bytes per frame */
    #define ALSA_BYTES_PER_FRAME (ALSA_AUDIO_CHANNELS * ALSA_BYTES_PER_SAMPLE)

    /* Number of Bytes to be read/write second */
    #define ALSA_BYTES_PER_SECOND (ALSA_SAMPLES_PER_SECOND * ALSA_BYTES_PER_FRAME)

    /**
    * The periods is the number of periods which can be accommodated in ALSA
    * driver/hardware ring buffer.
    * This should be informed to ALSA using snd_pcm_hw_params_set_periods.
    */
    #define ALSA_PERIODS_COUNT 40

    /**
    * The period is the playback duration of one period. Setting this value we inform
    * ALSA that READ/Write event should happen in this interval.
    * This should be informed to ALSA using snd_pcm_hw_params_set_period_time.
    */
    #define ALSA_PERIOD_TIME_IN_MSEC (0.125 )
    #define ALSA_PERIOD_TIME_IN_USEC (125)
    #define USEC_TO_SEC (1000000)

    /**
    * We can control when this PCM interrupt is generated, by setting a period size,
    * which is set in frames. This will be used in read, write and for setting period
    * size value configurations.
    * This should be informed to ALSA using snd_pcm_hw_params_set_period_size_near. (period size mentioned in frames count)
    */
    #define ALSA_PERIOD_SIZE ((ALSA_BYTES_PER_SECOND * ALSA_PERIOD_TIME_IN_USEC) / USEC_TO_SEC)
    /**
    * The number of bytes which can be read from capture device or write into playback
    * device in a trigger.
    */
    #define ALSA_PERIOD_BYTES (ALSA_PERIOD_SIZE * ALSA_BYTES_PER_FRAME)


    /**
    * This is the ALSA ring buffer size.
    * This should be informed to ALSA using snd_pcm_hw_params_set_buffer_size.
    */
    #define ALSA_BUFFER_SIZE (ALSA_PERIODS_COUNT * ALSA_PERIOD_BYTES)

    Every time i am reading(snd_pcm_readi()) PERIOD_SIZE frames from pcm device.

    I found that when the AUX input volume is increased to maximum volume, Noise is observed in playback.Is this related to analog noise?

    Best Regards,
    Mythili.R