Files
lmms/include/AudioDummy.h
Michael Gregorius 79cae31b5b Some refactoring to enable signals in audio driver setup dialogs
Moved AudioDevice::setupWidget into its own class AudioDeviceSetupWidget
which logically should belong to the GUI (unfortunately the include
structure does not make this obvious).

For the ALSA driver there is an implementation AudioAlsaSetupWidget
which provides a combo box for selection of the card and device.

All other driver widgets have been changed to inherit from
AudioAlsaSetupWidget but have not been changed otherwise.

SetupDialog has been adjusted to keep a map of AudioAlsaSetupWidgets
now.
2015-06-26 17:14:47 +02:00

118 lines
2.2 KiB
C++

/*
* AudioDummy.h - dummy audio-device
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* 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_DUMMY_H
#define AUDIO_DUMMY_H
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
#include "MicroTimer.h"
class AudioDummy : public AudioDevice, public QThread
{
public:
AudioDummy( bool & _success_ful, Mixer* mixer ) :
AudioDevice( DEFAULT_CHANNELS, mixer )
{
_success_ful = true;
}
virtual ~AudioDummy()
{
stopProcessing();
}
inline static QString name()
{
return QT_TRANSLATE_NOOP( "setupWidget", "Dummy (no sound output)" );
}
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioDummy::name(), _parent )
{
}
virtual ~setupWidget()
{
}
virtual void saveSettings()
{
}
virtual void show()
{
parentWidget()->hide();
QWidget::show();
}
} ;
private:
virtual void startProcessing()
{
start();
}
virtual void stopProcessing()
{
if( isRunning() )
{
wait( 1000 );
terminate();
}
}
virtual void run()
{
MicroTimer timer;
while( true )
{
timer.reset();
const surroundSampleFrame* b = mixer()->nextBuffer();
if( !b )
{
break;
}
delete[] b;
const int microseconds = static_cast<int>( mixer()->framesPerPeriod() * 1000000.0f / mixer()->processingSampleRate() - timer.elapsed() );
if( microseconds > 0 )
{
usleep( microseconds );
}
}
}
} ;
#endif