Example #1
0
/**
\brief get the delay between the first and last sample in the buffer
\return delay in seconds
*/
static float get_delay(struct ao *ao)
{
    struct priv *p = ao->priv;

    int space = check_free_buffer_size(ao);
    return (float)(p->buffer_size - space) / (float)ao->bps;
}
Example #2
0
/**
   \brief find out how many bytes can be written into the audio buffer without
   \return free space in bytes, has to return 0 if the buffer is almost full
 */
static int get_space(struct ao *ao)
{
    struct priv *p = ao->priv;

    int space = check_free_buffer_size(ao);
    if (space < p->min_free_space)
        return 0;
    return (space - p->min_free_space) / ao->sstride;
}
Example #3
0
/**
\brief play 'len' bytes of 'data'
\param data pointer to the data to play
\param len size in bytes of the data buffer, gets rounded down to outburst*n
\param flags currently unused
\return number of played bytes
*/
static int play(struct ao *ao, void *data, int len, int flags)
{
    struct priv *p = ao->priv;

    int space = check_free_buffer_size(ao);
    if (space < len)
        len = space;

    if (!(flags & AOPLAY_FINAL_CHUNK))
        len = (len / p->outburst) * p->outburst;
    return write_buffer(ao, data, len);
}