Adding OpenBSD's sndio support.
Updating jackmsr's work, adding sndio cmake module. Updating 64 bits OS arch detection (amd64).
This commit is contained in:
@@ -53,6 +53,7 @@ INCLUDE_DIRECTORIES(
|
||||
${JACK_INCLUDE_DIRS}
|
||||
${SAMPLERATE_INCLUDE_DIRS}
|
||||
${SNDFILE_INCLUDE_DIRS}
|
||||
${SNDIO_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
IF(NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
|
||||
@@ -117,6 +118,7 @@ SET(LMMS_REQUIRED_LIBS
|
||||
${SDL_LIBRARY}
|
||||
${PORTAUDIO_LIBRARIES}
|
||||
${SOUNDIO_LIBRARY}
|
||||
${SNDIO_LIBRARY}
|
||||
${PULSEAUDIO_LIBRARIES}
|
||||
${JACK_LIBRARIES}
|
||||
${OGGVORBIS_LIBRARIES}
|
||||
|
||||
@@ -71,6 +71,7 @@ set(LMMS_SRCS
|
||||
core/audio/AudioFileWave.cpp
|
||||
core/audio/AudioJack.cpp
|
||||
core/audio/AudioOss.cpp
|
||||
core/audio/AudioSndio.cpp
|
||||
core/audio/AudioPort.cpp
|
||||
core/audio/AudioPortAudio.cpp
|
||||
core/audio/AudioSoundIo.cpp
|
||||
@@ -83,6 +84,7 @@ set(LMMS_SRCS
|
||||
core/midi/MidiClient.cpp
|
||||
core/midi/MidiController.cpp
|
||||
core/midi/MidiOss.cpp
|
||||
core/midi/MidiSndio.cpp
|
||||
core/midi/MidiApple.cpp
|
||||
core/midi/MidiPort.cpp
|
||||
core/midi/MidiTime.cpp
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "AudioAlsa.h"
|
||||
#include "AudioJack.h"
|
||||
#include "AudioOss.h"
|
||||
#include "AudioSndio.h"
|
||||
#include "AudioPortAudio.h"
|
||||
#include "AudioSoundIo.h"
|
||||
#include "AudioPulseAudio.h"
|
||||
@@ -795,6 +796,19 @@ AudioDevice * Mixer::tryAudioDevices()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_SNDIO
|
||||
if( dev_name == AudioSndio::name() || dev_name == "" )
|
||||
{
|
||||
dev = new AudioSndio( success_ful, this );
|
||||
if( success_ful )
|
||||
{
|
||||
m_audioDevName = AudioSndio::name();
|
||||
return dev;
|
||||
}
|
||||
delete dev;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LMMS_HAVE_JACK
|
||||
if( dev_name == AudioJack::name() || dev_name == "" )
|
||||
|
||||
207
src/core/audio/AudioSndio.cpp
Normal file
207
src/core/audio/AudioSndio.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
#ifndef SINGLE_SOURCE_COMPILE
|
||||
|
||||
/* license */
|
||||
|
||||
#include "AudioSndio.h"
|
||||
|
||||
#ifdef LMMS_HAVE_SNDIO
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
#include "endian_handling.h"
|
||||
#include "LcdSpinBox.h"
|
||||
#include "Engine.h"
|
||||
#include "gui_templates.h"
|
||||
#include "templates.h"
|
||||
|
||||
#ifdef LMMS_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ConfigManager.h"
|
||||
|
||||
|
||||
|
||||
AudioSndio::AudioSndio(bool & _success_ful, Mixer * _mixer) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
ConfigManager::inst()->value( "audiosndio", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ), _mixer )
|
||||
{
|
||||
_success_ful = FALSE;
|
||||
|
||||
QString dev = ConfigManager::inst()->value( "audiosndio", "device" );
|
||||
|
||||
if (dev == "")
|
||||
{
|
||||
m_hdl = sio_open( NULL, SIO_PLAY, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hdl = sio_open( dev.toAscii().data(), SIO_PLAY, 0 );
|
||||
}
|
||||
|
||||
if( m_hdl == NULL )
|
||||
{
|
||||
printf( "sndio: failed opening audio-device\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
sio_initpar(&m_par);
|
||||
|
||||
m_par.pchan = channels();
|
||||
m_par.bits = 16;
|
||||
m_par.le = SIO_LE_NATIVE;
|
||||
m_par.rate = sampleRate();
|
||||
m_par.round = mixer()->framesPerPeriod();
|
||||
m_par.appbufsz = m_par.round * 2;
|
||||
|
||||
struct sio_par reqpar = m_par;
|
||||
|
||||
if (!sio_setpar(m_hdl, &m_par))
|
||||
{
|
||||
printf( "sndio: sio_setpar failed\n" );
|
||||
return;
|
||||
}
|
||||
if (!sio_getpar(m_hdl, &m_par))
|
||||
{
|
||||
printf( "sndio: sio_getpar failed\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (reqpar.pchan != m_par.pchan ||
|
||||
reqpar.bits != m_par.bits ||
|
||||
reqpar.le != m_par.le ||
|
||||
(abs(reqpar.rate - m_par.rate) * 100)/reqpar.rate > 2)
|
||||
{
|
||||
printf( "sndio: returned params not as requested\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sio_start(m_hdl))
|
||||
{
|
||||
printf( "sndio: sio_start failed\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
_success_ful = TRUE;
|
||||
}
|
||||
|
||||
|
||||
AudioSndio::~AudioSndio()
|
||||
{
|
||||
stopProcessing();
|
||||
if (m_hdl != NULL)
|
||||
{
|
||||
sio_close( m_hdl );
|
||||
m_hdl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AudioSndio::startProcessing( void )
|
||||
{
|
||||
if( !isRunning() )
|
||||
{
|
||||
start( QThread::HighPriority );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AudioSndio::stopProcessing( void )
|
||||
{
|
||||
if( isRunning() )
|
||||
{
|
||||
wait( 1000 );
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AudioSndio::applyQualitySettings( void )
|
||||
{
|
||||
if( hqAudio() )
|
||||
{
|
||||
setSampleRate( Engine::mixer()->processingSampleRate() );
|
||||
|
||||
/* change sample rate to sampleRate() */
|
||||
}
|
||||
|
||||
AudioDevice::applyQualitySettings();
|
||||
}
|
||||
|
||||
|
||||
void AudioSndio::run( void )
|
||||
{
|
||||
surroundSampleFrame * temp =
|
||||
new surroundSampleFrame[mixer()->framesPerPeriod()];
|
||||
int_sample_t * outbuf =
|
||||
new int_sample_t[mixer()->framesPerPeriod() * channels()];
|
||||
|
||||
while( TRUE )
|
||||
{
|
||||
const fpp_t frames = getNextBuffer( temp );
|
||||
if( !frames )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
uint bytes = convertToS16( temp, frames,
|
||||
mixer()->masterGain(), outbuf, FALSE );
|
||||
if( sio_write( m_hdl, outbuf, bytes ) != bytes )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] temp;
|
||||
delete[] outbuf;
|
||||
}
|
||||
|
||||
|
||||
AudioSndio::setupWidget::setupWidget( QWidget * _parent ) :
|
||||
AudioDeviceSetupWidget( AudioSndio::name(), _parent )
|
||||
{
|
||||
m_device = new QLineEdit( "", this );
|
||||
m_device->setGeometry( 10, 20, 160, 20 );
|
||||
|
||||
QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this );
|
||||
dev_lbl->setFont( pointSize<6>( dev_lbl->font() ) );
|
||||
dev_lbl->setGeometry( 10, 40, 160, 10 );
|
||||
|
||||
LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ );
|
||||
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
|
||||
m->setStep( 2 );
|
||||
m->setValue( ConfigManager::inst()->value( "audiosndio",
|
||||
"channels" ).toInt() );
|
||||
|
||||
m_channels = new LcdSpinBox( 1, this );
|
||||
m_channels->setModel( m );
|
||||
m_channels->setLabel( tr( "CHANNELS" ) );
|
||||
m_channels->move( 180, 20 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
AudioSndio::setupWidget::~setupWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AudioSndio::setupWidget::saveSettings( void )
|
||||
{
|
||||
ConfigManager::inst()->setValue( "audiosndio", "device",
|
||||
m_device->text() );
|
||||
ConfigManager::inst()->setValue( "audiosndio", "channels",
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
#endif /* LMMS_HAVE_SNDIO */
|
||||
|
||||
#endif /* SINGLE_SOURCE_COMPILE */
|
||||
101
src/core/midi/MidiSndio.cpp
Normal file
101
src/core/midi/MidiSndio.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef SINGLE_SOURCE_COMPILE
|
||||
|
||||
/* license */
|
||||
|
||||
#include "MidiSndio.h"
|
||||
|
||||
#ifdef LMMS_HAVE_SNDIO
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
#include "ConfigManager.h"
|
||||
#include "gui_templates.h"
|
||||
|
||||
|
||||
MidiSndio::MidiSndio( void ) :
|
||||
MidiClientRaw(),
|
||||
m_quit( FALSE )
|
||||
{
|
||||
QString dev = probeDevice();
|
||||
|
||||
if (dev == "")
|
||||
{
|
||||
m_hdl = mio_open( NULL, MIO_IN | MIO_OUT, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hdl = mio_open( dev.toAscii().data(), MIO_IN | MIO_OUT, 0 );
|
||||
}
|
||||
|
||||
if( m_hdl == NULL )
|
||||
{
|
||||
printf( "sndio: failed opening sndio midi device\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
start( QThread::LowPriority );
|
||||
}
|
||||
|
||||
|
||||
MidiSndio::~MidiSndio()
|
||||
{
|
||||
if( isRunning() )
|
||||
{
|
||||
m_quit = TRUE;
|
||||
wait( 1000 );
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString MidiSndio::probeDevice( void )
|
||||
{
|
||||
QString dev = ConfigManager::inst()->value( "MidiSndio", "device" );
|
||||
|
||||
return dev ;
|
||||
}
|
||||
|
||||
|
||||
void MidiSndio::sendByte( const unsigned char c )
|
||||
{
|
||||
mio_write( m_hdl, &c, 1 );
|
||||
}
|
||||
|
||||
|
||||
void MidiSndio::run( void )
|
||||
{
|
||||
struct pollfd pfd;
|
||||
nfds_t nfds;
|
||||
char buf[0x100], *p;
|
||||
size_t n;
|
||||
int ret;
|
||||
while( m_quit == FALSE && m_hdl )
|
||||
{
|
||||
nfds = mio_pollfd( m_hdl, &pfd, POLLIN );
|
||||
ret = poll( &pfd, nfds, 100 );
|
||||
if ( ret < 0 )
|
||||
break;
|
||||
if ( !ret || !( mio_revents( m_hdl, &pfd ) & POLLIN ) )
|
||||
continue;
|
||||
n = mio_read( m_hdl, buf, sizeof(buf) );
|
||||
if ( !n )
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (p = buf; n > 0; n--, p++)
|
||||
{
|
||||
parseData( *p );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LMMS_HAVE_SNDIO */
|
||||
|
||||
#endif /* SINGLE_SOURCE_COMPILE */
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "AudioAlsaSetupWidget.h"
|
||||
#include "AudioJack.h"
|
||||
#include "AudioOss.h"
|
||||
#include "AudioSndio.h"
|
||||
#include "AudioPortAudio.h"
|
||||
#include "AudioSoundIo.h"
|
||||
#include "AudioPulseAudio.h"
|
||||
@@ -65,6 +66,7 @@
|
||||
#include "MidiAlsaRaw.h"
|
||||
#include "MidiAlsaSeq.h"
|
||||
#include "MidiOss.h"
|
||||
#include "MidiSndio.h"
|
||||
#include "MidiWinMM.h"
|
||||
#include "MidiApple.h"
|
||||
#include "MidiDummy.h"
|
||||
@@ -801,6 +803,11 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
|
||||
m_audioIfaceSetupWidgets[AudioOss::name()] =
|
||||
new AudioOss::setupWidget( asw );
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_SNDIO
|
||||
m_audioIfaceSetupWidgets[AudioSndio::name()] =
|
||||
new AudioSndio::setupWidget( asw );
|
||||
#endif
|
||||
m_audioIfaceSetupWidgets[AudioDummy::name()] =
|
||||
new AudioDummy::setupWidget( asw );
|
||||
|
||||
@@ -885,6 +892,11 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
|
||||
MidiSetupWidget::create<MidiOss>( msw );
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_SNDIO
|
||||
m_midiIfaceSetupWidgets[MidiSndio::name()] =
|
||||
MidiSetupWidget::create<MidiSndio>( msw );
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
m_midiIfaceSetupWidgets[MidiWinMM::name()] =
|
||||
MidiSetupWidget::create<MidiWinMM>( msw );
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#cmakedefine LMMS_HAVE_JACK
|
||||
#cmakedefine LMMS_HAVE_OGGVORBIS
|
||||
#cmakedefine LMMS_HAVE_OSS
|
||||
#cmakedefine LMMS_HAVE_SNDIO
|
||||
#cmakedefine LMMS_HAVE_PORTAUDIO
|
||||
#cmakedefine LMMS_HAVE_SOUNDIO
|
||||
#cmakedefine LMMS_HAVE_PULSEAUDIO
|
||||
|
||||
Reference in New Issue
Block a user