Merge branch 'master' into feature/filesystem

This commit is contained in:
Stephen Anthony 2022-10-10 14:53:05 -02:30
commit 25c0f5ad69
11 changed files with 71 additions and 143 deletions

39
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,39 @@
---
name: Build
on:
pull_request:
permissions: {}
jobs:
linux:
name: Linux
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- name: Install GCC 9 and SDL2
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-9 libsdl2-dev
- name: Build Stella
run: |
./configure && make -j2 all
macos:
name: macOS
runs-on: macos-latest
steps:
- name: Check out the repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- name: Install SDL2
run: |
curl https://www.libsdl.org/release/SDL2-2.0.10.tar.gz | tar xzf -
mkdir SDL2-2.0.10/build
cd SDL2-2.0.10/build
../configure && make -j3 && sudo make install
- name: Build Stella
run: |
./configure && make -j3 all

View File

@ -1,63 +0,0 @@
# Build matrix / environment variables are explained on:
# http://about.travis-ci.org/docs/user/build-configuration/
# This file can be validated on: http://lint.travis-ci.org/
language: cpp
matrix:
include:
- os: linux
dist: xenial
compiler: gcc
env: GCC=9 CC=gcc-9 CXX=g++-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-9
- g++-9
update: true
- os: osx
osx_image: xcode11.3
compiler: clang
addons:
homebrew:
update: true
install:
- |
old_cwd=$(pwd)
cd ~
if [[ "$HOST" == macosx-* ]]; then
curl -O https://www.libsdl.org/release/SDL2-2.0.10.tar.gz
tar xzf SDL2-2.0.10.tar.gz
cd SDL2-2.0.10/Xcode/SDL
sed -i -e 's/@rpath//g' SDL.xcodeproj/project.pbxproj
xcodebuild -configuration Release
mkdir -p ~/Library/Frameworks/
ln -s `pwd`/build/Release/SDL2.framework ~/Library/Frameworks/
else
curl -O https://www.libsdl.org/release/SDL2-2.0.10.tar.gz
tar xzf SDL2-2.0.10.tar.gz
cd SDL2-2.0.10
mkdir build
cd build
../configure
make
sudo make install
fi
cd $old_cwd
script:
- |
./configure
make all

View File

