~ubuntu-branches/debian/sid/jackd2/sid

« back to all changes in this revision

Viewing changes to linux/alsa/JackAlsaAdapter.h

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Knoth
  • Date: 2011-03-31 13:54:50 UTC
  • mfrom: (1.1.3 upstream) (2.1.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110331135450-zafc1di024kzeu31
Tags: 1.9.7~dfsg-1
* New upstream version 1.9.7 (ALSA resume, new latency API)
* Build with --mixed on i386 to be compatible with amd64.
* Don't patch jack_connect for fast consecutive calls anymore, it's now
  using the same code as in jackd1 and waits for the port connection to
  appear.

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
            void* fOutputCardChannels[256];
146
146
 
147
147
            //non-interleaved mod, floating point software buffers
148
 
            float* fInputSoftChannels[256];
149
 
            float* fOutputSoftChannels[256];
 
148
            jack_default_audio_sample_t* fInputSoftChannels[256];
 
149
            jack_default_audio_sample_t* fOutputSoftChannels[256];
150
150
 
151
151
            //public methods ---------------------------------------------------------
152
152
 
165
165
                return fBuffering;
166
166
            }
167
167
 
168
 
            float** inputSoftChannels()
 
168
            jack_default_audio_sample_t** inputSoftChannels()
169
169
            {
170
170
                return fInputSoftChannels;
171
171
            }
172
172
 
173
 
            float** outputSoftChannels()
 
173
            jack_default_audio_sample_t** outputSoftChannels()
174
174
            {
175
175
                return fOutputSoftChannels;
176
176
            }
182
182
                fInputParams    = 0;
183
183
                fOutputParams   = 0;
184
184
                fPeriod = 2;
185
 
                
 
185
 
186
186
                fInputCardBuffer = 0;
187
187
                fOutputCardBuffer = 0;
188
 
                
 
188
 
189
189
                for ( int i = 0; i < 256; i++ )
190
190
                {
191
191
                    fInputCardChannels[i] = 0;
222
222
                //get hardware input parameters
223
223
                check_error ( snd_pcm_hw_params_malloc ( &fInputParams ) );
224
224
                setAudioParams ( fInputDevice, fInputParams );
225
 
           
 
225
 
226
226
                //get hardware output parameters
227
227
                check_error ( snd_pcm_hw_params_malloc ( &fOutputParams ) )
228
228
                setAudioParams ( fOutputDevice, fOutputParams );
229
 
                
 
229
 
230
230
                // set the number of physical input and output channels close to what we need
231
231
                fCardInputs     = fSoftInputs;
232
232
                fCardOutputs    = fSoftOutputs;
233
 
  
 
233
 
234
234
                snd_pcm_hw_params_set_channels_near(fInputDevice, fInputParams, &fCardInputs);
235
235
                snd_pcm_hw_params_set_channels_near(fOutputDevice, fOutputParams, &fCardOutputs);
236
 
     
 
236
 
237
237
                //set input/output param
238
238
                check_error ( snd_pcm_hw_params ( fInputDevice,  fInputParams ) );
239
239
                check_error ( snd_pcm_hw_params ( fOutputDevice, fOutputParams ) );
260
260
 
261
261
                for ( unsigned int i = 0; i < fSoftInputs; i++ )
262
262
                {
263
 
                    fInputSoftChannels[i] = ( float* ) aligned_calloc ( fBuffering, sizeof ( float ) );
 
263
                    fInputSoftChannels[i] = ( jack_default_audio_sample_t* ) aligned_calloc ( fBuffering, sizeof ( jack_default_audio_sample_t ) );
264
264
                    for ( int j = 0; j < fBuffering; j++ )
265
265
                        fInputSoftChannels[i][j] = 0.0;
266
266
                }
267
267
 
268
268
                for ( unsigned int i = 0; i < fSoftOutputs; i++ )
269
269
                {
270
 
                    fOutputSoftChannels[i] = ( float* ) aligned_calloc ( fBuffering, sizeof ( float ) );
 
270
                    fOutputSoftChannels[i] = ( jack_default_audio_sample_t* ) aligned_calloc ( fBuffering, sizeof ( jack_default_audio_sample_t ) );
271
271
                    for ( int j = 0; j < fBuffering; j++ )
272
272
                        fOutputSoftChannels[i][j] = 0.0;
273
273
                }
376
376
                            short* buffer16b = ( short* ) fInputCardBuffer;
377
377
                            for ( s = 0; s < fBuffering; s++ )
378
378
                                for ( c = 0; c < fCardInputs; c++ )
379
 
                                    fInputSoftChannels[c][s] = float ( buffer16b[c + s*fCardInputs] ) * ( 1.0/float ( SHRT_MAX ) );
 
379
                                    fInputSoftChannels[c][s] = jack_default_audio_sample_t(buffer16b[c + s*fCardInputs]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(SHRT_MAX));
380
380
                        }
