Sayonara Player
EngineHandler.h
1 /* EngineHandler.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef ENGINEHANDLER_H_
22 #define ENGINEHANDLER_H_
23 
24 #include "AbstractEngine.h"
25 #include "Components/PlayManager/PlayState.h"
26 #include "Utils/Singleton.h"
27 #include "Utils/Pimpl.h"
28 
29 #include <QList>
30 
31 #define EngineHandler_change_track_md static_cast<void (EngineHandler::*) (const MetaData& md)>(&EngineHandler::change_track)
32 
34 
35 namespace Engine
36 {
37  class Playback;
38 
43  class Handler :
44  public Base
45  {
46  Q_OBJECT
47  SINGLETON_QOBJECT(Handler)
48  PIMPL(Handler)
49 
50  public:
51  bool init() override;
52  void shutdown();
53 
54  Engine::Playback* get_playback_engine();
55 
56  void register_raw_sound_receiver(RawSoundReceiverInterface* receiver);
57  void unregister_raw_sound_receiver(RawSoundReceiverInterface* receiver);
58 
59  void start_convert();
60  void end_convert();
61 
62  void set_equalizer(int band, int value);
63 
64  bool change_track(const MetaData&) override;
65  bool change_track_by_filename(const QString&) override;
66 
67 
68  private slots:
69  void jump_abs_ms(MilliSeconds ms) override;
70  void jump_rel_ms(MilliSeconds ms) override;
71  void jump_rel(double where) override;
72 
73  void sl_md_changed(const MetaData&);
74  void sl_dur_changed(const MetaData&);
75  void sl_pos_changed_ms(MilliSeconds ms);
76  void sl_pos_changed_s(Seconds s);
77 
78  void sl_track_finished();
79 
80  void sl_track_ready_changed();
81  void sl_buffer_state_changed(int progress);
82 
83  void sl_error(const QString& error_msg);
84 
85  void sr_record_button_pressed(bool);
86  void playstate_changed(PlayState state);
87 
88  void new_data(const uchar* data, uint64_t n_bytes);
89 
90  void play() override;
91  void stop() override;
92  void pause() override;
93 
94  private:
95  Base* get_engine(Name name);
96  void switch_engine(Name name);
97 
98  bool configure_connections(Base* old_engine, Base* new_engine);
99 
100  // Engine interface
101  protected:
102  bool change_uri(char* uri) override;
103  };
104 }
105 #endif
106 
107 
PlayState
The PlayState enum.
Definition: PlayState.h:28
The MetaData class.
Definition: MetaData.h:48
Definition: AbstractEngine.h:33
The EngineHandler class.
Definition: EngineHandler.h:43
The PlaybackEngine class.
Definition: PlaybackEngine.h:50
The Engine class.
Definition: AbstractEngine.h:51
The RawSoundReceiver interface.
Definition: RawSoundReceiverInterface.h:30
Name
The EngineName enum.
Definition: AbstractEngine.h:39