mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Documenting ISoundDevice classes
This commit is contained in:
parent
32df86203a
commit
ae279d1211
@ -25,16 +25,35 @@
|
||||
|
||||
namespace D3 {
|
||||
|
||||
/// Implementation class for sound device used on movie playback.
|
||||
class MovieSoundDevice : ISoundDevice {
|
||||
private:
|
||||
SDL_AudioDeviceID m_device_id = 0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initialize sound device
|
||||
* @param sample_rate sample rate in Hz (22050, 44100...)
|
||||
* @param sample_size sample size (8, 16)
|
||||
* @param channels count of channels (1 for mono, 2 for stereo)
|
||||
* @param buf_size buffer size for SDL audio device
|
||||
* @param is_compressed mark stream as compressed (on streaming will be used decompression functions)
|
||||
*/
|
||||
MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, uint32_t buf_size, bool is_compressed);
|
||||
~MovieSoundDevice();
|
||||
|
||||
/**
|
||||
* Check if sound device is properly initialized
|
||||
* @return true on success
|
||||
*/
|
||||
[[nodiscard]] bool IsInitialized() const { return m_device_id > 0; }
|
||||
|
||||
/**
|
||||
* Callback for filling SDL audio buffer
|
||||
* @param userdata pointer to instance of this class
|
||||
* @param stream stream that will be filled on callback
|
||||
* @param len length of stream
|
||||
*/
|
||||
void static SDLAudioCallback(void *userdata, unsigned char *stream, int len);
|
||||
|
||||
void Play() override;
|
||||
|
@ -25,19 +25,26 @@
|
||||
|
||||
namespace D3 {
|
||||
|
||||
/// Abstract class for sound device.
|
||||
class ISoundDevice {
|
||||
protected:
|
||||
std::unique_ptr<std::deque<int16_t>> m_sound_buffer;
|
||||
bool m_is_compressed = false;
|
||||
|
||||
public:
|
||||
ISoundDevice() { m_sound_buffer = std::make_unique<std::deque<int16_t>>(); };
|
||||
ISoundDevice() { this->m_sound_buffer = std::make_unique<std::deque<int16_t>>(); };
|
||||
/// Play stream
|
||||
virtual void Play() {};
|
||||
/// Stop stream
|
||||
virtual void Stop() {};
|
||||
/// Lock buffer for various atomic operations
|
||||
virtual void Lock() {};
|
||||
/// Unlock buffer
|
||||
virtual void Unlock() {};
|
||||
|
||||
/// Get access to sound buffer
|
||||
std::unique_ptr<std::deque<int16_t>> &GetBuffer() { return m_sound_buffer; }
|
||||
/// Check if encoded sound is compressed
|
||||
[[nodiscard]] bool IsCompressed() const { return m_is_compressed; };
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user