コード例 #1
0
ファイル: log.c プロジェクト: mahaserver/MHSVLC
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
                                                libvlc_log_message_t *buffer,
                                                libvlc_exception_t *p_e )
{
    int i_pos;

    if( !p_iter )
        RAISENULL("Invalid log iterator!");
    if( !buffer )
        RAISENULL("Invalid message buffer!");

    i_pos = p_iter->i_pos;
    if( i_pos != p_iter->i_end )
    {
        msg_item_t *msg;
        vlc_mutex_lock(p_iter->p_messages->p_lock);
        msg = p_iter->p_messages->p_msg+i_pos;
        buffer->i_severity  = msg->i_type;
        buffer->psz_type    = msg->psz_object_type;
        buffer->psz_name    = msg->psz_module;
        buffer->psz_header  = msg->psz_header;
        buffer->psz_message = msg->psz_msg;
        p_iter->i_pos = ++i_pos % VLC_MSG_QSIZE;
        vlc_mutex_unlock(p_iter->p_messages->p_lock);

        return buffer;
    }
    RAISENULL("No more messages");
}
コード例 #2
0
ファイル: log.c プロジェクト: Kafay/vlc
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
                                                libvlc_log_message_t *buffer,
                                                libvlc_exception_t *p_e )
{
    unsigned i_pos;

    if( !p_iter )
        RAISENULL("Invalid log iterator!");
    if( !buffer )
        RAISENULL("Invalid message buffer!");

    i_pos = p_iter->i_pos;
    if( i_pos != p_iter->i_end )
    {
        msg_item_t *msg;
        vlc_spin_lock (&p_iter->p_data->lock);
        msg = p_iter->p_data->items[i_pos];
        buffer->i_severity  = msg->i_type;
        buffer->psz_type    = msg->psz_object_type;
        buffer->psz_name    = msg->psz_module;
        buffer->psz_header  = msg->psz_header;
        buffer->psz_message = msg->psz_msg;
        vlc_spin_unlock (&p_iter->p_data->lock);
        p_iter->i_pos++;

        return buffer;
    }
    RAISENULL("No more messages");
}
コード例 #3
0
ファイル: core.c プロジェクト: FLYKingdom/vlc
libvlc_instance_t * libvlc_new( int argc, const char *const *argv,
                                libvlc_exception_t *p_e )
{
    libvlc_instance_t *p_new;
    int i_ret;

    libvlc_init_threads ();

    libvlc_int_t *p_libvlc_int = libvlc_InternalCreate();
    if( !p_libvlc_int )
    {
        libvlc_deinit_threads ();
        RAISENULL( "VLC initialization failed" );
    }

    p_new = malloc( sizeof( libvlc_instance_t ) );
    if( !p_new )
    {
        libvlc_deinit_threads ();
        RAISENULL( "Out of memory" );
    }

    const char *my_argv[argc + 2];

    my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */
    for( int i = 0; i < argc; i++ )
         my_argv[i + 1] = argv[i];
    my_argv[argc + 1] = NULL; /* C calling conventions require a NULL */

    /** \todo Look for interface settings. If we don't have any, add -I dummy */
    /* Because we probably don't want a GUI by default */

    i_ret = libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv );
    if( i_ret )
    {
        libvlc_InternalDestroy( p_libvlc_int );
        free( p_new );
        libvlc_deinit_threads ();

        if( i_ret == VLC_EEXITSUCCESS )
            return NULL;
        else
            RAISENULL( "VLC initialization failed" );
    }

    p_new->p_libvlc_int = p_libvlc_int;
    p_new->libvlc_vlm.p_vlm = NULL;
    p_new->libvlc_vlm.p_event_manager = NULL;
    p_new->libvlc_vlm.pf_release = NULL;
    p_new->ref_count = 1;
    p_new->verbosity = 1;
    p_new->p_callback_list = NULL;
    vlc_mutex_init(&p_new->instance_lock);

    return p_new;
}
コード例 #4
0
ファイル: log.c プロジェクト: mahaserver/MHSVLC
libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
{
    struct libvlc_log_t *p_log =
        (struct libvlc_log_t *)malloc(sizeof(struct libvlc_log_t));

    if( !p_log ) RAISENULL( "Out of memory" );

    p_log->p_instance = p_instance;
    p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int);

    if( !p_log->p_messages )
    {
        free( p_log );
        RAISENULL( "Out of memory" );
    }

    libvlc_retain( p_instance );
    return p_log;
}
コード例 #5
0
ファイル: log.c プロジェクト: mahaserver/MHSVLC
libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
    if( p_log && p_log->p_messages )
    {
        struct libvlc_log_iterator_t *p_iter =
            (struct libvlc_log_iterator_t *)malloc(sizeof(struct libvlc_log_iterator_t));

        if( !p_iter ) RAISENULL( "Out of memory" );

        vlc_mutex_lock(p_log->p_messages->p_lock);
        p_iter->p_messages = p_log->p_messages;
        p_iter->i_start    = p_log->p_messages->i_start;
        p_iter->i_pos      = p_log->p_messages->i_start;
        p_iter->i_end      = *(p_log->p_messages->pi_stop);
        vlc_mutex_unlock(p_log->p_messages->p_lock);

        return p_iter;
    }
    RAISENULL("Invalid log object!");
}
コード例 #6
0
ファイル: log.c プロジェクト: Kafay/vlc
libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
    if( p_log )
    {
        struct libvlc_log_iterator_t *p_iter =
            (struct libvlc_log_iterator_t *)malloc(sizeof(struct libvlc_log_iterator_t));
        /* FIXME: break constant pointer constraints */
        msg_cb_data_t *data = &((libvlc_log_t *)p_log)->data;

        if( !p_iter ) RAISENULL( "Out of memory" );

        vlc_spin_lock (&data->lock);
        p_iter->p_data  = data;
        p_iter->i_pos   = 0;
        p_iter->i_end   = data->count;
        vlc_spin_unlock (&data->lock);

        return p_iter;
    }
    RAISENULL("Invalid log object!");
}
コード例 #7
0
ファイル: log.c プロジェクト: Kafay/vlc
libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
{
    struct libvlc_log_t *p_log =
        (struct libvlc_log_t *)malloc(sizeof(struct libvlc_log_t));

    if( !p_log ) RAISENULL( "Out of memory" );

    p_log->p_instance = p_instance;
    vlc_spin_init( &p_log->data.lock );
    p_log->data.count = 0;
    p_log->data.verbosity = p_instance->verbosity;
    p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int, handler, &p_log->data);

    if( !p_log->p_messages )
    {
        free( p_log );
        RAISENULL( "Out of memory" );
    }

    libvlc_retain( p_instance );
    return p_log;
}