From 47d8944d179c2686a31eea065338715a5f8a368f Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Sun, 5 Aug 2018 13:22:21 +0200 Subject: [PATCH] build 180805. minor bug fixes --- audiorenderer.cpp | 9 +++++++++ audiorenderer.h | 1 + driverkeyboardinput.cpp | 1 + drivermode.cpp | 2 +- editorkeyboardinput.cpp | 2 ++ keyboardinput.cpp | 10 +++++----- sound.cpp | 8 +++----- version.h | 2 +- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/audiorenderer.cpp b/audiorenderer.cpp index b29057a9..a9b66e47 100644 --- a/audiorenderer.cpp +++ b/audiorenderer.cpp @@ -44,10 +44,16 @@ openal_source::play() { ::alGetError(); // pop the error stack ::alSourcePlay( id ); + + ALint state; + ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + is_playing = ( state == AL_PLAYING ); +/* is_playing = ( ::alGetError() == AL_NO_ERROR ? true : false ); +*/ } // stops the playback @@ -78,14 +84,17 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity if( id != audio::null_resource ) { + sound_change = false; ::alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index ); // for multipart sounds trim away processed sources until only one remains, the last one may be set to looping by the controller + // TBD, TODO: instead of change flag move processed buffer ids to separate queue, for accurate tracking of longer buffer sequences ALuint bufferid; while( ( sound_index > 0 ) && ( sounds.size() > 1 ) ) { ::alSourceUnqueueBuffers( id, 1, &bufferid ); sounds.erase( std::begin( sounds ) ); --sound_index; + sound_change = true; } int state; diff --git a/audiorenderer.h b/audiorenderer.h index d0a89eb0..dbe95758 100644 --- a/audiorenderer.h +++ b/audiorenderer.h @@ -50,6 +50,7 @@ struct openal_source { uint32_sequence sounds; // // buffer_sequence buffers; // sequence of samples the source will emit int sound_index { 0 }; // currently queued sample from the buffer sequence + bool sound_change { false }; // indicates currently queued sample has changed bool is_playing { false }; bool is_looping { false }; sound_properties properties; diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 362c5467..5242d3dd 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -16,6 +16,7 @@ driverkeyboard_input::init() { default_bindings(); recall_bindings(); bind(); + m_bindingsetups.clear(); return true; } diff --git a/drivermode.cpp b/drivermode.cpp index 504934e7..0667f0a9 100644 --- a/drivermode.cpp +++ b/drivermode.cpp @@ -344,7 +344,7 @@ driver_mode::on_key( int const Key, int const Scancode, int const Action, int co } } - if( Action == GLFW_PRESS ) { + if( Action != GLFW_RELEASE ) { OnKeyDown( Key ); diff --git a/editorkeyboardinput.cpp b/editorkeyboardinput.cpp index 1934ffa7..0e88137a 100644 --- a/editorkeyboardinput.cpp +++ b/editorkeyboardinput.cpp @@ -17,6 +17,8 @@ editorkeyboard_input::init() { // TODO: re-enable after mode-specific binding import is in place // return recall_bindings(); bind(); + m_bindingsetups.clear(); + return true; } diff --git a/keyboardinput.cpp b/keyboardinput.cpp index 09f52b50..1e05bed8 100644 --- a/keyboardinput.cpp +++ b/keyboardinput.cpp @@ -87,7 +87,7 @@ keyboard_input::recall_bindings() { if( bindingkeyname == "shift" ) { binding |= keymodifier::shift; } else if( bindingkeyname == "ctrl" ) { binding |= keymodifier::control; } - else if( bindingkeyname == "none" ) { binding = -1; } + else if( bindingkeyname == "none" ) { binding = 0; } else { // regular key, convert it to glfw key code auto const keylookup = nametokeymap.find( bindingkeyname ); @@ -143,10 +143,10 @@ keyboard_input::key( int const Key, int const Action ) { true ); } + if( Key == -1 ) { return false; } + // store key state - if( Key != -1 ) { - input::keys[ Key ] = Action; - } + input::keys[ Key ] = Action; if( true == is_movement_key( Key ) ) { // if the received key was one of movement keys, it's been handled and we don't need to bother further @@ -187,7 +187,7 @@ keyboard_input::bind() { for( auto const &bindingsetup : m_bindingsetups ) { - m_bindings[ bindingsetup.binding ] = bindingsetup.command; + m_bindings[ bindingsetup.binding ] = bindingsetup.command; } // cache movement key bindings m_bindingscache.forward = binding( user_command::moveforward ); diff --git a/sound.cpp b/sound.cpp index 416cfdb9..0189721c 100644 --- a/sound.cpp +++ b/sound.cpp @@ -533,9 +533,8 @@ sound_source::update_basic( audio::openal_source &Source ) { if( sound( sound_id::begin ).buffer != null_handle ) { // potentially a multipart sound // detect the moment when the sound moves from startup sample to the main - if( ( false == Source.is_looping ) - && ( soundhandle == sound_id::main ) ) { - // when it happens update active sample counters, and activate the looping + if( true == Source.sound_change ) { + // when it happens update active sample counters, and potentially activate the looping update_counter( sound_id::begin, -1 ); update_counter( soundhandle, 1 ); Source.loop( TestFlag( m_flags, sound_flags::looping ) ); @@ -618,8 +617,7 @@ sound_source::update_combined( audio::openal_source &Source ) { if( sound( sound_id::begin ).buffer != null_handle ) { // potentially a multipart sound // detect the moment when the sound moves from startup sample to the main - if( ( false == Source.is_looping ) - && ( soundhandle == ( sound_id::chunk | 0 ) ) ) { + if( true == Source.sound_change ) { // when it happens update active sample counters, and activate the looping update_counter( sound_id::begin, -1 ); update_counter( soundhandle, 1 ); diff --git a/version.h b/version.h index af63ee2f..e33273e4 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 18 -#define VERSION_MINOR 804 +#define VERSION_MINOR 805 #define VERSION_REVISION 0