[vlc-devel] Re: playlist API

Stephan Assmus stippi at yellowbites.com
Wed Jan 29 22:04:32 CET 2003


> On Wed, Jan 29, 2003, Stephan Assmus wrote:
> 
> > Here is my proposal for an easier but more powerful API:
> > 
> > playlist_item_t* playlist_ItemAt( int index );
> > int              playlist_AddItem( playlist_item_t* item, int index 
> > = - 1 );
> > int              playlist_RemoveItem( playlist_item_t* item );
> > playlist_item_t* playlist_RemoveItem( int index );
> 
>    Be careful that this is not enough. The current API sucks a lot, 
> but
> this is mainly due to locking (several threads may be accessing the
> playlist at the same time). I think your proposal needs at least two
> additional functions to work properly (playlist_Lock/
> playlist_Unlock).

Yes, I forgot about those, I implemented them in the BeOS code already.

> > This caused me troubles when 
> > trying to implement sorting. In my API, no function would do any 
> > allocating or freeing of the items. That would be left up to the 
> > caller.
> 
>    My opinion is that the caller should not necessarily know what is
> in p_item, which is a playlist's internal type, but still be able
> to delete items.

I agree to some extent, but there are times, when you need to reference 
the exact "object", read pointer, not the index. For example, it is 
hard to keep track of _what_ items to remove. In the list view of my 
interface, the user can select any items in the list. She can then 
start dragging, which will attach all selected items to the pointer. 
Then they can get dropped at any position. When detaching items from 
the playlist, it is tricky to do that just by using the indices of the 
selected items, since they might change as soon as you removed the 
first item from the list. Of course it is possible to compensate for 
that, but it gives me a headache and just removing the items by their 
pointers is much easier. Currently, I used void pointers and casting, 
which is less than ideal, but only theoretically.

> > The power in my API lies in the fact, that you can disconnect 
> > playlist items from the list and add them at another index.
> 
>    This could be done with a playlist_MoveItem function.

Maybe you need to detach more than one item before you can insert them 
again to keep things ordered. Again, headache alarm. However, 
MoveItems(int* indices, int count, int toIndex) might do it.

> > An additional playlist_DeleteItem() is still needed, and that 
> > function 
> > should also take care of actually stopping the playback if the 
> > deleted 
> > item happens to be the currently played item. Currently, 
> > playlist_Delete() does nothing in that regard.
> 
>    Hehe, my feeling was that the deleted item should continue 
> playing,
> but it can probably be made a config option :)

Why an option? Deleting is (contrary to removing/detaching) a 
destructive action, and it just feels right that vlc should take care 
of everything involving that.


Of course, I *could* go ahead and implement the API we just layed out 
as additional exported functions. Then everybody has time to switch to 
the new API and then we get rid of the old stuff.

Regards,
-Stephan

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the vlc-devel mailing list