mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Some small changes to the audio code.
This commit is contained in:
parent
bde34ddffd
commit
f7c33ecd26
1
NEWS.md
1
NEWS.md
|
@ -71,6 +71,7 @@ Many bugs have been fixed, and numerous features that were only partially implem
|
|||
* Refactoring, cleanup and documentation of the source code, removal of deprecated files etc.
|
||||
* All required fonts bundled with the application, no dependencies on the OS to provide them any longer
|
||||
* Made pugixml an external dependency instead of bundling it
|
||||
* Modernized the audio code, for example using SDL_AudioStream instead of the older SDL_AudioCVT
|
||||
* Overhaul of application settings, now the configuration file is only updated when there have been actual configuration changes
|
||||
* Decreased CPU usage dramatically by only rendering the currently visible view (previously all views were always rendered)
|
||||
* Updated the CMake/CPack install and package build script to work as expected (it can now generate .deb, .rpm, .dmg and NSIS installation packages)
|
||||
|
|
|
@ -59,7 +59,10 @@ void AudioManager::init()
|
|||
SDL_memset(&sRequestedAudioFormat, 0, sizeof(sRequestedAudioFormat));
|
||||
SDL_memset(&sAudioFormat, 0, sizeof(sAudioFormat));
|
||||
|
||||
// Set up format and callback. Play 16-bit stereo audio at 44.1Khz.
|
||||
// Set up format and callback. SDL will negotiate these settings with the audio driver, so
|
||||
// if for instance the driver/hardware does not support 32-bit floating point output, 16-bit
|
||||
// integer may be selected instead. ES-DE will handle this automatically as there are no
|
||||
// hardcoded audio settings elsewhere in the code.
|
||||
sRequestedAudioFormat.freq = 44100;
|
||||
sRequestedAudioFormat.format = AUDIO_F32;
|
||||
sRequestedAudioFormat.channels = 2;
|
||||
|
@ -94,8 +97,8 @@ void AudioManager::init()
|
|||
std::to_string(sRequestedAudioFormat.channels) << " could not be "
|
||||
"set, obtained " << std::to_string(sAudioFormat.channels) << ".";
|
||||
}
|
||||
#if defined(_WIN64)
|
||||
// Beats me why the buffer size is not divided by the channel count on Windows.
|
||||
#if defined(_WIN64) || defined(__APPLE__)
|
||||
// Beats me why the buffer size is not divided by the channel count on some operating systems.
|
||||
if (sAudioFormat.samples != sRequestedAudioFormat.samples) {
|
||||
#else
|
||||
if (sAudioFormat.samples != sRequestedAudioFormat.samples / sRequestedAudioFormat.channels) {
|
||||
|
@ -170,6 +173,8 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
|
|||
}
|
||||
|
||||
// Process video stream audio.
|
||||
// The calling function in VideoVlcComponent is currently disabled as the internal
|
||||
// handling of audio streaming from videos does not work correctly.
|
||||
int chunkLength = SDL_AudioStreamAvailable(sConversionStream);
|
||||
|
||||
if (chunkLength != 0) {
|
||||
|
@ -199,13 +204,14 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
|
|||
return;
|
||||
}
|
||||
|
||||
// Currently disabled as it generates a lot of debug output.
|
||||
// Enable only when needed, as it generates a lot of debug output.
|
||||
// LOG(LogDebug) << "AudioManager::mixAudio(): chunkLength / chunkSegment "
|
||||
// "/ processedLength: " << chunkLength << " / " << chunkSegment <<
|
||||
// " / " << processedLength;
|
||||
|
||||
if (processedLength > 0)
|
||||
SDL_MixAudioFormat(stream, converted, sAudioFormat.format, processedLength, 128);
|
||||
SDL_MixAudioFormat(stream, converted, sAudioFormat.format, processedLength,
|
||||
Settings::getInstance()->getInt("SoundVolumeVideos") * 1.28);
|
||||
}
|
||||
|
||||
delete[] converted;
|
||||
|
@ -246,7 +252,7 @@ void AudioManager::stop()
|
|||
{
|
||||
// Stop playing all Sounds.
|
||||
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
|
||||
if (sSoundVector.at(i) && sSoundVector.at(i)->isPlaying())
|
||||
if (sSoundVector.at(i)->isPlaying())
|
||||
sSoundVector[i]->stop();
|
||||
}
|
||||
// Pause audio.
|
||||
|
|
Loading…
Reference in a new issue