#ifndef __PLAYLIST_H__
#define __PLAYLIST_H__

#include "../mecha/mecha.h"

#include "file_entry.h"

#define PLAYLIST_TYPE_ORDER		0x001 /* playlist is played in order (from filelist) */
#define PLAYLIST_TYPE_RANDOM		0x002 /* playlist is played completely randomly (with possible duplicates) */
#define PLAYLIST_TYPE_RANDOMLIST	0x004 /* playlist is played randomly without duplicates */
#define PLAYLIST_TYPE_RANDOMWEIGHTED	0x008 /* playlist is played randomly with weighting (with possible duplicates) */
#define PLAYLIST_TYPE_QUEUE		0x010 /* playlist is played once - files removed after playing */

#define PLAYLIST_OPTION_FILEBASED	0x020 /* playlist is attached to a file */
#define PLAYLIST_OPTION_MEMORYBASED	0x040 /* playlist is attached to a file */

typedef struct
{
   char *name;

   int  type;
   int  options;

   int  offset;
   int  len;
   FileEntry    **list;
   
   lstTlist *filelist;
} playlist;

typedef struct
{
   char *name;

   int  type;

   FileEntry * (*get_next) (playlist *);
   int (*add_file) (playlist *, FileEntry *file);
   int (*remove_file) (playlist *, const char *filename);
   int (*set_to_filelist) (playlist *, const char *file);
   int (*peek) (int num_entries, int *out_num_entries, lstTlist **out_entries);

} playlist_engine;

void playlist_init (void);
void playlist_destroy (void *ptr);

void playlist_engine_destroy (void *ptr);

FileEntry * playlist_get_next (void);

int playlist_create (const char *name, const char *type);
int playlist_delete (const char *name);

int playlist_add_file (const char *playlistname, const char *file);
int playlist_add_fileglob (const char *playlistname, const char *file);
int playlist_add_filelist (const char *playlistname, const char *file);

int playlist_reload_filelist (const char *playlistname, const char *file);

#endif
