atrooney-online-2/include/aomusicplayer.h
Crystalwarrior 44a4a2d23e
Fix an issue where the Ambience layer would break looping points for all other channels due to loop_start and loop_end only being a single variable. (#164)
This occurs due to BASS not having any private variables of its own, so it was simply using the public variables loop_start and loop_end as reference - since those changed for any new song playing on another channel, the old looping points got replaced, and the seamless looping stops working.
The solution was easy - just make a  loop_start/loop_end variable for every supported channel - so 4 variables in our case.
2020-07-04 12:15:52 -05:00

56 lines
1.2 KiB
C++

#ifndef AOMUSICPLAYER_H
#define AOMUSICPLAYER_H
#include "file_functions.h"
#if defined(BASSAUDIO)
#include "bass.h"
#include "bassopus.h"
#elif defined(QTAUDIO)
#include <QMediaPlayer>
#endif
#include "aoapplication.h"
#include <QDebug>
#include <QWidget>
#include <string.h>
class AOMusicPlayer {
public:
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
virtual ~AOMusicPlayer();
void set_volume(int p_value, int channel = -1);
void set_looping(bool toggle, int channel = 0);
const int m_channelmax = 4;
// These have to be public for the stupid sync thing
int loop_start[4] = {0, 0, 0, 0};
int loop_end[4] = {0, 0, 0, 0};
public slots:
void play(QString p_song, int channel = 0, bool loop = false,
int effect_flags = 0);
void stop(int channel = 0);
private:
QWidget *m_parent;
AOApplication *ao_app;
bool m_looping = false;
int m_volume[4] = {0, 0, 0, 0};
// Channel 0 = music
// Channel 1 = ambience
// Channel 2 = extra
// Channel 3 = extra
#if defined(BASSAUDIO)
HSTREAM m_stream_list[4];
HSYNC loop_sync[4];
#elif defined(QTAUDIO)
QMediaPlayer m_stream_list[4];
#endif
};
#endif // AOMUSICPLAYER_H