Remove support for SDL1 (#7443)
Remove the fallback code in `CMakeLists.txt`. Keep the message that's shown when SDL is wanted but not found. Remove the specific `LMMS_HAVE_SDL2` define. Just print "OK" if SDL is found. Remove several ifdefs which check for SDL2 or SDL1. Remove all code related to SDL1.
This commit is contained in:
committed by
GitHub
parent
0e96c267cd
commit
d8e4d8c115
@@ -338,37 +338,14 @@ IF(WANT_SDL)
|
||||
FIND_PACKAGE(SDL2)
|
||||
IF(SDL2_FOUND)
|
||||
SET(LMMS_HAVE_SDL TRUE)
|
||||
SET(LMMS_HAVE_SDL2 TRUE)
|
||||
SET(STATUS_SDL "OK, using SDL2")
|
||||
SET(STATUS_SDL "OK")
|
||||
SET(SDL2_LIBRARY "SDL2::SDL2")
|
||||
SET(SDL_INCLUDE_DIR "")
|
||||
SET(SDL_LIBRARY "")
|
||||
ELSE()
|
||||
SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) if you require SDL support")
|
||||
SET(SDL2_LIBRARY "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# fallback to SDL1
|
||||
IF(WANT_SDL AND NOT LMMS_HAVE_SDL2)
|
||||
# Fallback to SDL1.2
|
||||
SET(SDL_BUILDING_LIBRARY TRUE)
|
||||
FIND_PACKAGE(SDL)
|
||||
IF(SDL_FOUND)
|
||||
SET(LMMS_HAVE_SDL TRUE)
|
||||
SET(STATUS_SDL "OK, using SDL1.2")
|
||||
# fix mingw since 53abd65
|
||||
IF(NOT SDL_INCLUDE_DIR)
|
||||
SET(SDL_INCLUDE_DIR "${CMAKE_FIND_ROOT_PATH}/include")
|
||||
ENDIF()
|
||||
|
||||
ELSE()
|
||||
SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) "
|
||||
"if you require SDL support")
|
||||
SET(SDL_INCLUDE_DIR "")
|
||||
SET(SDL_LIBRARY "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# check for Sid
|
||||
if(WANT_SID)
|
||||
if(PERL_FOUND)
|
||||
|
||||
@@ -29,12 +29,7 @@
|
||||
|
||||
#ifdef LMMS_HAVE_SDL
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
#include <SDL2/SDL_audio.h>
|
||||
#else
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_audio.h>
|
||||
#endif
|
||||
|
||||
#include "AudioDevice.h"
|
||||
#include "AudioDeviceSetupWidget.h"
|
||||
@@ -84,35 +79,22 @@ private:
|
||||
static void sdlAudioCallback( void * _udata, Uint8 * _buf, int _len );
|
||||
void sdlAudioCallback( Uint8 * _buf, int _len );
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
static void sdlInputAudioCallback( void * _udata, Uint8 * _buf, int _len );
|
||||
void sdlInputAudioCallback( Uint8 * _buf, int _len );
|
||||
#endif
|
||||
|
||||
SDL_AudioSpec m_audioHandle;
|
||||
|
||||
SampleFrame* m_outBuf;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
size_t m_currentBufferFramePos;
|
||||
size_t m_currentBufferFramesCount;
|
||||
#else
|
||||
Uint8 * m_convertedBuf;
|
||||
int m_convertedBufPos;
|
||||
int m_convertedBufSize;
|
||||
bool m_outConvertEndian;
|
||||
#endif
|
||||
|
||||
|
||||
bool m_stopped;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
SDL_AudioDeviceID m_outputDevice;
|
||||
|
||||
SDL_AudioSpec m_inputAudioHandle;
|
||||
SDL_AudioDeviceID m_inputDevice;
|
||||
#endif
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -60,10 +60,6 @@ include_directories(SYSTEM
|
||||
${FFTW3F_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
IF(NOT LMMS_HAVE_SDL2 AND NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
|
||||
include_directories(SYSTEM "${SDL_INCLUDE_DIR}")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
|
||||
include_directories(SYSTEM "${PULSEAUDIO_INCLUDE_DIR}")
|
||||
ENDIF()
|
||||
|
||||
@@ -48,15 +48,8 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
{
|
||||
_success_ful = false;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
m_currentBufferFramesCount = 0;
|
||||
m_currentBufferFramePos = 0;
|
||||
#else
|
||||
m_convertedBufSize = audioEngine()->framesPerPeriod() * channels()
|
||||
* sizeof( int_sample_t );
|
||||
m_convertedBufPos = 0;
|
||||
m_convertedBuf = new Uint8[m_convertedBufSize];
|
||||
#endif
|
||||
|
||||
if( SDL_Init( SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE ) < 0 )
|
||||
{
|
||||
@@ -65,15 +58,10 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
}
|
||||
|
||||
m_audioHandle.freq = sampleRate();
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
m_audioHandle.format = AUDIO_F32SYS; // we want it in byte-order
|
||||
// of system, so we don't have
|
||||
// to convert the buffers
|
||||
#else
|
||||
m_audioHandle.format = AUDIO_S16SYS; // we want it in byte-order
|
||||
// of system, so we don't have
|
||||
// to convert the buffers
|
||||
#endif
|
||||
|
||||
m_audioHandle.channels = channels();
|
||||
m_audioHandle.samples = std::max(f_cnt_t{1024}, audioEngine()->framesPerPeriod() * 2);
|
||||
|
||||
@@ -82,7 +70,6 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
|
||||
SDL_AudioSpec actual;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
const auto playbackDevice = ConfigManager::inst()->value(SectionSDL, PlaybackDeviceSDL).toStdString();
|
||||
const bool isDefaultPlayback = playbackDevice.empty();
|
||||
|
||||
@@ -100,21 +87,9 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
qCritical( "Couldn't open SDL-audio: %s\n", SDL_GetError() );
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// open the audio device, forcing the desired format
|
||||
if( SDL_OpenAudio( &m_audioHandle, &actual ) < 0 )
|
||||
{
|
||||
qCritical( "Couldn't open SDL-audio: %s\n", SDL_GetError() );
|
||||
return;
|
||||
}
|
||||
|
||||
m_outConvertEndian = ( m_audioHandle.format != actual.format );
|
||||
#endif
|
||||
|
||||
|
||||
_success_ful = true;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
// Workaround for a race condition that causes SDL to segfault
|
||||
SDL_Delay(50);
|
||||
|
||||
@@ -140,8 +115,6 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
m_supportsCapture = false;
|
||||
qWarning ( "Couldn't open SDL capture device: %s\n", SDL_GetError ());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -151,15 +124,10 @@ AudioSdl::~AudioSdl()
|
||||
{
|
||||
stopProcessing();
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
if (m_inputDevice != 0)
|
||||
SDL_CloseAudioDevice(m_inputDevice);
|
||||
if (m_outputDevice != 0)
|
||||
SDL_CloseAudioDevice(m_outputDevice);
|
||||
#else
|
||||
SDL_CloseAudio();
|
||||
delete[] m_convertedBuf;
|
||||
#endif
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
@@ -173,12 +141,8 @@ void AudioSdl::startProcessing()
|
||||
{
|
||||
m_stopped = false;
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
SDL_PauseAudioDevice (m_outputDevice, 0);
|
||||
SDL_PauseAudioDevice (m_inputDevice, 0);
|
||||
#else
|
||||
SDL_PauseAudio( 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -186,13 +150,8 @@ void AudioSdl::startProcessing()
|
||||
|
||||
void AudioSdl::stopProcessing()
|
||||
{
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
if( SDL_GetAudioDeviceStatus(m_outputDevice) == SDL_AUDIO_PLAYING )
|
||||
#else
|
||||
if( SDL_GetAudioStatus() == SDL_AUDIO_PLAYING )
|
||||
#endif
|
||||
{
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
SDL_LockAudioDevice (m_inputDevice);
|
||||
SDL_LockAudioDevice (m_outputDevice);
|
||||
|
||||
@@ -203,13 +162,6 @@ void AudioSdl::stopProcessing()
|
||||
|
||||
SDL_UnlockAudioDevice (m_inputDevice);
|
||||
SDL_UnlockAudioDevice (m_outputDevice);
|
||||
#else
|
||||
SDL_LockAudio();
|
||||
m_stopped = true;
|
||||
SDL_PauseAudio( 1 );
|
||||
SDL_UnlockAudio();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +184,6 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len )
|
||||
}
|
||||
|
||||
// SDL2: process float samples
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
while( _len )
|
||||
{
|
||||
if( m_currentBufferFramePos == 0 )
|
||||
@@ -258,37 +209,8 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len )
|
||||
|
||||
m_currentBufferFramePos %= m_currentBufferFramesCount;
|
||||
}
|
||||
#else
|
||||
while( _len )
|
||||
{
|
||||
if( m_convertedBufPos == 0 )
|
||||
{
|
||||
// frames depend on the sample rate
|
||||
const fpp_t frames = getNextBuffer( m_outBuf );
|
||||
if( !frames )
|
||||
{
|
||||
m_stopped = true;
|
||||
memset( _buf, 0, _len );
|
||||
return;
|
||||
}
|
||||
m_convertedBufSize = frames * channels()
|
||||
* sizeof( int_sample_t );
|
||||
|
||||
convertToS16(m_outBuf, frames, reinterpret_cast<int_sample_t*>(m_convertedBuf), m_outConvertEndian);
|
||||
}
|
||||
const int min_len = std::min(_len, m_convertedBufSize
|
||||
- m_convertedBufPos);
|
||||
memcpy( _buf, m_convertedBuf + m_convertedBufPos, min_len );
|
||||
_buf += min_len;
|
||||
_len -= min_len;
|
||||
m_convertedBufPos += min_len;
|
||||
m_convertedBufPos %= m_convertedBufSize;
|
||||
}
|
||||
#endif // LMMS_HAVE_SDL2
|
||||
}
|
||||
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
|
||||
void AudioSdl::sdlInputAudioCallback(void *_udata, Uint8 *_buf, int _len) {
|
||||
auto _this = static_cast<AudioSdl*>(_udata);
|
||||
|
||||
@@ -302,8 +224,6 @@ void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) {
|
||||
audioEngine()->pushInputFrames (samples_buffer, frames);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QString AudioSdl::setupWidget::s_systemDefaultDevice = AudioDeviceSetupWidget::tr("[System Default]");
|
||||
|
||||
AudioSdl::setupWidget::setupWidget( QWidget * _parent ) :
|
||||
@@ -355,7 +275,6 @@ void AudioSdl::setupWidget::saveSettings()
|
||||
|
||||
void AudioSdl::setupWidget::populatePlaybackDeviceComboBox()
|
||||
{
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
m_playbackDeviceComboBox->addItem(s_systemDefaultDevice);
|
||||
|
||||
QStringList playbackDevices;
|
||||
@@ -372,12 +291,10 @@ void AudioSdl::setupWidget::populatePlaybackDeviceComboBox()
|
||||
|
||||
const auto playbackDevice = ConfigManager::inst()->value(SectionSDL, PlaybackDeviceSDL);
|
||||
m_playbackDeviceComboBox->setCurrentText(playbackDevice.isEmpty() ? s_systemDefaultDevice : playbackDevice);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AudioSdl::setupWidget::populateInputDeviceComboBox()
|
||||
{
|
||||
#ifdef LMMS_HAVE_SDL2
|
||||
m_inputDeviceComboBox->addItem(s_systemDefaultDevice);
|
||||
|
||||
QStringList inputDevices;
|
||||
@@ -395,7 +312,6 @@ void AudioSdl::setupWidget::populateInputDeviceComboBox()
|
||||
// Set the current device to the one in the configuration
|
||||
const auto inputDevice = ConfigManager::inst()->value(SectionSDL, InputDeviceSDL);
|
||||
m_inputDeviceComboBox->setCurrentText(inputDevice.isEmpty() ? s_systemDefaultDevice : inputDevice);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#cmakedefine LMMS_HAVE_SOUNDIO
|
||||
#cmakedefine LMMS_HAVE_PULSEAUDIO
|
||||
#cmakedefine LMMS_HAVE_SDL
|
||||
#cmakedefine LMMS_HAVE_SDL2
|
||||
#cmakedefine LMMS_HAVE_STK
|
||||
#cmakedefine LMMS_HAVE_VST
|
||||
#cmakedefine LMMS_HAVE_SF_COMPLEVEL
|
||||
|
||||
Reference in New Issue
Block a user