mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-20 16:59:06 +00:00
SCUMM: Fix race condition in MOD player
Fixes Trac#6272.
This commit is contained in:
parent
63b90d13e4
commit
0eda63bed1
@ -63,11 +63,13 @@ void Player_MOD::setMusicVolume(int vol) {
|
||||
}
|
||||
|
||||
void Player_MOD::setUpdateProc(ModUpdateProc *proc, void *param, int freq) {
|
||||
Common::StackLock lock(_mutex);
|
||||
_playproc = proc;
|
||||
_playparam = param;
|
||||
_mixamt = _sampleRate / freq;
|
||||
}
|
||||
void Player_MOD::clearUpdateProc() {
|
||||
Common::StackLock lock(_mutex);
|
||||
_playproc = NULL;
|
||||
_playparam = NULL;
|
||||
_mixamt = 0;
|
||||
@ -78,6 +80,7 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
|
||||
if (id == 0)
|
||||
error("player_mod - attempted to start channel id 0");
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
for (i = 0; i < MOD_MAXCHANS; i++) {
|
||||
if (!_channels[i].id)
|
||||
break;
|
||||
@ -106,6 +109,8 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
|
||||
void Player_MOD::stopChannel(int id) {
|
||||
if (id == 0)
|
||||
error("player_mod - attempted to stop channel id 0");
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
for (int i = 0; i < MOD_MAXCHANS; i++) {
|
||||
if (_channels[i].id == id) {
|
||||
delete _channels[i].input;
|
||||
@ -121,6 +126,8 @@ void Player_MOD::stopChannel(int id) {
|
||||
void Player_MOD::setChannelVol(int id, uint8 vol) {
|
||||
if (id == 0)
|
||||
error("player_mod - attempted to set volume for channel id 0");
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
for (int i = 0; i < MOD_MAXCHANS; i++) {
|
||||
if (_channels[i].id == id) {
|
||||
_channels[i].vol = vol;
|
||||
@ -132,6 +139,8 @@ void Player_MOD::setChannelVol(int id, uint8 vol) {
|
||||
void Player_MOD::setChannelPan(int id, int8 pan) {
|
||||
if (id == 0)
|
||||
error("player_mod - attempted to set pan for channel id 0");
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
for (int i = 0; i < MOD_MAXCHANS; i++) {
|
||||
if (_channels[i].id == id) {
|
||||
_channels[i].pan = pan;
|
||||
@ -143,6 +152,8 @@ void Player_MOD::setChannelPan(int id, int8 pan) {
|
||||
void Player_MOD::setChannelFreq(int id, int freq) {
|
||||
if (id == 0)
|
||||
error("player_mod - attempted to set frequency for channel id 0");
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
for (int i = 0; i < MOD_MAXCHANS; i++) {
|
||||
if (_channels[i].id == id) {
|
||||
if (freq > 31400) // this is about as high as WinUAE goes
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "scumm/scumm.h"
|
||||
#include "audio/audiostream.h"
|
||||
#include "audio/mixer.h"
|
||||
#include "common/mutex.h"
|
||||
|
||||
namespace Audio {
|
||||
class RateConverter;
|
||||
@ -55,6 +56,7 @@ public:
|
||||
|
||||
// AudioStream API
|
||||
int readBuffer(int16 *buffer, const int numSamples) {
|
||||
Common::StackLock lock(_mutex);
|
||||
do_mix(buffer, numSamples / 2);
|
||||
return numSamples;
|
||||
}
|
||||
@ -80,6 +82,7 @@ private:
|
||||
|
||||
Audio::Mixer *_mixer;
|
||||
Audio::SoundHandle _soundHandle;
|
||||
Common::Mutex _mutex;
|
||||
|
||||
uint32 _mixamt;
|
||||
uint32 _mixpos;
|
||||
|
Loading…
Reference in New Issue
Block a user