[Scummvm-git-logs] scummvm master -> b9a99a897d6e669c43b9faa39300db5a5efac118
dreammaster
paulfgilbert at gmail.com
Sun Dec 9 05:36:06 CET 2018
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
867adc6dca GLK: Sound volume and pausing methods
b9a99a897d GLK: Further fixes for Buildbot warnings
Commit: 867adc6dcac3969863f933435bf98012e52c90aa
https://github.com/scummvm/scummvm/commit/867adc6dcac3969863f933435bf98012e52c90aa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-12-08T20:22:31-08:00
Commit Message:
GLK: Sound volume and pausing methods
Changed paths:
engines/glk/glk_api.cpp
engines/glk/sound.cpp
engines/glk/sound.h
diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp
index 08dce8c..f638ea3 100644
--- a/engines/glk/glk_api.cpp
+++ b/engines/glk/glk_api.cpp
@@ -1022,7 +1022,11 @@ void GlkAPI::glk_schannel_stop(schanid_t chan) {
}
void GlkAPI::glk_schannel_set_volume(schanid_t chan, glui32 vol) {
- // TODO
+ if (chan) {
+ chan->setVolume(vol);
+ } else {
+ warning("schannel_set_volume: invalid ref");
+ }
}
void GlkAPI::glk_sound_load_hint(glui32 snd, glui32 flag) {
@@ -1041,16 +1045,28 @@ glui32 GlkAPI::glk_schannel_play_multi(schanid_t *chanarray, glui32 chancount,
}
void GlkAPI::glk_schannel_pause(schanid_t chan) {
- // TODO
+ if (chan) {
+ chan->pause();
+ } else {
+ warning("schannel_pause: invalid ref");
+ }
}
void GlkAPI::glk_schannel_unpause(schanid_t chan) {
- // TODO
+ if (chan) {
+ chan->unpause();
+ } else {
+ warning("schannel_unpause: invalid ref");
+ }
}
void GlkAPI::glk_schannel_set_volume_ext(schanid_t chan, glui32 vol,
glui32 duration, glui32 notify) {
- // TODO
+ if (chan) {
+ chan->setVolume(vol, duration, notify);
+ } else {
+ warning("schannel_set_volume_ext: invalid ref");
+ }
}
void GlkAPI::glk_set_hyperlink(glui32 linkval) {
diff --git a/engines/glk/sound.cpp b/engines/glk/sound.cpp
index 02fb7f9..0e3fbf4 100644
--- a/engines/glk/sound.cpp
+++ b/engines/glk/sound.cpp
@@ -144,10 +144,29 @@ void SoundChannel::stop() {
}
void SoundChannel::poll() {
- if (!g_vm->_mixer->isSoundHandleActive(_handle) && _notify != 0)
- g_vm->_events->store(evtype_SoundNotify, 0,
- _soundNum, _notify);
+ if (!g_vm->_mixer->isSoundHandleActive(_handle) && _notify != 0) {
+ glui32 notify = _notify;
+ _notify = 0;
+ g_vm->_events->store(evtype_SoundNotify, nullptr, _soundNum, notify);
+ }
+}
+
+void SoundChannel::setVolume(uint volume, uint duration, uint notify) {
+ uint newVol = volume * 255 / 0x10000;
+ g_vm->_mixer->setChannelVolume(_handle, newVol);
+
+ if (notify) {
+ warning("TODO: Gradual volume change");
+ g_vm->_events->store(evtype_VolumeNotify, nullptr, 0, notify);
+ }
+}
+
+void SoundChannel::pause() {
+ g_vm->_mixer->pauseHandle(_handle, true);
+}
+void SoundChannel::unpause() {
+ g_vm->_mixer->pauseHandle(_handle, false);
}
} // End of namespace Glk
diff --git a/engines/glk/sound.h b/engines/glk/sound.h
index 514a5f6..9635302 100644
--- a/engines/glk/sound.h
+++ b/engines/glk/sound.h
@@ -68,6 +68,25 @@ public:
* Poll for whether a playing sound was finished
*/
void poll();
+
+ /**
+ * Change the volume
+ * @param volume Volume from 0 (silence) to 0x10000 (full volume)
+ * @param duration Optional duration for a gradual volume change
+ * @param notify If non-zero, triggers a evtype_VolumeNotify when
+ * the volume change duration finishes
+ */
+ void setVolume(uint volume, uint duration = 0, uint notify = 0);
+
+ /**
+ * Pause playback
+ */
+ void pause();
+
+ /**
+ * Unpause playback
+ */
+ void unpause();
};
typedef SoundChannel *schanid_t;
Commit: b9a99a897d6e669c43b9faa39300db5a5efac118
https://github.com/scummvm/scummvm/commit/b9a99a897d6e669c43b9faa39300db5a5efac118
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-12-08T20:35:54-08:00
Commit Message:
GLK: Further fixes for Buildbot warnings
Changed paths:
engines/glk/conf.cpp
engines/glk/screen.cpp
engines/glk/sound.cpp
engines/glk/streams.cpp
diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp
index efd1687..0d2c33f 100644
--- a/engines/glk/conf.cpp
+++ b/engines/glk/conf.cpp
@@ -94,9 +94,9 @@ Conf::Conf(InterpreterType interpType) {
get("cols", _cols, 60);
if (ConfMan.hasKey("leading"))
- _leading = atof(ConfMan.get("leading").c_str()) + 0.5;
+ _leading = static_cast<int>(atof(ConfMan.get("leading").c_str()) + 0.5);
if (ConfMan.hasKey("baseline"))
- _baseLine = atof(ConfMan.get("baseline").c_str()) + 0.5;
+ _baseLine = static_cast<int>(atof(ConfMan.get("baseline").c_str()) + 0.5);
if (ConfMan.hasKey("minrows"))
_rows = MAX(_rows, strToInt(ConfMan.get("minrows").c_str()));
diff --git a/engines/glk/screen.cpp b/engines/glk/screen.cpp
index 6768360..2276998 100644
--- a/engines/glk/screen.cpp
+++ b/engines/glk/screen.cpp
@@ -48,8 +48,8 @@ void Screen::initialize() {
double baseLine = (double)r1.bottom;
double leading = (double)r2.bottom + 2;
- g_conf->_leading = MAX((double)g_conf->_leading, leading);
- g_conf->_baseLine = MAX((double)g_conf->_baseLine, baseLine);
+ g_conf->_leading = static_cast<int>(MAX((double)g_conf->_leading, leading));
+ g_conf->_baseLine = static_cast<int>(MAX((double)g_conf->_baseLine, baseLine));
g_conf->_cellW = _fonts[0]->getStringWidth("0");
g_conf->_cellH = g_conf->_leading;
}
@@ -157,7 +157,7 @@ const Graphics::Font *Screen::loadFont(FACES face, Common::Archive *archive, dou
if (!f.open(FILENAMES[face], *archive))
error("Could not load font");
- return Graphics::loadTTFFont(f, size, Graphics::kTTFSizeModeCharacter);
+ return Graphics::loadTTFFont(f, (int)size, Graphics::kTTFSizeModeCharacter);
}
FACES Screen::getFontId(const Common::String &name) {
diff --git a/engines/glk/sound.cpp b/engines/glk/sound.cpp
index 0e3fbf4..b2b0778 100644
--- a/engines/glk/sound.cpp
+++ b/engines/glk/sound.cpp
@@ -26,8 +26,8 @@
#include "common/file.h"
#include "audio/audiostream.h"
#include "audio/decoders/aiff.h"
-#include "audio/decoders/raw.h"
#include "audio/decoders/mp3.h"
+#include "audio/decoders/raw.h"
#include "audio/decoders/wave.h"
namespace Glk {
@@ -91,9 +91,11 @@ glui32 SoundChannel::play(glui32 soundNum, glui32 repeats, glui32 notify) {
Audio::AudioStream *stream;
Common::File f;
Common::String nameSnd = Common::String::format("sound%u.snd", soundNum);
- Common::String nameMp3 = Common::String::format("sound%u.mp3", soundNum);
Common::String nameWav = Common::String::format("sound%u.wav", soundNum);
Common::String nameAiff = Common::String::format("sound%u.aiff", soundNum);
+#ifdef USE_MAD
+ Common::String nameMp3 = Common::String::format("sound%u.mp3", soundNum);
+#endif
if (f.exists(nameSnd) && f.open(nameSnd)) {
if (f.readUint16BE() != (f.size() - 2))
@@ -107,10 +109,11 @@ glui32 SoundChannel::play(glui32 soundNum, glui32 repeats, glui32 notify) {
Common::SeekableReadStream *s = f.readStream(size);
stream = Audio::makeRawStream(s, freq, Audio::FLAG_UNSIGNED);
+#ifdef USE_MAD
} else if (f.exists(nameMp3) && f.open(nameMp3)) {
Common::SeekableReadStream *s = f.readStream(f.size());
stream = Audio::makeMP3Stream(s, DisposeAfterUse::YES);
-
+#endif
} else if (f.exists(nameWav) && f.open(nameWav)) {
Common::SeekableReadStream *s = f.readStream(f.size());
stream = Audio::makeWAVStream(s, DisposeAfterUse::YES);
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index d6c71ca..42aa790 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -469,8 +469,10 @@ void MemoryStream::setPosition(glsi32 pos, glui32 seekMode) {
pos = ((unsigned char *)_bufPtr - (unsigned char *)_buf) + pos;
else if (seekMode == seekmode_End)
pos = ((unsigned char *)_bufEof - (unsigned char *)_buf) + pos;
- else
- /* pos = pos */;
+ else {
+ // pos = pos
+ }
+
if (pos < 0)
pos = 0;
if (pos > ((unsigned char *)_bufEof - (unsigned char *)_buf))
More information about the Scummvm-git-logs
mailing list