diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-03-24 02:56:23 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-03-29 22:22:25 +0000 |
| commit | 3f6fb17deddd1b366d16db5a2531c82407ced9db (patch) | |
| tree | 5dd78ee66a67398274d08f598b79f8b663791c1f /src/aoapplication.h | |
| parent | 8475cfb7ac19f8698d2b96a0367f4735a016c375 (diff) | |
Rewrite audio engine: replace BASS with miniaudio
SFX and blip players largely remain the same.
For the music player, we now have to implement network streaming
natively, we no longer have a convenient function that did everything
for us. I introduced QNetworkRequest to download the stream in memory
and signal when it's ready to be decoded and played back. The size is
guarded to prevent the client from accidentally downloading terabytes of
audio.
Delete QFutureWatcher, we no longer need it for concurrency. miniaudio
uses a separate audio thread. Network donwloads and communication with
the track name display are handled by Qt signals.
Also, delete an odd "music.txt" feature. Its purpose was specifying
offsets for loops in a text file per track, but it remained obscure and
unused in practice.
Unsupported:
- Large streams, including unbounded ones (radio). We'll need a ring
buffer for that, and a mechanism to write to it from the network and
feed it to the audio thread.
- Effect flags: fade in, fade out, sync pos. Ignored.
- Audio device selection.
Diffstat (limited to 'src/aoapplication.h')
| -rw-r--r-- | src/aoapplication.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/aoapplication.h b/src/aoapplication.h index 5e67fc8..3773f16 100644 --- a/src/aoapplication.h +++ b/src/aoapplication.h @@ -7,7 +7,9 @@ #include "serverdata.h" #include "widgets/aooptionsdialog.h" -#include <bass.h> +#include "miniaudio.h" +#include "miniaudio_libvorbis.h" +#include "miniaudio_libopus.h" #include <QColor> #include <QCryptographicHash> @@ -330,19 +332,22 @@ public: bool pointExistsOnScreen(QPoint point); void centerOrMoveWidgetOnPrimaryScreen(QWidget *widget); - void initBASS(); - static void load_bass_plugins(); - static void CALLBACK BASSreset(HSTREAM handle, DWORD channel, DWORD data, void *user); - static void doBASSreset(); + void initAudio(); QElapsedTimer demo_timer; DemoServer *demo_server = nullptr; + ma_engine audio_engine; + // Vorbis and Opus decoders. + ma_decoding_backend_vtable *mus_decoders[2]; + ma_decoder_config mus_decoder_config; + private: QVector<ServerInfo> server_list; QHash<size_t, QString> asset_lookup_cache; QHash<size_t, QString> dir_listing_cache; QSet<size_t> dir_listing_exist_cache; + ma_resource_manager audio_rm; public Q_SLOTS: void server_connected(); |
