[Scummvm-git-logs] scummvm master -> c57e8f14a7aad289c18bd879182e468c78570321

dreammaster paulfgilbert at gmail.com
Mon Nov 25 04:34:34 UTC 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c57e8f14a7 GLK: Implement glk_schannel_create_ext


Commit: c57e8f14a7aad289c18bd879182e468c78570321
    https://github.com/scummvm/scummvm/commit/c57e8f14a7aad289c18bd879182e468c78570321
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-11-24T20:30:43-08:00

Commit Message:
GLK: Implement glk_schannel_create_ext

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 ba05988..803e858 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 4f56ee2..2c8bf31 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 251c75a..0c2f0b0 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




More information about the Scummvm-git-logs mailing list