381
381
                        else   // SND_PCM_FORMAT_S32
382
382
                        {
383
383
                            int32_t* buffer32b = ( int32_t* ) fInputCardBuffer;
384
384
                            for ( s = 0; s < fBuffering; s++ )
385
385
                                for ( c = 0; c < fCardInputs; c++ )
386
 
                                    fInputSoftChannels[c][s] = float ( buffer32b[c + s*fCardInputs] ) * ( 1.0/float ( INT_MAX ) );
 
386
                                    fInputSoftChannels[c][s] = jack_default_audio_sample_t(buffer32b[c + s*fCardInputs]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(INT_MAX));
387
387
                        }
388
388
                        break;
389
389
                    case SND_PCM_ACCESS_RW_NONINTERLEAVED :
400
400
                            {
401
401
                                chan16b = ( short* ) fInputCardChannels[c];
402
402
                                for ( s = 0; s < fBuffering; s++ )
403
 
                                    fInputSoftChannels[c][s] = float ( chan16b[s] ) * ( 1.0/float ( SHRT_MAX ) );
 
403
                                    fInputSoftChannels[c][s] = jack_default_audio_sample_t(chan16b[s]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(SHRT_MAX));
404
404
                            }
405
405
                        }
406
406
                        else   // SND_PCM_FORMAT_S32
410
410
                            {
411
411
                                chan32b = ( int32_t* ) fInputCardChannels[c];
412
412
                                for ( s = 0; s < fBuffering; s++ )
413
 
                                    fInputSoftChannels[c][s] = float ( chan32b[s] ) * ( 1.0/float ( INT_MAX ) );
 
413
                                    fInputSoftChannels[c][s] = jack_default_audio_sample_t(chan32b[s]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(INT_MAX));
414
414
                            }
415
415
                        }
416
416
                        break;
440
440
                            {
441
441
                                for ( unsigned int c = 0; c < fCardOutputs; c++ )
442
442
                                {
443
 
                                    float x = fOutputSoftChannels[c][f];
444
 
                                    buffer16b[c + f * fCardOutputs] = short ( max ( min ( x, 1.0 ), -1.0 ) * float ( SHRT_MAX ) );
 
443
                                    jack_default_audio_sample_t x = fOutputSoftChannels[c][f];
 
444
                                    buffer16b[c + f * fCardOutputs] = short(max(min (x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(SHRT_MAX));
445
445
                                }
446
446
                            }
447
447
                        }
452
452
                            {
453
453
                                for ( unsigned int c = 0; c < fCardOutputs; c++ )
454
454
                                {
455
 
                                    float x = fOutputSoftChannels[c][f];
456
 
                                    buffer32b[c + f * fCardOutputs] = int32_t ( max ( min ( x, 1.0 ), -1.0 ) * float ( INT_MAX ) );
 
455
                                    jack_default_audio_sample_t x = fOutputSoftChannels[c][f];
 
456
                                    buffer32b[c + f * fCardOutputs] = int32_t(max(min(x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(INT_MAX));
457
457
                                }
458
458
                            }
459
459
                        }
474
474
                                short* chan16b = ( short* ) fOutputCardChannels[c];
475
475
                                for ( f = 0; f < fBuffering; f++ )
476
476
                                {
477
 
                                    float x = fOutputSoftChannels[c][f];
478
 
                                    chan16b[f] = short ( max ( min ( x,1.0 ), -1.0 ) * float ( SHRT_MAX ) ) ;
 
477
                                    jack_default_audio_sample_t x = fOutputSoftChannels[c][f];
 
478
                                    chan16b[f] = short(max(min (x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(SHRT_MAX));
479
479
                                }
480
480
                            }
481
481
                        }
486
486
                                int32_t* chan32b = ( int32_t* ) fOutputCardChannels[c];
487
487
                                for ( f = 0; f < fBuffering; f++ )
488
488
                                {
489
 
                                    float x = fOutputSoftChannels[c][f];
490
 
                                    chan32b[f] = int32_t ( max ( min ( x,1.0 ),-1.0 ) * float ( INT_MAX ) ) ;
 
489
                                    jack_default_audio_sample_t x = fOutputSoftChannels[c][f];
 
490
                                    chan32b[f] = int32_t(max(min(x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(INT_MAX));
491
491
                                }
492
492
                            }
493
493
                        }