Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Fix audio reproduction issue (863) in GNU/Linux

jabarrera7c1be800e990
diff --git a/toonz/sources/common/tsound/tsound_sdl.cpp b/toonz/sources/common/tsound/tsound_sdl.cpp
index 9756b3f0e..705f1e60a 100644
--- a/toonz/sources/common/tsound/tsound_sdl.cpp
+++ b/toonz/sources/common/tsound/tsound_sdl.cpp
@@ -89,11 +89,11 @@ public:
if (m_data->imp) {
if (m_data->m_doNotify == false) return;
m_data->m_doNotify = false;
- if (m_data->imp->m_isPlaying) m_data->imp->doStopDevice();
std::set<TSoundOutputDeviceListener *>::iterator it =
m_data->imp->m_listeners.begin();
for (; it != m_data->imp->m_listeners.end(); ++it)
(*it)->onPlayCompleted();
+ if (m_data->imp->m_isPlaying) m_data->imp->doStopDevice();
}
}
};
@@ -134,6 +134,11 @@ static void sdl_fill_audio(void *udata, Uint8 *stream, int len) {
/* Mix as much data as possible */
len = (len > audio_len ? audio_len : len);
+
+ // Mix with silence if we're not at full volume
+ if (_this->m_volume != SDL_MIX_MAXVOLUME) {
+ SDL_memset(stream, 0, len);
+ }
SDL_MixAudio(stream, (Uint8 *)myData->entireFileBuffer + myData->byteOffset,
len, _this->m_volume);
myData->byteOffset += len;