summaryrefslogtreecommitdiff
path: root/games-strategy/s25rttr/files/s25rttr-0.9.1-libsamplerate.patch
blob: 41d6d90e5fd8fc27494e4f62f2d04fc29f178bfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 16cb06c99f78a21b1be2bc681c1f1d85a6caddca Mon Sep 17 00:00:00 2001
From: James Le Cuirot <chewi@gentoo.org>
Date: Fri, 10 Sep 2021 22:59:51 +0100
Subject: [PATCH] Fix bad channel count handling with libsamplerate 0.2.0

Since libsndfile/libsamplerate@26d92c369394bcd0b0cea488890edce1a0d757d5,
initialising libsamplerate with 0 channels or less causes a SIGABRT. We
therefore need to handle this in the C++ wrapper classes.
---
 libs/libsamplerate/include/samplerate.hpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libs/libsamplerate/include/samplerate.hpp b/libs/libsamplerate/include/samplerate.hpp
index d0af34317..23e243d91 100644
--- a/libs/libsamplerate/include/samplerate.hpp
+++ b/libs/libsamplerate/include/samplerate.hpp
@@ -152,6 +152,8 @@ class State : public detail::StateBase
 {
     static SRC_STATE* createOrThrow(Converter converter, int channels)
     {
+        if (channels <= 0)
+            throw std::runtime_error("Channel count must be >= 1.");
         int error;
         auto* state = src_new(static_cast<int>(converter), channels, &error);
         if(!state)
@@ -174,6 +176,8 @@ class StateCallback : public detail::StateBase
 {
     static SRC_STATE* createOrThrow(Converter converter, int channels, src_callback_t func, void* data)
     {
+        if (channels <= 0)
+            throw std::runtime_error("Channel count must be >= 1.");
         int error;
         auto* state = src_callback_new(func, static_cast<int>(converter), channels, &error, data);
         if(!state)
-- 
2.32.0