forked from mia/Aegisub
Don't reuse buffers in the audio provider converters, as it isn't thread-safe to do so and making it thread-safe would hurt performance more than the extra allocations
Originally committed to SVN as r5800.
This commit is contained in:
parent
af3f160f43
commit
6315192e2b
1 changed files with 2 additions and 4 deletions
|
@ -49,7 +49,6 @@ public:
|
||||||
/// Anything -> 16 bit signed machine-endian audio converter
|
/// Anything -> 16 bit signed machine-endian audio converter
|
||||||
template<class Target>
|
template<class Target>
|
||||||
class BitdepthConvertAudioProvider : public AudioProviderConverter {
|
class BitdepthConvertAudioProvider : public AudioProviderConverter {
|
||||||
mutable std::vector<char> src_buf;
|
|
||||||
int src_bytes_per_sample;
|
int src_bytes_per_sample;
|
||||||
bool src_is_native_endian;
|
bool src_is_native_endian;
|
||||||
public:
|
public:
|
||||||
|
@ -63,7 +62,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAudio(void *buf, int64_t start, int64_t count) const {
|
void GetAudio(void *buf, int64_t start, int64_t count) const {
|
||||||
src_buf.resize(count * src_bytes_per_sample * channels);
|
std::vector<char> src_buf(count * src_bytes_per_sample * channels);
|
||||||
source->GetAudio(&src_buf[0], start, count);
|
source->GetAudio(&src_buf[0], start, count);
|
||||||
|
|
||||||
int16_t *dest = reinterpret_cast<int16_t*>(buf);
|
int16_t *dest = reinterpret_cast<int16_t*>(buf);
|
||||||
|
@ -106,7 +105,6 @@ public:
|
||||||
|
|
||||||
/// Non-mono 16-bit signed machine-endian -> mono 16-bit signed machine endian converter
|
/// Non-mono 16-bit signed machine-endian -> mono 16-bit signed machine endian converter
|
||||||
class DownmixAudioProvider : public AudioProviderConverter {
|
class DownmixAudioProvider : public AudioProviderConverter {
|
||||||
mutable std::vector<int16_t> src_buf;
|
|
||||||
int src_channels;
|
int src_channels;
|
||||||
public:
|
public:
|
||||||
DownmixAudioProvider(AudioProvider *src) : AudioProviderConverter(src) {
|
DownmixAudioProvider(AudioProvider *src) : AudioProviderConverter(src) {
|
||||||
|
@ -121,7 +119,7 @@ public:
|
||||||
void GetAudio(void *buf, int64_t start, int64_t count) const {
|
void GetAudio(void *buf, int64_t start, int64_t count) const {
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
src_buf.resize(count * src_channels);
|
std::vector<int16_t> src_buf(count * src_channels);
|
||||||
source->GetAudio(&src_buf[0], start, count);
|
source->GetAudio(&src_buf[0], start, count);
|
||||||
|
|
||||||
int16_t *dst = reinterpret_cast<int16_t*>(buf);
|
int16_t *dst = reinterpret_cast<int16_t*>(buf);
|
||||||
|
|
Loading…
Reference in a new issue