Codebase list squeezelite / 80b66f6
bump version and year add configurable delay switching between dop and pcm Adrian Smith 10 years ago
25 changed file(s) with 60 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
00 Squeezelite - lightweight headless squeezebox emulator
11
2 (c) Adrian Smith 2012, 2013, triode1@btinternet.com
2 (c) Adrian Smith 2012-2014, triode1@btinternet.com
33
44 Released under GPLv3 license:
55
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
8080 }
8181 }
8282
83 void dop_init(bool enable) {
83 void dop_init(bool enable, unsigned delay) {
8484 LOCK_O;
8585 output.has_dop = enable;
86 output.dop_delay = delay;
8687 UNLOCK_O;
8788 }
8889
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
214214 unsigned bytes_per_frame = dop ? 2 : 1;
215215
216216 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;
219219 }
220220
221221 IF_PROCESS(
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
2121
2222 #include <signal.h>
2323
24 #define TITLE "Squeezelite " VERSION ", Copyright 2012, 2013 Adrian Smith."
24 #define TITLE "Squeezelite " VERSION ", Copyright 2012-2014 Adrian Smith."
2525
2626 static void usage(const char *argv0) {
2727 printf(TITLE " See -t for license terms\n"
6767 " \t\t\t phase_response = 0-100 (0 = minimum / 50 = linear / 100 = maximum)\n"
6868 #endif
6969 #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"
7171 #endif
7272 #if VISEXPORT
7373 " -v \t\t\tVisulizer support\n"
168168 #endif
169169 #if DSD
170170 bool dop = false;
171 unsigned dop_delay = 0;
171172 #endif
172173 #if VISEXPORT
173174 bool visexport = false;
330331 #if DSD
331332 case 'D':
332333 dop = true;
334 if (optind < argc && argv[optind] && argv[optind][0] != '-') {
335 dop_delay = atoi(argv[optind++]);
336 }
333337 break;
334338 #endif
335339 #if VISEXPORT
405409 }
406410
407411 #if DSD
408 dop_init(dop);
412 dop_init(dop, dop_delay);
409413 #endif
410414
411415 #if VISEXPORT
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
118118
119119 if (output.track_start && !silence) {
120120 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 )
121139 LOG_INFO("track start sample rate: %u replay_gain: %u", output.next_sample_rate, output.next_replay_gain);
122140 output.frames_played = 0;
123141 output.track_started = true;
124142 output.current_sample_rate = output.next_sample_rate;
125 IF_DSD( output.dop = output.next_dop; )
126143 if (!output.fade == FADE_ACTIVE || !output.fade_mode == FADE_CROSSFADE) {
127144 output.current_replay_gain = output.next_replay_gain;
128145 }
129146 output.track_start = NULL;
130 continue;
147 break;
131148 } else if (output.track_start > outputbuf->readp) {
132149 // reduce cont_frames so we find the next track start at beginning of next chunk
133150 cont_frames = min(cont_frames, (output.track_start - outputbuf->readp) / BYTES_PER_FRAME);
396413 if (output.error_opening) {
397414 output.current_sample_rate = output.default_sample_rate;
398415 }
416 IF_DSD( output.dop_delay_active = false; )
399417 }
400418 output.frames_played = 0;
401419 UNLOCK;
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
531531 continue;
532532 }
533533 LOG_INFO("start error: %s", snd_strerror(err));
534 usleep(10000);
534535 }
535536 } else {
536537 start = false;
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
1919
2020 // make may define: PORTAUDIO, SELFPIPE, RESAMPLE, VISEXPORT, DSD, LINKALL to influence build
2121
22 #define VERSION "v1.4"
22 #define VERSION "v1.5-dev"
2323
2424 // build detection
2525 #if defined(linux)
527527 bool next_dop; // set in decode thread
528528 bool dop;
529529 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;
530532 #endif
531533 };
532534
580582 bool is_flac_dop(u32_t *lptr, u32_t *rptr, frames_t frames);
581583 void update_dop_marker(u32_t *ptr, frames_t frames);
582584 void dop_silence_frames(u32_t *ptr, frames_t frames);
583 void dop_init(bool enable);
585 void dop_init(bool enable, unsigned delay);
584586 #endif
585587
586588 // codecs
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
00 /*
11 * Squeezelite - lightweight headless squeezebox emulator
22 *
3 * (c) Adrian Smith 2012, 2013, triode1@btinternet.com
3 * (c) Adrian Smith 2012-2014, triode1@btinternet.com
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by