bump version and year
add configurable delay switching between dop and pcm
Adrian Smith
10 years ago
0 | 0 | Squeezelite - lightweight headless squeezebox emulator |
1 | 1 | |
2 | (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
2 | (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
3 | 3 | |
4 | 4 | Released under GPLv3 license: |
5 | 5 |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | void dop_init(bool enable) { | |
83 | void dop_init(bool enable, unsigned delay) { | |
84 | 84 | LOCK_O; |
85 | 85 | output.has_dop = enable; |
86 | output.dop_delay = delay; | |
86 | 87 | UNLOCK_O; |
87 | 88 | } |
88 | 89 |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
214 | 214 | unsigned bytes_per_frame = dop ? 2 : 1; |
215 | 215 | |
216 | 216 | if (bytes < d->block_size * d->channels) { |
217 | LOG_WARN("stream too short"); | |
218 | return DECODE_ERROR; | |
217 | LOG_INFO("stream too short"); // this can occur when scanning the track | |
218 | return DECODE_COMPLETE; | |
219 | 219 | } |
220 | 220 | |
221 | 221 | IF_PROCESS( |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
21 | 21 | |
22 | 22 | #include <signal.h> |
23 | 23 | |
24 | #define TITLE "Squeezelite " VERSION ", Copyright 2012, 2013 Adrian Smith." | |
24 | #define TITLE "Squeezelite " VERSION ", Copyright 2012-2014 Adrian Smith." | |
25 | 25 | |
26 | 26 | static void usage(const char *argv0) { |
27 | 27 | printf(TITLE " See -t for license terms\n" |
67 | 67 | " \t\t\t phase_response = 0-100 (0 = minimum / 50 = linear / 100 = maximum)\n" |
68 | 68 | #endif |
69 | 69 | #if DSD |
70 | " -D\t\t\tOutput device supports DSD over PCM (DoP)\n" | |
70 | " -D [delay]\t\tOutput device supports DSD over PCM (DoP), delay = optional delay switching between PCM and DoP in ms\n" | |
71 | 71 | #endif |
72 | 72 | #if VISEXPORT |
73 | 73 | " -v \t\t\tVisulizer support\n" |
168 | 168 | #endif |
169 | 169 | #if DSD |
170 | 170 | bool dop = false; |
171 | unsigned dop_delay = 0; | |
171 | 172 | #endif |
172 | 173 | #if VISEXPORT |
173 | 174 | bool visexport = false; |
330 | 331 | #if DSD |
331 | 332 | case 'D': |
332 | 333 | dop = true; |
334 | if (optind < argc && argv[optind] && argv[optind][0] != '-') { | |
335 | dop_delay = atoi(argv[optind++]); | |
336 | } | |
333 | 337 | break; |
334 | 338 | #endif |
335 | 339 | #if VISEXPORT |
405 | 409 | } |
406 | 410 | |
407 | 411 | #if DSD |
408 | dop_init(dop); | |
412 | dop_init(dop, dop_delay); | |
409 | 413 | #endif |
410 | 414 | |
411 | 415 | #if VISEXPORT |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
118 | 118 | |
119 | 119 | if (output.track_start && !silence) { |
120 | 120 | if (output.track_start == outputbuf->readp) { |
121 | frames -= size; | |
122 | IF_DSD( | |
123 | if (output.dop != output.next_dop) { | |
124 | if (output.dop_delay) { | |
125 | // add silence delay in two halves, before and after track start and pcm-dop change | |
126 | if (!output.dop_delay_active) { | |
127 | output.pause_frames = output.current_sample_rate * output.dop_delay / 2000; | |
128 | output.dop_delay_active = true; // first delay - don't process track start | |
129 | break; | |
130 | } else { | |
131 | output.pause_frames = output.next_sample_rate * output.dop_delay / 2000; | |
132 | output.dop_delay_active = false; // second delay - process track start | |
133 | } | |
134 | output.state = OUTPUT_PAUSE_FRAMES; | |
135 | } | |
136 | } | |
137 | output.dop = output.next_dop; | |
138 | ) | |
121 | 139 | LOG_INFO("track start sample rate: %u replay_gain: %u", output.next_sample_rate, output.next_replay_gain); |
122 | 140 | output.frames_played = 0; |
123 | 141 | output.track_started = true; |
124 | 142 | output.current_sample_rate = output.next_sample_rate; |
125 | IF_DSD( output.dop = output.next_dop; ) | |
126 | 143 | if (!output.fade == FADE_ACTIVE || !output.fade_mode == FADE_CROSSFADE) { |
127 | 144 | output.current_replay_gain = output.next_replay_gain; |
128 | 145 | } |
129 | 146 | output.track_start = NULL; |
130 | continue; | |
147 | break; | |
131 | 148 | } else if (output.track_start > outputbuf->readp) { |
132 | 149 | // reduce cont_frames so we find the next track start at beginning of next chunk |
133 | 150 | cont_frames = min(cont_frames, (output.track_start - outputbuf->readp) / BYTES_PER_FRAME); |
396 | 413 | if (output.error_opening) { |
397 | 414 | output.current_sample_rate = output.default_sample_rate; |
398 | 415 | } |
416 | IF_DSD( output.dop_delay_active = false; ) | |
399 | 417 | } |
400 | 418 | output.frames_played = 0; |
401 | 419 | UNLOCK; |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
531 | 531 | continue; |
532 | 532 | } |
533 | 533 | LOG_INFO("start error: %s", snd_strerror(err)); |
534 | usleep(10000); | |
534 | 535 | } |
535 | 536 | } else { |
536 | 537 | start = false; |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
19 | 19 | |
20 | 20 | // make may define: PORTAUDIO, SELFPIPE, RESAMPLE, VISEXPORT, DSD, LINKALL to influence build |
21 | 21 | |
22 | #define VERSION "v1.4" | |
22 | #define VERSION "v1.5-dev" | |
23 | 23 | |
24 | 24 | // build detection |
25 | 25 | #if defined(linux) |
527 | 527 | bool next_dop; // set in decode thread |
528 | 528 | bool dop; |
529 | 529 | bool has_dop; // set in dop_init - output device supports dop |
530 | unsigned dop_delay; // set in dop_init - delay in ms switching to/from dop | |
531 | bool dop_delay_active; | |
530 | 532 | #endif |
531 | 533 | }; |
532 | 534 | |
580 | 582 | bool is_flac_dop(u32_t *lptr, u32_t *rptr, frames_t frames); |
581 | 583 | void update_dop_marker(u32_t *ptr, frames_t frames); |
582 | 584 | void dop_silence_frames(u32_t *ptr, frames_t frames); |
583 | void dop_init(bool enable); | |
585 | void dop_init(bool enable, unsigned delay); | |
584 | 586 | #endif |
585 | 587 | |
586 | 588 | // codecs |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
0 | 0 | /* |
1 | 1 | * Squeezelite - lightweight headless squeezebox emulator |
2 | 2 | * |
3 | * (c) Adrian Smith 2012, 2013, triode1@btinternet.com | |
3 | * (c) Adrian Smith 2012-2014, triode1@btinternet.com | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |