[Scummvm-cvs-logs] SF.net SVN: scummvm:[48231] scummvm/trunk/engines/scumm
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Mar 10 22:05:48 CET 2010
Revision: 48231
http://scummvm.svn.sourceforge.net/scummvm/?rev=48231&view=rev
Author: fingolfin
Date: 2010-03-10 21:05:48 +0000 (Wed, 10 Mar 2010)
Log Message:
-----------
Replace mutex_up/mutex_down methods by Common::StackLock
Modified Paths:
--------------
scummvm/trunk/engines/scumm/player_v1.cpp
scummvm/trunk/engines/scumm/player_v2.cpp
scummvm/trunk/engines/scumm/player_v2.h
scummvm/trunk/engines/scumm/player_v2cms.cpp
Modified: scummvm/trunk/engines/scumm/player_v1.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_v1.cpp 2010-03-10 21:03:50 UTC (rev 48230)
+++ scummvm/trunk/engines/scumm/player_v1.cpp 2010-03-10 21:05:48 UTC (rev 48231)
@@ -68,11 +68,11 @@
}
void Player_V1::startSound(int nr) {
+ Common::StackLock lock(_mutex);
+
byte *data = _vm->getResourceAddress(rtSound, nr);
assert(data);
- mutex_up();
-
int offset = _pcjr ? READ_LE_UINT16(data+4) : 6;
int cprio = _current_data ? *(_current_data) & 0x7f : 0;
int prio = *(data + offset) & 0x7f;
@@ -89,21 +89,21 @@
chainSound(nr, data + offset);
}
- mutex_down();
}
void Player_V1::stopAllSounds() {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
for (int i = 0; i < 4; i++)
clear_channel(i);
_repeat_chunk = _next_chunk = 0;
_next_nr = _current_nr = 0;
_next_data = _current_data = 0;
- mutex_down();
}
void Player_V1::stopSound(int nr) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
if (_next_nr == nr) {
_next_nr = 0;
_next_data = 0;
@@ -117,7 +117,6 @@
_current_data = 0;
chainNextSound();
}
- mutex_down();
}
void Player_V1::clear_channel(int i) {
Modified: scummvm/trunk/engines/scumm/player_v2.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_v2.cpp 2010-03-10 21:03:50 UTC (rev 48230)
+++ scummvm/trunk/engines/scumm/player_v2.cpp 2010-03-10 21:05:48 UTC (rev 48231)
@@ -370,13 +370,13 @@
}
Player_V2::~Player_V2() {
- mutex_up();
+ Common::StackLock lock(_mutex);
_mixer->stopHandle(_soundHandle);
- mutex_down();
}
void Player_V2::set_pcjr(bool pcjr) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
_pcjr = pcjr;
if (_pcjr) {
@@ -396,12 +396,9 @@
for (i = 0; (_sampleRate << i) < 30000; i++)
_decay = _decay * _decay / 65536;
-
_timer_output = 0;
for (i = 0; i < 4; i++)
_timer_count[i] = 0;
-
- mutex_down();
}
void Player_V2::setMusicVolume (int vol) {
@@ -452,17 +449,18 @@
}
void Player_V2::stopAllSounds() {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
for (int i = 0; i < 4; i++) {
clear_channel(i);
}
_next_nr = _current_nr = 0;
_next_data = _current_data = 0;
- mutex_down();
}
void Player_V2::stopSound(int nr) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
if (_next_nr == nr) {
_next_nr = 0;
_next_data = 0;
@@ -475,14 +473,13 @@
_current_data = 0;
chainNextSound();
}
- mutex_down();
}
void Player_V2::startSound(int nr) {
byte *data = _vm->getResourceAddress(rtSound, nr);
assert(data);
- mutex_up();
+ Common::StackLock lock(_mutex);
int cprio = _current_data ? *(_current_data + _header_len) : 0;
int prio = *(data + _header_len);
@@ -516,8 +513,6 @@
_next_nr = nr;
_next_data = data;
}
-
- mutex_down();
}
int Player_V2::getSoundStatus(int nr) const {
@@ -787,7 +782,8 @@
}
void Player_V2::do_mix(int16 *data, uint len) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
uint step;
do {
@@ -806,8 +802,6 @@
data += 2 * step;
_next_tick -= step << FIXP_SHIFT;
} while (len -= step);
-
- mutex_down();
}
void Player_V2::nextTick() {
@@ -957,12 +951,4 @@
lowPassFilter(data, len);
}
-void Player_V2::mutex_up() {
- _mutex.lock();
-}
-
-void Player_V2::mutex_down() {
- _mutex.unlock();
-}
-
} // End of namespace Scumm
Modified: scummvm/trunk/engines/scumm/player_v2.h
===================================================================
--- scummvm/trunk/engines/scumm/player_v2.h 2010-03-10 21:03:50 UTC (rev 48230)
+++ scummvm/trunk/engines/scumm/player_v2.h 2010-03-10 21:05:48 UTC (rev 48231)
@@ -119,6 +119,8 @@
byte *_next_data;
byte *_retaddr;
+ Common::Mutex _mutex;
+
private:
union ChannelInfo {
channel_data d;
@@ -131,13 +133,9 @@
const uint16 *_freqs_table;
- Common::Mutex _mutex;
ChannelInfo _channels[5];
protected:
- void mutex_up();
- void mutex_down();
-
virtual void nextTick();
virtual void clear_channel(int i);
virtual void chainSound(int nr, byte *data);
@@ -302,6 +300,8 @@
byte *_next_data;
byte *_retaddr;
+ Common::Mutex _mutex;
+
private:
union ChannelInfo {
channel_data d;
@@ -312,13 +312,9 @@
int _music_timer_ctr;
int _ticks_per_music_timer;
- Common::Mutex _mutex;
ChannelInfo _channels[5];
protected:
- void mutex_up();
- void mutex_down();
-
virtual void nextTick();
virtual void clear_channel(int i);
virtual void chainSound(int nr, byte *data);
Modified: scummvm/trunk/engines/scumm/player_v2cms.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_v2cms.cpp 2010-03-10 21:03:50 UTC (rev 48230)
+++ scummvm/trunk/engines/scumm/player_v2cms.cpp 2010-03-10 21:05:48 UTC (rev 48231)
@@ -895,10 +895,10 @@
}
Player_V2CMS::~Player_V2CMS() {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
_mixer->stopHandle(_soundHandle);
delete g_cmsEmu;
- mutex_down();
}
void Player_V2CMS::setMusicVolume(int vol) {
@@ -933,7 +933,8 @@
}
void Player_V2CMS::stopAllSounds() {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
for (int i = 0; i < 4; i++) {
clear_channel(i);
}
@@ -943,11 +944,11 @@
_midiSongBegin = 0;
_midiDelay = 0;
offAllChannels();
- mutex_down();
}
void Player_V2CMS::stopSound(int nr) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
if (_next_nr == nr) {
_next_nr = 0;
_next_data = 0;
@@ -966,20 +967,17 @@
_midiDelay = 0;
offAllChannels();
}
- mutex_down();
}
void Player_V2CMS::startSound(int nr) {
+ Common::StackLock lock(_mutex);
+
byte *data = _vm->getResourceAddress(rtSound, nr);
assert(data);
if (data[6] == 0x80) {
- mutex_up();
loadMidiData(data, nr);
- mutex_down();
} else {
- mutex_up();
-
int cprio = _current_data ? *(_current_data + _header_len) : 0;
int prio = *(data + _header_len);
int nprio = _next_data ? *(_next_data + _header_len) : 0;
@@ -1012,8 +1010,6 @@
_next_nr = nr;
_next_data = data;
}
-
- mutex_down();
}
}
@@ -1413,7 +1409,8 @@
}
int Player_V2CMS::readBuffer(int16 *buffer, const int numSamples) {
- mutex_up();
+ Common::StackLock lock(_mutex);
+
uint step = 1;
int len = numSamples/2;
@@ -1450,7 +1447,6 @@
_next_tick -= step << FIXP_SHIFT;
} while (len -= step);
- mutex_down();
return numSamples;
}
@@ -1843,11 +1839,4 @@
} while ((cmsPort & 2) == 0);
}
-void Player_V2CMS::mutex_up() {
- _mutex.lock();
-}
-
-void Player_V2CMS::mutex_down() {
- _mutex.unlock();
-}
} // End of namespace Scumm
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list