~ubuntu-branches/ubuntu/hardy/lmms/hardy

« back to all changes in this revision

Viewing changes to src/audio/audio_oss.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Tobias Doerffel
  • Date: 2007-09-17 15:00:24 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070917150024-mo0zk4ks81jawqii
Tags: 0.3.0-1ubuntu1
* Resynchronized with Debian (LP: #139759, LP: #90806, LP: #102639,
  LP: #113447, LP: #121172, LP: #124890)
* reverted changes from 0.2.1-1.1ubuntu1 as upstream merged/included them

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*
4
4
 * audio_oss.cpp - device-class that implements OSS-PCM-output
5
5
 *
6
 
 * Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
6
 * Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
7
7
 * 
8
8
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
9
9
 *
19
19
 *
20
20
 * You should have received a copy of the GNU General Public
21
21
 * License along with this program (see COPYING); if not, write to the
22
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23
 
 * Boston, MA 02111-1307, USA.
 
22
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
23
 * Boston, MA 02110-1301 USA.
24
24
 *
25
25
 */
26
26
 
47
47
#endif
48
48
 
49
49
 
50
 
#include "buffer_allocator.h"
51
50
#include "endian_handling.h"
52
51
#include "lcd_spinbox.h"
53
52
#include "gui_templates.h"
99
98
                configManager::inst()->value( "audiooss", "channels" ).toInt(),
100
99
                                        DEFAULT_CHANNELS, SURROUND_CHANNELS ),
101
100
                                                                _mixer ),
102
 
        m_convertEndian( FALSE ),
103
 
        m_quit( FALSE )
 
101
        m_convertEndian( FALSE )
104
102
{
105
103
        _success_ful = FALSE;
106
104
 
129
127
 
130
128
        int frag_spec;
131
129
        for( frag_spec = 0; static_cast<int>( 0x01 << frag_spec ) <
132
 
                getMixer()->framesPerAudioBuffer() * channels() *
 
130
                getMixer()->framesPerPeriod() * channels() *
133
131
                                                        BYTES_PER_INT_SAMPLE;
134
132
                ++frag_spec )
135
133
        {
216
214
                else
217
215
                {
218
216
                        SAMPLE_RATES[0] = 44100;
219
 
                        SAMPLE_RATES[1] = 82000;
 
217
                        SAMPLE_RATES[1] = 88200;
220
218
                }
221
219
                setSampleRate( SAMPLE_RATES[q] );
222
220
                value = sampleRate();
307
305
{
308
306
        if( isRunning() )
309
307
        {
310
 
                m_quit = TRUE;
311
308
                wait( 1000 );
312
309
                terminate();
313
310
        }
319
316
void audioOSS::run( void )
320
317
{
321
318
        surroundSampleFrame * temp =
322
 
                        bufferAllocator::alloc<surroundSampleFrame>(
323
 
                                        getMixer()->framesPerAudioBuffer() );
324
 
        int_sample_t * outbuf = bufferAllocator::alloc<int_sample_t>(
325
 
                                        getMixer()->framesPerAudioBuffer() *
326
 
                                                                channels() );
327
 
        m_quit = FALSE;
 
319
                new surroundSampleFrame[getMixer()->framesPerPeriod()];
 
320
        int_sample_t * outbuf =
 
321
                        new int_sample_t[getMixer()->framesPerPeriod() *
 
322
                                                                channels()];
328
323
 
329
 
        while( m_quit == FALSE )
 
324
        while( TRUE )
330
325
        {
331
 
                const fpab_t frames = getNextBuffer( temp );
 
326
                const fpp_t frames = getNextBuffer( temp );
 
327
                if( !frames )
 
328
                {
 
329
                        break;
 
330
                }
332
331
 
333
332
                int bytes = convertToS16( temp, frames,
334
333
                                getMixer()->masterGain(), outbuf,
336
335
                write( m_audioFD, outbuf, bytes );
337
336
        }
338
337
 
339
 
        bufferAllocator::free( temp );
340
 
        bufferAllocator::free( outbuf );
 
338
        delete[] temp;
 
339
        delete[] outbuf;
341
340
}
342
341
 
343
342
 
354
353
        dev_lbl->setGeometry( 10, 40, 160, 10 );
355
354
 
356
355
        m_channels = new lcdSpinBox( DEFAULT_CHANNELS, SURROUND_CHANNELS, 1,
357
 
                                                this, NULL, NULL, NULL );
 
356
                                                        this, NULL, NULL );
358
357
        m_channels->setStep( 2 );
359
358
        m_channels->setLabel( tr( "CHANNELS" ) );
360
359
        m_channels->setValue( configManager::inst()->value( "audiooss",