#ifndef AUDIO_S_HPP
#define AUDIO_S_HPP

#include "simplefile.hpp"
#include "player.hpp"

// overlay
#include "image.hpp"

#include <cc++/thread.h>

#ifdef use_imms
#include "library-builder/immsdb.h"
#include "library-builder/imms.h"
#endif

#include <string>
#include <stack>

class Audio_s
{
public:
  // common
  bool p_playing() const { return playing; }
  void set_playing(bool state) { playing = state; }

  bool p_pause() const { return paused; }
  void set_pause(bool state) { paused = state; }

  Player *p;

  // real random
  void remove_track_from_played(const Simplefile& e);
  void add_track_to_played(const Simplefile& e);
  Simplefile prev_track_played();

  // queue
  void add_track_to_queue(const Simplefile& e);
  void remove_track_from_queue(const Simplefile& e);
  Simplefile next_in_queue();
  int queue_size();
  int queue_pos(const Simplefile& s);
  void remove_queued_tracks();

#ifdef use_imms
  Imms *imms;
  std::string imms_cur_path;
#endif

  // real random
  enum real_random_state { ADDED, TAKEN };
  real_random_state direction;

  ~Audio_s();
  static Audio_s* get_instance();

  bool check_repeat();
  bool check_shutdown();
 
  Overlay playback;
  bool has_played;

  Overlay playback_fullscreen;
  bool playback_fullscreen_shown;

  bool fullscreen_info;

  Overlay volume;
  bool volume_shown;

  std::stack<Simplefile> played_tracks;
  void empty_played_tracks();

protected:
  Audio_s();
  
private:
  
  static Audio_s* instance;

  bool playing;
  
  bool paused;

  std::list<Simplefile> queued_tracks;
};
#endif
