/*****************************************************************************
* media_list.c: libvlc new API media list functions
*****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
EventDidHappen
} EventPlaceInTime;
-//#define DEBUG_MEDIA_LIST
-
-#ifdef DEBUG_MEDIA_LIST
-# define trace( fmt, ... ) printf( "%s(): " fmt, __FUNCTION__, ##__VA_ARGS__ )
-#else
-# define trace( ... )
-#endif
-
/*
* Private functions
*/
/* Construct the event */
if( event_status == EventDidHappen )
{
- trace("item was added at index %d\n", index);
event.type = libvlc_MediaListItemAdded;
event.u.media_list_item_added.item = p_md;
event.u.media_list_item_added.index = index;
/* Construct the event */
if( event_status == EventDidHappen )
{
- trace("item at index %d was deleted\n", index);
event.type = libvlc_MediaListItemDeleted;
event.u.media_list_item_deleted.item = p_md;
event.u.media_list_item_deleted.index = index;
libvlc_event_send( p_mlist->p_event_manager, &event );
}
+/* LibVLC internal */
+void libvlc_media_list_internal_end_reached( libvlc_media_list_t * p_mlist )
+{
+ libvlc_event_t event;
+
+ event.type = libvlc_MediaListEndReached;
+
+ /* Send the event */
+ libvlc_event_send( p_mlist->p_event_manager, &event );
+}
+
/**************************************************************************
* static mlist_is_writable (private)
**************************************************************************/
return NULL;
}
- /* Code for that one should be handled in flat_media_list.c */
- p_mlist->p_flat_mlist = NULL;
p_mlist->b_read_only = false;
libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
libvlc_MediaListItemDeleted );
libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
libvlc_MediaListWillDeleteItem );
+ libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
+ libvlc_MediaListEndReached );
vlc_mutex_init( &p_mlist->object_lock );
vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?
assert( p_mlist->items.i_count == 0 );
p_mlist->i_refcount = 1;
p_mlist->p_md = NULL;
+ p_mlist->p_internal_md = NULL;
return p_mlist;
}
}
vlc_mutex_destroy( &p_mlist->object_lock );
+ vlc_mutex_destroy( &p_mlist->refcount_lock );
vlc_array_clear( &p_mlist->items );
free( p_mlist );
{
vlc_mutex_lock( &p_mlist->object_lock );
+ if( p_mlist->p_internal_md || !mlist_is_writable(p_mlist) )
+ {
+ vlc_mutex_unlock( &p_mlist->object_lock );
+ return;
+ }
libvlc_media_release( p_mlist->p_md );
libvlc_media_retain( p_md );
p_mlist->p_md = p_md;
libvlc_media_t *p_md;
vlc_mutex_lock( &p_mlist->object_lock );
- p_md = p_mlist->p_md;
+ p_md = p_mlist->p_internal_md ? p_mlist->p_internal_md : p_mlist->p_md;
if( p_md )
libvlc_media_retain( p_md );
vlc_mutex_unlock( &p_mlist->object_lock );
{
if( !mlist_is_writable(p_mlist) )
return -1;
- _libvlc_media_list_add_media( p_mlist, p_md );
+ libvlc_media_list_internal_add_media( p_mlist, p_md );
return 0;
}
/* LibVLC internal version */
-void _libvlc_media_list_add_media( libvlc_media_list_t * p_mlist,
- libvlc_media_t * p_md )
+void libvlc_media_list_internal_add_media( libvlc_media_list_t * p_mlist,
+ libvlc_media_t * p_md )
{
libvlc_media_retain( p_md );
{
if( !mlist_is_writable(p_mlist) )
return -1;
- _libvlc_media_list_insert_media( p_mlist, p_md, index );
+ libvlc_media_list_internal_insert_media( p_mlist, p_md, index );
return 0;
}
/* LibVLC internal version */
-void _libvlc_media_list_insert_media(
- libvlc_media_list_t * p_mlist,
- libvlc_media_t * p_md,
- int index )
+void libvlc_media_list_internal_insert_media( libvlc_media_list_t * p_mlist,
+ libvlc_media_t * p_md,
+ int index )
{
libvlc_media_retain( p_md );
{
if( !mlist_is_writable(p_mlist) )
return -1;
- return _libvlc_media_list_remove_index( p_mlist, index );
+ return libvlc_media_list_internal_remove_index( p_mlist, index );
}
/* LibVLC internal version */
-int _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
- int index )
+int libvlc_media_list_internal_remove_index( libvlc_media_list_t * p_mlist,
+ int index )
{
libvlc_media_t * p_md;