aboutsummaryrefslogtreecommitdiff
path: root/src/aomusicplayer.h
blob: 707d64ad33f452d9e59b89a7ae2aed747c4263ff (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
#pragma once

#include "aoapplication.h"

#include <QFutureWatcher>

class AOMusicPlayer
{
public:
  // 0 = music
  // 1 = ambience
  static constexpr int STREAM_COUNT = 2;

  explicit AOMusicPlayer(AOApplication *ao_app);
  virtual ~AOMusicPlayer();

  void setMuted(bool enabled);

  QString playStream(QString song, int streamId, bool loopEnabled, int effectFlags);

  void setStreamVolume(int value, int streamId);
  void setStreamLooping(bool enabled, int streamId);

  QFutureWatcher<QString> m_watcher;

private:
  AOApplication *ao_app;

  bool m_muted = false;

  int m_volume[STREAM_COUNT]{};
  HSTREAM m_stream_list[STREAM_COUNT]{};
  HSYNC m_loop_sync[STREAM_COUNT]{};
  quint32 m_loop_start[STREAM_COUNT]{};
  quint32 m_loop_end[STREAM_COUNT]{};

  bool ensureValidStreamId(int streamId);
};