summaryrefslogtreecommitdiffstats
path: root/amarok/src/engine/helix/helix-engine.h
blob: e7282d3bdb5dd4df7591b85ec57f914be8e4ccb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/***************************************************************************
 *   Copyright (C) 2005-2006 Paul Cifarelli <paul@cifarelli.net>           *
 *                                                                         *
 *   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     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _HELIX_ENGINE_H_
#define _HELIX_ENGINE_H_

#include "enginebase.h"
#include <qobject.h>
#include <sys/types.h>
#include <hxplayercontrol.h>

class QStringList;
struct timeval;

class HelixEngine : public Engine::Base, public PlayerControl
{
   Q_OBJECT

public:
   HelixEngine();
   ~HelixEngine();

   virtual bool init();
   virtual bool canDecode( const KURL& ) const;
   virtual uint position() const;
   virtual uint length() const;
   virtual Engine::State state() const;

   virtual void play_finished(int playerIndex);
   virtual const Engine::Scope &scope();

   virtual Amarok::PluginConfig *configure() const;

   virtual void onContacting(const char *host);
   virtual void onBuffering(int pcnt);

   virtual int fallbackToOSS();

public slots:
   virtual bool load( const KURL &url, bool stream );
   virtual bool play( uint = 0 );
   virtual void stop();
   virtual void pause();
   virtual void unpause();
   virtual void seek( uint );

   virtual void setEqualizerEnabled( bool );
   virtual void setEqualizerParameters( int preamp, const QValueList<int>& );


protected:
   virtual void setVolumeSW( uint );

private:
   Engine::State m_state;
   KURL          m_url;

   QString      m_coredir;
   QString      m_pluginsdir;
   QString      m_codecsdir;
   bool         m_inited;

   int           m_numPlayers;
   int           m_current;  // the current player

   bool          m_isStream;
   HelixSimplePlayer::metaData m_md;

   int scope(int playerIndex);
   int prune();
   int prune(int playerIndex);
   bool m_scopeplayerlast;
   float m_sfps;
   struct timeval m_scopetm;
   unsigned long m_scopedelta;
   int   m_sframes;
   int   m_lframes;
   struct HelixScope
   {
      DelayQueue *m_item;
      unsigned long  m_lasttime;
      unsigned long  m_lastpos;
      unsigned short m_currentScope[SCOPESIZE];
      int            m_scopeindex;
      unsigned long  m_w; // more accurate position estimate for the player
   } hscope[2];

   typedef struct MimeEntry
   {
      QStringList type;
      QStringList ext;
   };

   std::vector<MimeEntry> m_mimes;

   struct FadeTrack
   {
      unsigned long m_startfadetime;
      bool m_fadeactive;
      bool m_stopfade;
   } m_pfade[2];

   void cleanup();
   void timerEvent( QTimerEvent * );
   void resetScope(int playerIndex);

   int print2stdout(const char *fmt, ...)
#ifdef __GNUC__
      __attribute__ ((format (printf, 2, 3)))
#endif
      ;
   int print2stderr(const char *fmt, ...)
#ifdef __GNUC__
      __attribute__ ((format (printf, 2, 3)))
#endif
      ;
   void notifyUser(unsigned long code, const char *moreinfo, const char *moreinfourl);
   void interruptUser(unsigned long code, const char *moreinfo, const char *moreinfourl);

   friend class HelixConfigDialogBase;
};


#endif