2024-05-11 19:47:13 +00:00
|
|
|
/*
|
|
|
|
* Descent 3
|
|
|
|
* Copyright (C) 2024 Descent Developers
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-07-07 01:28:57 +00:00
|
|
|
#ifndef LIBMVE_MOVIE_SOUND_H_
|
|
|
|
#define LIBMVE_MOVIE_SOUND_H_
|
2024-05-11 19:47:13 +00:00
|
|
|
|
|
|
|
#include <SDL_audio.h>
|
|
|
|
|
|
|
|
#include "sound_interface.h"
|
|
|
|
|
|
|
|
namespace D3 {
|
|
|
|
|
2024-07-07 14:04:10 +00:00
|
|
|
/// Implementation class for sound device used on movie playback.
|
2024-05-11 19:47:13 +00:00
|
|
|
class MovieSoundDevice : ISoundDevice {
|
|
|
|
private:
|
|
|
|
SDL_AudioDeviceID m_device_id = 0;
|
|
|
|
|
|
|
|
public:
|
2024-07-07 14:04:10 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
2024-05-11 19:47:13 +00:00
|
|
|
MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, uint32_t buf_size, bool is_compressed);
|
|
|
|
~MovieSoundDevice();
|
|
|
|
|
2024-07-07 14:04:10 +00:00
|
|
|
/**
|
|
|
|
* Check if sound device is properly initialized
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2024-07-01 00:59:23 +00:00
|
|
|
[[nodiscard]] bool IsInitialized() const { return m_device_id > 0; }
|
2024-05-11 19:47:13 +00:00
|
|
|
|
2024-07-07 14:04:10 +00:00
|
|
|
/**
|
2024-07-12 13:04:03 +00:00
|
|
|
* Fill internal audio stream to be played
|
|
|
|
* @param stream source buffer
|
|
|
|
* @param len length of source buffer
|
2024-07-07 14:04:10 +00:00
|
|
|
*/
|
2024-07-12 13:04:03 +00:00
|
|
|
void FillBuffer(char *stream, int len) const;
|
2024-05-11 19:47:13 +00:00
|
|
|
|
|
|
|
void Play() override;
|
|
|
|
void Stop() override;
|
|
|
|
void Lock() override;
|
|
|
|
void Unlock() override;
|
|
|
|
|
|
|
|
using ISoundDevice::IsCompressed;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-07-07 01:28:57 +00:00
|
|
|
#endif // LIBMVE_MOVIE_SOUND_H_
|