2 * AudioDummy.h - dummy audio-device
4 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
25 #ifndef _AUDIO_DUMMY_H
26 #define _AUDIO_DUMMY_H
28 #include "AudioBackend.h"
30 #include "MicroTimer.h"
33 class AudioDummy
: public AudioBackend
, public QThread
36 AudioDummy( bool & _success_ful
, AudioOutputContext
* context
) :
37 AudioBackend( DEFAULT_CHANNELS
, context
)
47 inline static QString
name()
49 return QT_TRANSLATE_NOOP( "setupWidget", "Dummy (no sound output)" );
53 class setupWidget
: public AudioBackend::setupWidget
56 setupWidget( QWidget
* _parent
) :
57 AudioBackend::setupWidget( AudioDummy::name(), _parent
)
61 virtual ~setupWidget()
65 virtual void saveSettings()
71 parentWidget()->hide();
79 virtual void startProcessing()
84 virtual void stopProcessing()
96 sampleFrameA
* buf
= CPU::allocFrames( mixer()->framesPerPeriod() );
100 int frames
= getNextBuffer( buf
);
106 const Sint32 microseconds
= static_cast<Sint32
>(
107 mixer()->framesPerPeriod() * 1000000.0f
/
108 mixer()->processingSampleRate() - timer
.elapsed() );
109 if( microseconds
> 0 )
111 usleep( microseconds
);
114 CPU::freeFrames( buf
);