Frontends: Add cubeb as audio backend option

This commit is contained in:
Connor McLaughlin 2020-01-11 13:49:52 +10:00
parent 9586970a9f
commit 8f6ac437ab
3 changed files with 24 additions and 4 deletions

View File

@ -53,6 +53,7 @@ enum class AudioBackend : u8
{ {
Null, Null,
Default, Default,
Cubeb,
Count Count
}; };

View File

@ -27,7 +27,6 @@ QtHostInterface::QtHostInterface(QObject* parent)
checkSettings(); checkSettings();
createGameList(); createGameList();
doUpdateInputMap(); doUpdateInputMap();
createAudioStream();
createThread(); createThread();
} }
@ -445,9 +444,20 @@ void QtHostInterface::doBootSystem(QString initial_filename, QString initial_sav
void QtHostInterface::createAudioStream() void QtHostInterface::createAudioStream()
{ {
// Qt at least on Windows seems to want a buffer size of at least 8KB. switch (m_settings.audio_backend)
// m_audio_stream = QtAudioStream::Create(); {
// if (!m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, AUDIO_BUFFER_SIZE, 4)) case AudioBackend::Default:
case AudioBackend::Cubeb:
m_audio_stream = AudioStream::CreateCubebAudioStream();
break;
case AudioBackend::Null:
default:
m_audio_stream = AudioStream::CreateNullAudioStream();
break;
}
if (!m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, AUDIO_BUFFER_SIZE, 4))
{ {
qWarning() << "Failed to configure audio stream, falling back to null output"; qWarning() << "Failed to configure audio stream, falling back to null output";
@ -482,6 +492,10 @@ void QtHostInterface::doStopThread()
void QtHostInterface::threadEntryPoint() void QtHostInterface::threadEntryPoint()
{ {
m_worker_thread_event_loop = new QEventLoop(); m_worker_thread_event_loop = new QEventLoop();
createAudioStream();
// TODO: Event which flags the thread as ready
while (!m_shutdown_flag.load()) while (!m_shutdown_flag.load())
{ {
if (!m_system || m_paused) if (!m_system || m_paused)
@ -524,6 +538,7 @@ void QtHostInterface::threadEntryPoint()
} }
m_system.reset(); m_system.reset();
m_audio_stream.reset();
delete m_worker_thread_event_loop; delete m_worker_thread_event_loop;
m_worker_thread_event_loop = nullptr; m_worker_thread_event_loop = nullptr;

View File

@ -128,6 +128,10 @@ void SDLHostInterface::CreateAudioStream()
m_audio_stream = AudioStream::CreateNullAudioStream(); m_audio_stream = AudioStream::CreateNullAudioStream();
break; break;
case AudioBackend::Cubeb:
m_audio_stream = AudioStream::CreateCubebAudioStream();
break;
case AudioBackend::Default: case AudioBackend::Default:
default: default:
m_audio_stream = std::make_unique<SDLAudioStream>(); m_audio_stream = std::make_unique<SDLAudioStream>();