src/test/sysdep/linux/sound.c
static int read_pcm(int16_t *buffer, int count)
{
    uint8_t *ptr = (uint8_t *)buffer;
    int left = count;
    while (left > 0) {
        int to_read = ubound(left, pcm_buffer_size);
        ssize_t result;
        while ((result = snd_pcm_readi(pcm_handle, ptr, to_read)) < 0) {
            DLOG("snd_pcm_readi(): %s", snd_strerror(result));
            if (result == -EPIPE) {
                result = snd_pcm_prepare(pcm_handle);
                if (result != 0) {
                    DLOG("snd_pcm_readi(): overrun recovery failed: %s",
                         snd_strerror(result));
                    return 0;
                }
            } else {
                result = snd_pcm_recover(pcm_handle, result, 0);
                if (result != 0) {
                    DLOG("snd_pcm_readi(): recover: %s", snd_strerror(result));
                    return 0;
                }
            }
        }
        ptr += result * 4;
        left -= result;
    }
    ASSERT(ptr == (uint8_t *)buffer + count*4);
    return 1;
}
/**
 * read_pcm:  Read the given number of 16-bit stereo samples from the
 * loopback PCM capture device.
 *
 * [Parameters]
 *     buffer: Buffer into which to read PCM samples.
 *     count: Number of samples to read.
 * [Return value]
 *     True on success, false on failure (including short read).
 */
Read the given number of 16-bit stereo samples from the
loopback PCM capture device.

[Parameters]
buffer: Buffer into which to read PCM samples.
count: Number of samples to read.
[Return value]
True on success, false on failure (including short read).
Read the given number of 16 - bit stereo samples from the loopback PCM capture device . [ Parameters ] buffer : Buffer into which to read PCM samples . count : Number of samples to read . [ Return value ] True on success false on failure ( including short read ) .
static int read_pcm(int16_t *buffer, int count)
{
    uint8_t *ptr = (uint8_t *)buffer;
    int left = count;
    while (left > 0) {
        int to_read = ubound(left, pcm_buffer_size);
        ssize_t result;
        while ((result = snd_pcm_readi(pcm_handle, ptr, to_read)) < 0) {
            DLOG("snd_pcm_readi(): %s", snd_strerror(result));
            if (result == -EPIPE) {
                result = snd_pcm_prepare(pcm_handle);
                if (result != 0) {
                    DLOG("snd_pcm_readi(): overrun recovery failed: %s",
                         snd_strerror(result));
                    return 0;
                }
            } else {
                result = snd_pcm_recover(pcm_handle, result, 0);
                if (result != 0) {
                    DLOG("snd_pcm_readi(): recover: %s", snd_strerror(result));
                    return 0;
                }
            }
        }
        ptr += result * 4;
        left -= result;
    }
    ASSERT(ptr == (uint8_t *)buffer + count*4);
    return 1;
}
static int read_pcm ( int16_t * buffer , int count ) { uint8_t * ptr = ( uint8_t * ) buffer ; int left = count ; while ( left > 0 ) { int to_read = ubound ( left , pcm_buffer_size ) ; ssize_t result ; while ( ( result = snd_pcm_readi ( pcm_handle , ptr , to_read ) ) < 0 ) { DLOG ( " " , snd_strerror ( result ) ) ; if ( result == - EPIPE ) { result = snd_pcm_prepare ( pcm_handle ) ; if ( result != 0 ) { DLOG ( " " , snd_strerror ( result ) ) ; return 0 ; } } else { result = snd_pcm_recover ( pcm_handle , result , 0 ) ; if ( result != 0 ) { DLOG ( " " , snd_strerror ( result ) ) ; return 0 ; } } } ptr += result * 4 ; left -= result ; } ASSERT ( ptr == ( uint8_t * ) buffer + count * 4 ) ; return 1 ; }
read_pcm:  Read the given number of 16-bit stereo samples from the
 loopback PCM capture device.
read_pcm : Read the given number of 16 - bit stereo samples from the loopback PCM capture device .