aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-11-24 20:30:37 -0800
committerPaul Gilbert2019-11-24 20:30:43 -0800
commitc57e8f14a7aad289c18bd879182e468c78570321 (patch)
treee7fbc28949b75324785af9ef9f4f440221a98791 /engines/glk
parent574db58b270f8a22cde48a89a5b858b64d7b3cf1 (diff)
downloadscummvm-rg350-c57e8f14a7aad289c18bd879182e468c78570321.tar.gz
scummvm-rg350-c57e8f14a7aad289c18bd879182e468c78570321.tar.bz2
scummvm-rg350-c57e8f14a7aad289c18bd879182e468c78570321.zip
GLK: Implement glk_schannel_create_ext
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/glk_api.cpp9
-rw-r--r--engines/glk/sound.cpp15
-rw-r--r--engines/glk/sound.h7
3 files changed, 18 insertions, 13 deletions
diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp
index ba05988e86..803e85818e 100644
--- a/engines/glk/glk_api.cpp
+++ b/engines/glk/glk_api.cpp
@@ -132,6 +132,7 @@ uint GlkAPI::glk_gestalt_ext(uint id, uint val, uint *arr, uint arrlen) {
return false;
case gestalt_Sound:
+ case gestalt_Sound2:
case gestalt_SoundVolume:
case gestalt_SoundMusic:
case gestalt_SoundNotify:
@@ -151,7 +152,6 @@ uint GlkAPI::glk_gestalt_ext(uint id, uint val, uint *arr, uint arrlen) {
case gestalt_GarglkText:
return true;
- case gestalt_Sound2:
default:
return false;
}
@@ -998,7 +998,7 @@ void GlkAPI::glk_window_set_background_color(winid_t win, uint color) {
}
schanid_t GlkAPI::glk_schannel_create(uint rock) {
- return _sounds->create(rock);
+ return _sounds->create(rock, GLK_MAXVOLUME);
}
void GlkAPI::glk_schannel_destroy(schanid_t chan) {
@@ -1060,9 +1060,8 @@ void GlkAPI::glk_sound_load_hint(uint snd, uint flag) {
// No implementation
}
-schanid_t GlkAPI::glk_schannel_create_ext(uint rock, uint volume) {
- // No implementation
- return nullptr;
+schanid_t GlkAPI::glk_schannel_create_ext(glui32 rock, glui32 volume) {
+ return _sounds->create(rock, volume);
}
uint GlkAPI::glk_schannel_play_multi(schanid_t *chanarray, uint chancount,
diff --git a/engines/glk/sound.cpp b/engines/glk/sound.cpp
index 4f56ee2add..2c8bf319fa 100644
--- a/engines/glk/sound.cpp
+++ b/engines/glk/sound.cpp
@@ -46,8 +46,8 @@ void Sounds::removeSound(schanid_t snd) {
}
}
-schanid_t Sounds::create(uint rock) {
- schanid_t snd = new SoundChannel(this);
+schanid_t Sounds::create(uint rock, uint volume) {
+ schanid_t snd = new SoundChannel(this, volume);
_sounds.push_back(snd);
return snd;
}
@@ -73,8 +73,10 @@ void Sounds::poll() {
/*--------------------------------------------------------------------------*/
-SoundChannel::SoundChannel(Sounds *owner) : _owner(owner), _soundNum(0),
- _rock(0), _notify(0) {
+SoundChannel::SoundChannel(Sounds *owner, uint volume) : _owner(owner),
+ _soundNum(0), _rock(0), _notify(0) {
+ _defaultVolume = MIN(volume, (uint)GLK_MAXVOLUME);
+
if (g_vm->gli_register_obj)
_dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Schannel);
}
@@ -145,7 +147,8 @@ uint SoundChannel::play(uint soundNum, uint repeats, uint notify) {
}
// Start playing the audio
- g_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream);
+ g_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1,
+ _defaultVolume * 255 / GLK_MAXVOLUME);
return 0;
}
@@ -162,7 +165,7 @@ void SoundChannel::poll() {
}
void SoundChannel::setVolume(uint volume, uint duration, uint notify) {
- uint newVol = volume * 255 / 0x10000;
+ uint newVol = volume * 255 / GLK_MAXVOLUME;
g_vm->_mixer->setChannelVolume(_handle, newVol);
if (notify) {
diff --git a/engines/glk/sound.h b/engines/glk/sound.h
index 251c75a2fe..0c2f0b0236 100644
--- a/engines/glk/sound.h
+++ b/engines/glk/sound.h
@@ -30,6 +30,8 @@
namespace Glk {
+#define GLK_MAXVOLUME 0x10000
+
class Sounds;
/**
@@ -41,6 +43,7 @@ private:
uint _soundNum;
uint _notify;
Audio::SoundHandle _handle;
+ uint _defaultVolume;
public:
uint _rock;
gidispatch_rock_t _dispRock;
@@ -48,7 +51,7 @@ public:
/**
* Constructor
*/
- SoundChannel(Sounds *owner);
+ SoundChannel(Sounds *owner, uint volume);
/**
* Destructor
@@ -109,7 +112,7 @@ public:
/**
* Create a new channel
*/
- schanid_t create(uint rock = 0);
+ schanid_t create(uint rock = 0, uint volume = GLK_MAXVOLUME);
/**
* Used to iterate over the current list of sound channels