~ubuntu-branches/ubuntu/wily/squeezelite/wily

« back to all changes in this revision

Viewing changes to output.c

  • Committer: Package Import Robot
  • Author(s): Chris Boot
  • Date: 2015-05-12 19:56:54 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150512195654-z4pb7qxxp0vo4r85
Tags: 1.8-1
* New upstream release.
  - Refresh patches for Makefile changes.
  - Should fix a crash when resampling. (Closes: #774524)
* Tweak debian/copyright based on debmake -k's suggestions.
* Enable LIRC support.
* Bump standards version to 3.8.6 (no changes required).
* Update debian/man/squeezelite.1 to document new features/options added
  since 1.6.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
2
 *  Squeezelite - lightweight headless squeezebox emulator
3
3
 *
4
 
 *  (c) Adrian Smith 2012-2014, triode1@btinternet.com
 
4
 *  (c) Adrian Smith 2012-2015, triode1@btinternet.com
5
5
 *
6
6
 * This program is free software: you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
49
49
        
50
50
        s32_t gainL = output.current_replay_gain ? gain(output.gainL, output.current_replay_gain) : output.gainL;
51
51
        s32_t gainR = output.current_replay_gain ? gain(output.gainR, output.current_replay_gain) : output.gainR;
52
 
        
 
52
 
 
53
        if (output.invert) { gainL = -gainL; gainR = -gainR; }
 
54
 
53
55
        frames = _buf_used(outputbuf) / BYTES_PER_FRAME;
54
56
        silence = false;
55
57
 
220
222
                                                fade_gain = to_gain((float)cur_f / (float)dur_f);
221
223
                                                gainL = gain(gainL, fade_gain);
222
224
                                                gainR = gain(gainR, fade_gain);
 
225
                                                if (output.invert) { gainL = -gainL; gainR = -gainR; }
223
226
                                        }
224
227
                                        if (output.fade_dir == FADE_CROSS) {
225
228
                                                // cross fade requires special treatment - performed later based on these values
235
238
                                                        }
236
239
                                                        gainL = output.gainL;
237
240
                                                        gainR = output.gainR;
 
241
                                                        if (output.invert) { gainL = -gainL; gainR = -gainR; }
238
242
                                                        cross_ptr = (s32_t *)(output.fade_end + cur_f * BYTES_PER_FRAME);
239
243
                                                } else {
240
244
                                                        LOG_INFO("unable to continue crossfade - too few samples");
333
337
        }
334
338
}
335
339
 
336
 
void output_init_common(log_level level, const char *device, unsigned output_buf_size, unsigned rates[]) {
 
340
void output_init_common(log_level level, const char *device, unsigned output_buf_size, unsigned rates[], unsigned idle) {
337
341
        unsigned i;
338
342
 
339
343
        loglevel = level;
363
367
                dop_silence_frames((u32_t *)silencebuf_dop, MAX_SILENCE_FRAMES);
364
368
        )
365
369
 
366
 
        output.state = OUTPUT_STOPPED;
 
370
        LOG_DEBUG("idle timeout: %u", idle);
 
371
 
 
372
        output.state = idle ? OUTPUT_OFF: OUTPUT_STOPPED;
367
373
        output.device = device;
368
374
        output.fade = FADE_INACTIVE;
 
375
        output.invert = false;
369
376
        output.error_opening = false;
 
377
        output.idle_to = (u32_t) idle;
370
378
 
371
379
        if (!rates[0]) {
372
380
                if (!test_open(output.device, output.supported_rates)) {
387
395
                }
388
396
        }
389
397
        if (!output.default_sample_rate) {
390
 
                output.default_sample_rate = rates[0];
 
398
                output.default_sample_rate = output.supported_rates[0];
391
399
        }
392
400
        
393
401
        output.current_sample_rate = output.default_sample_rate;