-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add libsoundio audio backend #2339
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2015 Andrew Kelley | ||
# This file is MIT licensed. | ||
# See http://opensource.org/licenses/MIT | ||
|
||
# SOUNDIO_FOUND | ||
# SOUNDIO_INCLUDE_DIR | ||
# SOUNDIO_LIBRARY | ||
|
||
find_path(SOUNDIO_INCLUDE_DIR NAMES soundio/soundio.h) | ||
|
||
find_library(SOUNDIO_LIBRARY NAMES soundio) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(SOUNDIO DEFAULT_MSG SOUNDIO_LIBRARY SOUNDIO_INCLUDE_DIR) | ||
|
||
mark_as_advanced(SOUNDIO_INCLUDE_DIR SOUNDIO_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* AudioSoundIo.h - device-class that performs PCM-output via libsoundio | ||
* | ||
* Copyright (c) 2015 Andrew Kelley <[email protected]> | ||
* | ||
* This file is part of LMMS - http://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#ifndef AUDIO_SOUNDIO_H | ||
#define AUDIO_SOUNDIO_H | ||
|
||
#include <QtCore/QObject> | ||
|
||
#include "lmmsconfig.h" | ||
#include "ComboBoxModel.h" | ||
|
||
#ifdef LMMS_HAVE_SOUNDIO | ||
|
||
#include <soundio/soundio.h> | ||
|
||
#include "AudioDevice.h" | ||
#include "AudioDeviceSetupWidget.h" | ||
|
||
class ComboBox; | ||
class LcdSpinBox; | ||
|
||
// Exists only to work around "Error: Meta object features not supported for nested classes" | ||
class AudioSoundIoSetupUtil : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
void *m_setupWidget; | ||
public slots: | ||
void updateDevices(); | ||
void reconnectSoundIo(); | ||
}; | ||
|
||
class AudioSoundIo : public AudioDevice | ||
{ | ||
public: | ||
AudioSoundIo( bool & _success_ful, Mixer* mixer ); | ||
virtual ~AudioSoundIo(); | ||
|
||
inline static QString name() | ||
{ | ||
return QT_TRANSLATE_NOOP( "setupWidget", "soundio" ); | ||
} | ||
|
||
class setupWidget : public AudioDeviceSetupWidget | ||
{ | ||
public: | ||
setupWidget( QWidget * _parent ); | ||
virtual ~setupWidget(); | ||
|
||
virtual void saveSettings(); | ||
|
||
void updateDevices(); | ||
void reconnectSoundIo(); | ||
|
||
private: | ||
|
||
AudioSoundIoSetupUtil m_setupUtil; | ||
ComboBox * m_backend; | ||
ComboBox * m_device; | ||
|
||
ComboBoxModel m_backendModel; | ||
ComboBoxModel m_deviceModel; | ||
|
||
SoundIo * m_soundio; | ||
|
||
struct DeviceId { | ||
QString id; | ||
bool is_raw; | ||
}; | ||
QList<DeviceId> m_deviceList; | ||
|
||
int m_defaultOutIndex; | ||
bool m_isFirst; | ||
|
||
} ; | ||
|
||
private: | ||
virtual void startProcessing(); | ||
virtual void stopProcessing(); | ||
|
||
SoundIo *m_soundio; | ||
SoundIoOutStream *m_outstream; | ||
|
||
surroundSampleFrame * m_outBuf; | ||
int m_outBufSize; | ||
fpp_t m_outBufFramesTotal; | ||
fpp_t m_outBufFrameIndex; | ||
|
||
int m_disconnectErr; | ||
void onBackendDisconnect(int err); | ||
|
||
void writeCallback(int frame_count_min, int frame_count_max); | ||
void errorCallback(int err); | ||
void underflowCallback(); | ||
|
||
static void staticWriteCallback(SoundIoOutStream *outstream, int frame_count_min, int frame_count_max) { | ||
return ((AudioSoundIo *)outstream->userdata)->writeCallback(frame_count_min, frame_count_max); | ||
} | ||
static void staticErrorCallback(SoundIoOutStream *outstream, int err) { | ||
return ((AudioSoundIo *)outstream->userdata)->errorCallback(err); | ||
} | ||
static void staticUnderflowCallback(SoundIoOutStream *outstream) { | ||
return ((AudioSoundIo *)outstream->userdata)->underflowCallback(); | ||
} | ||
static void staticOnBackendDisconnect(SoundIo *soundio, int err) { | ||
return ((AudioSoundIo *)soundio->userdata)->onBackendDisconnect(err); | ||
} | ||
|
||
}; | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how big of a deal this is, but all the other audio/midi backends configure their includes in
/src/CMakeLists.txt
instead of/CMakeLists.txt
so as not to affect the building of plugins.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first thing I tried was using PortAudio's CMake lines as a template but that lead to inability to build if the library is not installed. Instead of trying to figure out why that wasn't working, I opted to just do it how I do it in my own projects, since I know that will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Probably not a big deal - I wouldn't sink any time into changing that then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In regards to the CMakeLists lines, I'll be the odd man out and say I'd prefer we keep this consistent -- speaking less about where it should be but rather on behalf of the recent cleanup efforts.
From my experience, variable scope and order of operations is what seems to cause most
CMakeLists.txt
problems. At a glance,LMMS_REQUIRED_LIBS
adds${PORTAUDIO_LIBRARIES}
to parent scope. In my experience, thePARENT_SCOPE
related issues are usually the cause ofADD_SUBDIRECTORY
headaches and this is because a local variable in cmake isn't exposed to its parent.Anyway, happy to help. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you're suggesting. I basically grepped for portaudio, copied all the cmake configuration, then replaced portudio with soundio. The only difference is the cmake/modules/Find*.cmake file, which I suspect is the culprit. But I'm sure that the FindSoundIo.cmake is OK and the PortAudio one looks complicated and not how I would do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I get for only reading the comments. 😄
I see now that it's a single line...
INCLUDE_DIRECTORIES
. Did you clone theIF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
logic? Because if you don't defineSOUNDIO_INCLUDE_DIR
, you're better off doing anIF(WANT_SOUNDIO AND SOUNDIO_FOUND)
, right (in src/CMakeLists.txt that is)?Edit: Hmm... I see you do define
SOUNDIO_INCLUDE_DIR
inFindSoundIo.cmake
. I'm confused now too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I cloned that logic too.