📄 media_list.c
字号:
void libvlc_media_list_set_media( libvlc_media_list_t * p_mlist, libvlc_media_t * p_md, libvlc_exception_t * p_e){ (void)p_e; vlc_mutex_lock( &p_mlist->object_lock ); if( p_mlist->p_md ) libvlc_media_release( p_mlist->p_md ); libvlc_media_retain( p_md ); p_mlist->p_md = p_md; vlc_mutex_unlock( &p_mlist->object_lock );}/************************************************************************** * media (Public) * * If this media_list comes is a media's subitems, * This holds the corresponding media. * This md is also seen as the information holder for the media_list. * Indeed a media_list can have meta information through this * media. **************************************************************************/libvlc_media_t *libvlc_media_list_media( libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e){ libvlc_media_t *p_md; (void)p_e; vlc_mutex_lock( &p_mlist->object_lock ); p_md = p_mlist->p_md; if( p_md ) libvlc_media_retain( p_md ); vlc_mutex_unlock( &p_mlist->object_lock ); return p_md;}/************************************************************************** * libvlc_media_list_count (Public) * * Lock should be hold when entering. **************************************************************************/int libvlc_media_list_count( libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e ){ (void)p_e; return vlc_array_count( &p_mlist->items );}/************************************************************************** * libvlc_media_list_add_media (Public) * * Lock should be hold when entering. **************************************************************************/void libvlc_media_list_add_media( libvlc_media_list_t * p_mlist, libvlc_media_t * p_md, libvlc_exception_t * p_e ){ if( p_mlist->b_read_only ) { /* We are read only from user side */ libvlc_exception_raise( p_e, "Trying to write into a read-only media list." ); return; } _libvlc_media_list_add_media( p_mlist, p_md, p_e );}/* LibVLC internal version */void _libvlc_media_list_add_media( libvlc_media_list_t * p_mlist, libvlc_media_t * p_md, libvlc_exception_t * p_e ){ (void)p_e; libvlc_media_retain( p_md ); notify_item_addition( p_mlist, p_md, vlc_array_count( &p_mlist->items ), EventWillHappen ); vlc_array_append( &p_mlist->items, p_md ); notify_item_addition( p_mlist, p_md, vlc_array_count( &p_mlist->items )-1, EventDidHappen );}/************************************************************************** * libvlc_media_list_insert_media (Public) * * Lock should be hold when entering. **************************************************************************/void libvlc_media_list_insert_media( libvlc_media_list_t * p_mlist, libvlc_media_t * p_md, int index, libvlc_exception_t * p_e ){ if( p_mlist->b_read_only ) { /* We are read only from user side */ libvlc_exception_raise( p_e, "Trying to write into a read-only media list." ); return; } _libvlc_media_list_insert_media( p_mlist, p_md, index, p_e );}/* LibVLC internal version */void _libvlc_media_list_insert_media( libvlc_media_list_t * p_mlist, libvlc_media_t * p_md, int index, libvlc_exception_t * p_e ){ (void)p_e; libvlc_media_retain( p_md ); notify_item_addition( p_mlist, p_md, index, EventWillHappen ); vlc_array_insert( &p_mlist->items, p_md, index ); notify_item_addition( p_mlist, p_md, index, EventDidHappen );}/************************************************************************** * libvlc_media_list_remove_index (Public) * * Lock should be hold when entering. **************************************************************************/void libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist, int index, libvlc_exception_t * p_e ){ if( p_mlist->b_read_only ) { /* We are read only from user side */ libvlc_exception_raise( p_e, "Trying to write into a read-only media list." ); return; } _libvlc_media_list_remove_index( p_mlist, index, p_e );}/* LibVLC internal version */void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist, int index, libvlc_exception_t * p_e ){ libvlc_media_t * p_md; if( index < 0 || index >= vlc_array_count( &p_mlist->items )) { libvlc_exception_raise( p_e, "Index out of bounds exception"); return; } p_md = vlc_array_item_at_index( &p_mlist->items, index ); notify_item_deletion( p_mlist, p_md, index, EventWillHappen ); vlc_array_remove( &p_mlist->items, index ); notify_item_deletion( p_mlist, p_md, index, EventDidHappen ); libvlc_media_release( p_md );}/************************************************************************** * libvlc_media_list_item_at_index (Public) * * Lock should be hold when entering. **************************************************************************/libvlc_media_t *libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist, int index, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( index < 0 || index >= vlc_array_count( &p_mlist->items )) { libvlc_exception_raise( p_e, "Index out of bounds exception"); return NULL; } libvlc_media_t * p_md; p_md = vlc_array_item_at_index( &p_mlist->items, index ); libvlc_media_retain( p_md ); return p_md;}/************************************************************************** * libvlc_media_list_index_of_item (Public) * * Lock should be hold when entering. * Warning: this function would return the first matching item **************************************************************************/int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist, libvlc_media_t * p_searched_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); libvlc_media_t * p_md; int i; for ( i = 0; i < vlc_array_count( &p_mlist->items ); i++ ) { p_md = vlc_array_item_at_index( &p_mlist->items, i ); if( p_searched_md == p_md ) return i; } return -1;}/************************************************************************** * libvlc_media_list_is_readonly (Public) * * This indicates if this media list is read-only from a user point of view **************************************************************************/int libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist ){ return p_mlist->b_read_only;}/************************************************************************** * libvlc_media_list_lock (Public) * * The lock must be held in access operations. It is never used in the * Public method. **************************************************************************/void libvlc_media_list_lock( libvlc_media_list_t * p_mlist ){ vlc_mutex_lock( &p_mlist->object_lock );}/************************************************************************** * libvlc_media_list_unlock (Public) * * The lock must be held in access operations **************************************************************************/void libvlc_media_list_unlock( libvlc_media_list_t * p_mlist ){ vlc_mutex_unlock( &p_mlist->object_lock );}/************************************************************************** * libvlc_media_list_p_event_manager (Public) * * The p_event_manager is immutable, so you don't have to hold the lock **************************************************************************/libvlc_event_manager_t *libvlc_media_list_event_manager( libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e ){ (void)p_e; return p_mlist->p_event_manager;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -