/*
 * audio_playlist.h: The audio playlist interface
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: audio_playlist.h,v 1.11 2005/10/26 19:04:53 cm Exp $
 */

#ifndef __AUDIOPLAYLIST_H
#define __AUDIOPLAYLIST_H

#include <stdint.h>
#include <vdr/thread.h>
#include "daap_database.h"

class cAudioTune {
  public:
    cAudioTune();
    virtual ~cAudioTune();
    // returns the pointer to & length of the data block
    virtual const cMediaDatabaseBlob *GetData(void) const = 0;
    // returns the number of channels
    virtual int GetChannels(void) const = 0;
    // returns the sample rate
    virtual int GetSampleRate(void) const = 0;
    // returns the bit rate
    virtual short GetBitRate(void) const = 0;
    // returns the data format
    virtual const char *GetFormat(void) const = 0;
    // returns the song time
    virtual int GetTime(void) const = 0; 
};

class cAudioTunePreloader : public cThread {
  private:
    bool m_ready;
    int m_numOfGets;
    cAudioTune *mpo_tune;
    const cMediaDatabaseBlob *mpo_blob;
    void Action(void);
  public:
    cAudioTunePreloader();
    virtual ~cAudioTunePreloader();
    void Clear(void);
    void SetItem(cAudioTune *tune);
    bool isEmpty(void) const { return NULL == mpo_tune; };
    bool isReady(void) const { return m_ready; };
    const cMediaDatabaseBlob *GetData(void) ;
};

class cAudioPlaylist {
  protected:
    bool m_lock;
    int m_currentItem;
  public:
    cAudioPlaylist();
    virtual ~cAudioPlaylist();
    virtual cAudioTune *Item(unsigned int index) = 0;
    virtual int Count(void) = 0;
    virtual cAudioTune *Current(void) = 0;
    virtual int SetCurrent(int current) = 0;
    virtual int GetCurrent(void) const { return m_currentItem; };
    // (un)locks the playlist from the start up to the current track
    virtual bool Lock(void) = 0;
    virtual bool Unlock(void) = 0;
    virtual bool isLocked(void) const { return m_lock; };
};

#endif
