1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Corrects fullscreen switch.

This commit is contained in:
Thomas Harte 2020-02-16 19:07:13 -05:00
parent 1e4356f83a
commit 01a883e669
2 changed files with 17 additions and 18 deletions

View File

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

View File

@ -168,12 +168,12 @@ struct MachineRunner {
struct SpeakerDelegate: public Outputs::Speaker::Speaker::Delegate {
// This is empirically the best that I can seem to do with SDL's timer precision.
static constexpr int buffered_samples = 1024;
static constexpr size_t buffered_samples = 1024;
bool is_stereo = false;
void speaker_did_complete_samples(Outputs::Speaker::Speaker *speaker, const std::vector<int16_t> &buffer) final {
std::lock_guard<std::mutex> lock_guard(audio_buffer_mutex_);
const auto buffer_size = buffered_samples * (is_stereo ? 2 : 1);
const size_t buffer_size = buffered_samples * (is_stereo ? 2 : 1);
if(audio_buffer_.size() > buffer_size) {
audio_buffer_.erase(audio_buffer_.begin(), audio_buffer_.end() - buffer_size);
}
@ -664,7 +664,7 @@ int main(int argc, char *argv[]) {
desired_audio_spec.freq = 48000; // TODO: how can I get SDL to reveal the output rate of this machine?
desired_audio_spec.format = AUDIO_S16;
desired_audio_spec.channels = 1 + int(speaker->get_is_stereo());
desired_audio_spec.samples = SpeakerDelegate::buffered_samples;
desired_audio_spec.samples = Uint16(SpeakerDelegate::buffered_samples);
desired_audio_spec.callback = SpeakerDelegate::SDL_audio_callback;
desired_audio_spec.userdata = &speaker_delegate;
@ -869,11 +869,11 @@ int main(int argc, char *argv[]) {
SDL_FreeSurface(surface);
break;
}
}
// Syphon off alt+enter (toggle full-screen) upon key up only; this was previously a key down action,
// but the SDL_KEYDOWN announcement was found to be reposted after changing graphics mode on some
// systems so key up is safer.
// systems, causing a loop of changes, so key up is safer.
if(event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_RETURN && (SDL_GetModState()&KMOD_ALT)) {
fullscreen_mode ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
SDL_SetWindowFullscreen(window, fullscreen_mode);
@ -886,7 +886,6 @@ int main(int argc, char *argv[]) {
}
break;
}
}
const bool is_pressed = event.type == SDL_KEYDOWN;