kwave  18.07.70
PlaybackController.h
Go to the documentation of this file.
1 /***************************************************************************
2  PlaybackController.h - Interface for generic playback control
3  -------------------
4  begin : Nov 15 2000
5  copyright : (C) 2000 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <Thomas.Eschenbacher@gmx.de>
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef PLAYBACK_CONTROLLER_H
19 #define PLAYBACK_CONTROLLER_H
20 
21 #include "config.h"
22 
23 #include <QtGlobal>
24 #include <QList>
25 #include <QMutex>
26 #include <QObject>
27 
28 #include "libkwave/PlayBackParam.h"
29 #include "libkwave/Runnable.h"
30 #include "libkwave/Sample.h"
31 #include "libkwave/WorkerThread.h"
32 
33 namespace Kwave
34 {
35 
36  class PlayBackDevice;
37  class PlaybackDeviceFactory;
38  class SignalManager;
39 
53  class Q_DECL_EXPORT PlaybackController: public QObject,
54  public Kwave::Runnable
55  {
56  Q_OBJECT
57 
58  public:
59 
61  explicit PlaybackController(Kwave::SignalManager &signal_manager);
62 
64  virtual ~PlaybackController() Q_DECL_OVERRIDE;
65 
66  public:
67 
69  void reset();
70 
72  bool loop() const;
73 
75  bool running() const;
76 
78  bool paused() const;
79 
81  void setStartPos(sample_index_t pos);
82 
84  void setEndPos(sample_index_t pos);
85 
87  sample_index_t startPos() const;
88 
90  sample_index_t endPos() const;
91 
93  sample_index_t currentPos() const;
94 
98  void registerPlaybackDeviceFactory(
100 
104  void unregisterPlaybackDeviceFactory(
106 
113  virtual Kwave::PlayBackDevice *createDevice(
114  Kwave::playback_method_t method);
115 
127  Kwave::PlayBackDevice *openDevice(int tracks,
128  const Kwave::PlayBackParam *playback_params);
129 
135  void setDefaultParams(const Kwave::PlayBackParam &params);
136 
142  void checkMethod(Kwave::playback_method_t &method);
143 
144  public slots:
145 
150  void playbackStart();
151 
157  void playbackLoop();
158 
164  void playbackPause();
165 
173  void playbackContinue();
174 
179  void playbackStop();
180 
185  void reload();
186 
188  void seekTo(sample_index_t pos);
189 
191  void seekDone(sample_index_t pos);
192 
194  void updatePlaybackPos(sample_index_t pos);
195 
197  void playbackDone();
198 
199  signals:
200 
204  void sigPlaybackStarted();
205 
209  void sigPlaybackPaused();
210 
214  void sigPlaybackStopped();
215 
219  void sigPlaybackPos(sample_index_t pos);
220 
224  void sigSeekDone(sample_index_t pos);
225 
229  void sigDevicePlaybackDone();
230 
232  void sigDevicePlaybackPos(sample_index_t pos);
233 
235  void sigDeviceSeekDone(sample_index_t pos);
236 
237  private slots:
238 
245  void closeDevice();
246 
248  void trackSelectionChanged();
249 
250  protected:
251 
253  virtual void run_wrapper(const QVariant &params) Q_DECL_OVERRIDE;
254 
255  private:
256 
258  void startDevicePlayBack();
259 
261  void stopDevicePlayBack();
262 
263  private:
264 
267 
272 
275 
278 
281 
287 
290 
293 
296 
304 
307 
309  bool m_paused;
310 
312  bool m_playing;
313 
316 
319 
322 
325 
328 
330  QList<Kwave::PlaybackDeviceFactory *> m_playback_factories;
331 
332  };
333 }
334 
335 #endif /* PLAYBACK_CONTROLLER_H */
336 
337 //***************************************************************************
338 //***************************************************************************
Kwave::SignalManager & m_signal_manager
Definition: App.h:33
QList< Kwave::PlaybackDeviceFactory * > m_playback_factories
playback_method_t
Definition: PlayBackParam.h:31
quint64 sample_index_t
Definition: Sample.h:28
Kwave::PlayBackDevice * m_device
Kwave::PlayBackParam m_playback_params
Kwave::WorkerThread m_thread