mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 19:55:23 +00:00
Merge pull request #552 from winterheart/mve-pipewire
Fix audio distortions on MVE playback with pipewire backend
This commit is contained in:
commit
9df3316bd9
@ -16,21 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
#include "movie_sound.h"
|
||||
|
||||
namespace D3 {
|
||||
|
||||
MovieSoundDevice::MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, uint32_t buf_size,
|
||||
bool is_compressed) {
|
||||
SDL_AudioFormat format = (sample_size == 2) ? AUDIO_S16LSB : AUDIO_U8;
|
||||
SDL_AudioSpec spec;
|
||||
MovieSoundDevice::MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, bool is_compressed) {
|
||||
SDL_AudioSpec spec{};
|
||||
spec.freq = sample_rate;
|
||||
spec.format = format;
|
||||
spec.format = (sample_size == 2) ? AUDIO_S16LSB : AUDIO_U8;
|
||||
spec.channels = channels;
|
||||
spec.size = buf_size;
|
||||
spec.callback = nullptr;
|
||||
spec.userdata = this;
|
||||
|
||||
m_device_id = SDL_OpenAudioDevice(nullptr, 0, &spec, nullptr, 0);
|
||||
m_is_compressed = is_compressed;
|
||||
|
@ -37,11 +37,10 @@ public:
|
||||
* @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();
|
||||
MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, bool is_compressed);
|
||||
~MovieSoundDevice() override;
|
||||
|
||||
/**
|
||||
* Check if sound device is properly initialized
|
||||
|
@ -184,7 +184,7 @@ static int create_audiobuf_handler(unsigned char major, unsigned char minor, uns
|
||||
is_compressed = true;
|
||||
}
|
||||
|
||||
snd_ds = std::make_unique<D3::MovieSoundDevice>(sample_rate, sample_size, channels, 4096, is_compressed);
|
||||
snd_ds = std::make_unique<D3::MovieSoundDevice>(sample_rate, sample_size, channels, is_compressed);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
@ -29,6 +29,8 @@ protected:
|
||||
bool m_is_compressed = false;
|
||||
|
||||
public:
|
||||
virtual ~ISoundDevice() = default;
|
||||
|
||||
/// Play stream
|
||||
virtual void Play() {};
|
||||
/// Stop stream
|
||||
|
Loading…
Reference in New Issue
Block a user