Exemple #1
0
/*****************************************************************************
 * QNXaoutThread: asynchronous thread used to DMA the data to the device
 *****************************************************************************/
static int QNXaoutThread( aout_instance_t * p_aout )
{
    struct aout_sys_t * p_sys = p_aout->output.p_sys;

    while ( !p_aout->b_die )
    {
        aout_buffer_t * p_buffer;
        int i_tmp, i_size;
        byte_t * p_bytes;

        if ( p_aout->output.output.i_format != VLC_FOURCC('s','p','d','i') )
        {
            mtime_t next_date = 0;

            /* Get the presentation date of the next write() operation. It
             * is equal to the current date + duration of buffered samples.
             * Order is important here, since GetBufInfo is believed to take
             * more time than mdate(). */
            next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
                      / p_aout->output.output.i_bytes_per_frame
                      / p_aout->output.output.i_rate
                      * p_aout->output.output.i_frame_length;
            next_date += mdate();

            p_buffer = aout_OutputNextBuffer( p_aout, next_date, VLC_FALSE );
        }
        else
        {
            p_buffer = aout_OutputNextBuffer( p_aout, 0, VLC_TRUE );
        }

        if ( p_buffer != NULL )
        {
            p_bytes = p_buffer->p_buffer;
            i_size = p_buffer->i_nb_bytes;
        }
        else
        {
            i_size = DEFAULT_FRAME_SIZE / p_aout->output.output.i_frame_length
                      * p_aout->output.output.i_bytes_per_frame;
            p_bytes = p_aout->output.p_sys->p_silent_buffer;
            memset( p_bytes, 0, i_size );
        }

        i_tmp = snd_pcm_plugin_write( p_aout->output.p_sys->p_pcm_handle,
                                        (void *) p_bytes,
                                        (size_t) i_size );

        if( i_tmp < 0 )
        {
            msg_Err( p_aout, "write failed (%s)", strerror(errno) );
        }

        if ( p_buffer != NULL )
        {
            aout_BufferFree( p_buffer );
        }
    }

    return 0;
}
Exemple #2
0
/*****************************************************************************
 * QNXaoutThread: asynchronous thread used to DMA the data to the device
 *****************************************************************************/
static void* QNXaoutThread( vlc_object_t *p_this )
{
    aout_instance_t * p_aout = (aout_instance_t*)p_this;
    struct aout_sys_t * p_sys = p_aout->output.p_sys;
    int canc = vlc_savecancel ();

    while ( vlc_object_alive (p_aout) )
    {
        aout_buffer_t * p_buffer;
        int i_tmp, i_size;
        uint8_t * p_bytes;

        if ( p_aout->output.output.i_format != VLC_CODEC_SPDIFL )
        {
            mtime_t next_date = 0;

            /* Get the presentation date of the next write() operation. It
             * is equal to the current date + duration of buffered samples.
             * Order is important here, since GetBufInfo is believed to take
             * more time than mdate(). */
            next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
                      / p_aout->output.output.i_bytes_per_frame
                      / p_aout->output.output.i_rate
                      * p_aout->output.output.i_frame_length;
            next_date += mdate();

            p_buffer = aout_OutputNextBuffer( p_aout, next_date, false );
        }
        else
        {
            p_buffer = aout_OutputNextBuffer( p_aout, 0, true );
        }

        if ( p_buffer != NULL )
        {
            p_bytes = p_buffer->p_buffer;
            i_size = p_buffer->i_nb_bytes;
        }
        else
        {
            i_size = DEFAULT_FRAME_SIZE / p_aout->output.output.i_frame_length
                      * p_aout->output.output.i_bytes_per_frame;
            p_bytes = p_aout->output.p_sys->p_silent_buffer;
            memset( p_bytes, 0, i_size );
        }

        i_tmp = snd_pcm_plugin_write( p_aout->output.p_sys->p_pcm_handle,
                                        (void *) p_bytes,
                                        (size_t) i_size );

        if( i_tmp < 0 )
        {
            msg_Err( p_aout, "write failed (%m)" );
        }

        if ( p_buffer != NULL )
        {
            aout_BufferFree( p_buffer );
        }
    }

    vlc_restorecancel (canc);
    return NULL;
}