aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-11-04 16:10:54 +0300
committerCrystalwarrior <varsash@gmail.com>2019-11-04 16:10:54 +0300
commita49c4a503bcdfd09b9bbda3552e1598a4d147f40 (patch)
tree91bbf026ba3a68b70ff1815b3c43dce240458856 /src
parent963e32109503fe7bb83c5a4111913e1d489db608 (diff)
add .opus support
Diffstat (limited to 'src')
-rw-r--r--src/aoblipplayer.cpp7
-rw-r--r--src/aomusicplayer.cpp6
-rw-r--r--src/aosfxplayer.cpp5
3 files changed, 14 insertions, 4 deletions
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp
index 5f4dc6cc..4c7bf7b0 100644
--- a/src/aoblipplayer.cpp
+++ b/src/aoblipplayer.cpp
@@ -15,7 +15,10 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{
BASS_StreamFree(m_stream_list[n_stream]);
- m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
+ if (f_path.endsWith(".opus"))
+ m_stream_list[n_stream] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
+ else
+ m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
}
set_volume_internal(m_volume);
@@ -46,7 +49,7 @@ void AOBlipPlayer::set_volume(qreal p_value)
void AOBlipPlayer::set_volume_internal(qreal p_value)
{
- float volume = p_value;
+ float volume = static_cast<float>(p_value);
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp
index 49cf089c..9a96b3eb 100644
--- a/src/aomusicplayer.cpp
+++ b/src/aomusicplayer.cpp
@@ -26,7 +26,11 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop, int effect_flag
if (loop)
flags |= BASS_SAMPLE_LOOP;
- DWORD newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
+ DWORD newstream;
+ if (f_path.endsWith(".opus"))
+ newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
+ else
+ newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp
index cc019725..98496eaa 100644
--- a/src/aosfxplayer.cpp
+++ b/src/aosfxplayer.cpp
@@ -59,7 +59,10 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, int channel
if (!file_exists(f_path))
f_path = ao_app->get_sfx_suffix(f_path); //If we're not given a sound file with .wav/.ogg/.opus already there, let's do this thing
- m_stream_list[channel] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
+ if (f_path.endsWith(".opus"))
+ m_stream_list[channel] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
+ else
+ m_stream_list[channel] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
set_volume_internal(m_volume);