80bffc0fdd
Add Database class with SQLite fetch/fetchAlbum methods. Refactor PlaybackEngine (data callback, seek, getPosition, decoder lifecycle) and Player API (PlaybackEngine member, queue handling, PlayerLocal). Update Metadata::Track fields to include artist/title/album/trackNr/length.
45 lines
963 B
C++
45 lines
963 B
C++
#pragma once
|
|
|
|
#include "miniaudio.h"
|
|
|
|
#include <atomic>
|
|
#include <memory>
|
|
|
|
struct PlaybackState {
|
|
ma_decoder decoder {};
|
|
std::atomic<bool> finished { false };
|
|
};
|
|
|
|
class PlaybackEngine {
|
|
public:
|
|
PlaybackEngine ();
|
|
~PlaybackEngine ();
|
|
|
|
static void data_callback ( ma_device *pDevice, void *pOutput, const void *, ma_uint32 frameCount );
|
|
void configureDevice ();
|
|
void configureDecoder ();
|
|
void initDevice ();
|
|
void initDecoder ( const char *filePath );
|
|
void uninitDecoder();
|
|
|
|
void startPlayback ();
|
|
void stopPlayback ();
|
|
void pausePlayback () { stopPlayback(); };
|
|
void seek ( ma_uint64 frame );
|
|
int isFinished () const;
|
|
|
|
ma_uint64 getPosition ();
|
|
|
|
private:
|
|
ma_device device_;
|
|
ma_format format_;
|
|
unsigned int channels_;
|
|
unsigned int sampleRate_;
|
|
PlaybackState state;
|
|
|
|
ma_uint64 cursor_;
|
|
// config
|
|
ma_decoder_config decoderConfig;
|
|
ma_device_config deviceConfig;
|
|
};
|