@ -24,7 +24,7 @@
#include "StaggeredLogger.hxx" #include "StaggeredLogger.hxx"
/** /**
This class implements a an audio queue that acts both like a ring buffer This class implements an audio queue that acts both like a ring buffer
and a pool of audio fragments. The TIA emulation core fills a fragment and a pool of audio fragments. The TIA emulation core fills a fragment
with samples and then returns it to the queue, receiving a new fragment with samples and then returns it to the queue, receiving a new fragment
in return. The sound driver removes fragments for playback from the in return. The sound driver removes fragments for playback from the

View File

@ -59,12 +59,6 @@ class SoundNull : public Sound
*/ */
void open(shared_ptr<AudioQueue>, EmulationTiming*) override { } void open(shared_ptr<AudioQueue>, EmulationTiming*) override { }
/**
Should be called to close the sound device. Once called the sound
device can be started again using the initialize method.
*/
void close() override { }
/** /**
Sets the sound mute state; sound processing continues. When turned Sets the sound mute state; sound processing continues. When turned
off, sound volume is 0; when turned on, sound volume returns to off, sound volume is 0; when turned on, sound volume returns to

View File

@ -141,7 +141,6 @@ bool SoundSDL2::openDevice()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::setEnabled(bool enable) void SoundSDL2::setEnabled(bool enable)
{ {
cerr << "setEnabled: " << enable << endl;
mute(!enable); mute(!enable);
pause(!enable); pause(!enable);
} }
@ -164,7 +163,6 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
Logger::debug("SoundSDL2::open started ..."); Logger::debug("SoundSDL2::open started ...");
myAudioSettings.setEnabled(true);
audioQueue->ignoreOverflows(!myAudioSettings.enabled()); audioQueue->ignoreOverflows(!myAudioSettings.enabled());
if(!myAudioSettings.enabled()) if(!myAudioSettings.enabled())
{ {
@ -193,22 +191,9 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::close() void SoundSDL2::mute(bool enable)
{ {
if(!myIsInitializedFlag) if(enable)
return;
if(myAudioQueue)
myAudioQueue->closeSink(myCurrentFragment);
myAudioQueue.reset();
myCurrentFragment = nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::mute(bool state)
{
myAudioSettings.setEnabled(!state);
if(state)
myVolumeFactor = 0; myVolumeFactor = 0;
else else
setVolume(myAudioSettings.volume()); setVolume(myAudioSettings.volume());
@ -217,27 +202,29 @@ void SoundSDL2::mute(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::toggleMute() void SoundSDL2::toggleMute()
{ {
const bool state = !myAudioSettings.enabled(); const bool wasMuted = myVolumeFactor == 0;
mute(!state); mute(!wasMuted);
string message = "Sound "; string message = "Sound ";
message += state ? "unmuted" : "muted"; message += !myAudioSettings.enabled()
? "disabled"
: (wasMuted ? "unmuted" : "muted");
myOSystem.frameBuffer().showTextMessage(message); myOSystem.frameBuffer().showTextMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL2::pause(bool state) bool SoundSDL2::pause(bool enable)
{ {
ASSERT_MAIN_THREAD; ASSERT_MAIN_THREAD;
const bool oldstate = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED; const bool wasPaused = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED;
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
SDL_PauseAudioDevice(myDevice, state ? 1 : 0); SDL_PauseAudioDevice(myDevice, enable ? 1 : 0);
myWavHandler.pause(state); myWavHandler.pause(enable);
} }
return oldstate; return wasPaused;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -386,7 +373,7 @@ void SoundSDL2::callback(void* object, uInt8* stream, int len)
const uInt32 length = len >> 2; const uInt32 length = len >> 2;
self->myResampler->fillFragment(s, length); self->myResampler->fillFragment(s, length);
for(uInt32 i = 0; i < length; ++i) // TODO - perhaps move into Resampler for(uInt32 i = 0; i < length; ++i)
s[i] *= SoundSDL2::myVolumeFactor; s[i] *= SoundSDL2::myVolumeFactor;
} }
else else
@ -452,8 +439,9 @@ bool SoundSDL2::WavHandlerSDL2::play(
myDevice = SDL_OpenAudioDevice(device, 0, &mySpec, nullptr, 0); myDevice = SDL_OpenAudioDevice(device, 0, &mySpec, nullptr, 0);
if(!myDevice) if(!myDevice)
return false; return false;
// Play audio // Play audio
SDL_PauseAudioDevice(myDevice, 0); pause(false);
} }
return true; return true;
} }

View File

@ -66,19 +66,13 @@ class SoundSDL2 : public Sound
EmulationTiming* emulationTiming) override; EmulationTiming* emulationTiming) override;
/** /**
Should be called to close the sound device. Once called the sound Sets the sound mute state; sound processing continues. When enabled,
device can be started again using the open method. sound volume is 0; when disabled, sound volume returns to previously
*/ set level.
void close() override;
/** @param enable Mutes sound if true, unmute if false
Sets the sound mute state; sound processing continues. When turned
off, sound volume is 0; when turned on, sound volume returns to
previously set level.
@param state Mutes sound if true, unmute if false
*/ */
void mute(bool state) override; void mute(bool enable) override;
/** /**
Toggles the sound mute state; sound processing continues. Toggles the sound mute state; sound processing continues.
@ -91,11 +85,11 @@ class SoundSDL2 : public Sound
neither played nor processed (ie, the sound subsystem is temporarily neither played nor processed (ie, the sound subsystem is temporarily
disabled). disabled).
@param state Pause sound if true, unpause if false @param enable Pause sound if true, unpause if false
@return The previous (old) pause state @return The previous (old) pause state
*/ */
bool pause(bool state) override; bool pause(bool enable) override;
/** /**
Sets the volume of the sound device to the specified level. The Sets the volume of the sound device to the specified level. The

View File

@ -250,10 +250,12 @@ Console::~Console()
myLeftControl->close(); myLeftControl->close();
myRightControl->close(); myRightControl->close();
// Close audio to prevent invalid access to myConsoleTiming from the audio // Close audio to prevent invalid access in the audio callback
// callback if(myAudioQueue)
myOSystem.sound().close(); {
myOSystem.sound().stopWav(); myAudioQueue->closeSink(nullptr); // TODO: is this needed?
myAudioQueue.reset();
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -335,12 +337,10 @@ void Console::redetectFrameLayout()
{ {
Serializer s; Serializer s;
myOSystem.sound().close();
save(s); save(s);
autodetectFrameLayout(false); autodetectFrameLayout(false);
load(s); load(s);
initializeAudio(); initializeAudio();
} }
@ -691,8 +691,6 @@ FBInitStatus Console::initializeVideo(bool full)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::initializeAudio() void Console::initializeAudio()
{ {
myOSystem.sound().close();
myEmulationTiming myEmulationTiming
.updatePlaybackRate(myAudioSettings.sampleRate()) .updatePlaybackRate(myAudioSettings.sampleRate())
.updatePlaybackPeriod(myAudioSettings.fragmentSize()) .updatePlaybackPeriod(myAudioSettings.fragmentSize())

View File

@ -572,7 +572,7 @@ bool OSystem::createLauncher(const string& startdir)
closeConsole(); closeConsole();
if(mySound) if(mySound)
mySound->close(); mySound->pause(true);
mySettings->setValue("tmpromdir", startdir); mySettings->setValue("tmpromdir", startdir);
bool status = false; bool status = false;

View File

@ -99,7 +99,7 @@ class PlusROMRequest {
client.set_write_timeout(milliseconds(WRITE_TIMEOUT_MSEC)); client.set_write_timeout(milliseconds(WRITE_TIMEOUT_MSEC));
auto response = client.Post( auto response = client.Post(
myDestination.path.c_str(), myDestination.path,
headers, headers,
reinterpret_cast<const char*>(myRequest.data()), reinterpret_cast<const char*>(myRequest.data()),
myRequestSize, myRequestSize,

View File

@ -55,12 +55,6 @@ class Sound
*/ */
virtual void open(shared_ptr<AudioQueue>, EmulationTiming*) = 0; virtual void open(shared_ptr<AudioQueue>, EmulationTiming*) = 0;
/**
Should be called to stop the sound system. Once called the sound
device can be started again using the ::open() method.
*/
virtual void close() = 0;
/** /**
Sets the sound mute state; sound processing continues. When turned Sets the sound mute state; sound processing continues. When turned
off, sound volume is 0; when turned on, sound volume returns to off, sound volume is 0; when turned on, sound volume returns to

View File

@ -80,22 +80,6 @@ class SoundLIBRETRO : public Sound
myIsInitializedFlag = true; myIsInitializedFlag = true;
} }
/**
Should be called to close the sound device. Once called the sound
device can be started again using the open method.
*/
void close() override
{
if (!myIsInitializedFlag)
return;
if (myAudioQueue)
myAudioQueue->closeSink(myCurrentFragment);
myAudioQueue.reset();
myCurrentFragment = nullptr;
Logger::debug("SoundLIBRETRO::close");
}
/** /**
Empties the playback buffer. Empties the playback buffer.