Package list squeezelite / fresh-snapshots/main
New upstream snapshot. Debian Janitor 7 months ago
24 changed file(s) with 189 addition(s) and 110 deletion(s). Raw diff Collapse all Expand all
0 # OSX 10.5 Intel 32-bit
1 OPTS = -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DGPIO -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./include -I./include/opus -I./include/alac -O2 -I./include -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386
0 # OSX 10.7 Intel 32-bit
1 OPTS = -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./include -I./include/opus -I./include/alac -I./include -O3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch i386 -mmacosx-version-min=10.7
22
3 LDFLAGS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch i386 -mmacosx-version-min=10.5 -L./lib
3 LDFLAGS = -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch i386 -mmacosx-version-min=10.7 -L./lib
44
55 LDADD = -lportaudio -lpthread -ldl -lm -framework CoreVideo -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon
66
0 # OSX 11.0+ arm64 only
1 OPTS = -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./includem1 -I./includem1/opus -I./includem1/alac -arch arm64 -O3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11.0
2
3 LDFLAGS = -arch arm64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -L./libm1
4
5 LDADD = -lportaudio -lpthread -ldl -lm -framework CoreVideo -framework VideoDecodeAcceleration -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon
6
7 include Makefile
00 # OSX 10.7+ 64-bit only
1 OPTS = -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DGPIO -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./include64 -I./include64/opus -I./include64/alac -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -mmacosx-version-min=10.7
1 OPTS = -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./include64 -I./include64/opus -I./include64/alac -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -mmacosx-version-min=10.7
22
33 LDFLAGS = -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -mmacosx-version-min=10.7 -L./lib64
44
119119 // extract audio config from within alac
120120 if (!strcmp(type, "alac") && bytes > len) {
121121 u8_t *ptr = streambuf->readp + 36;
122 l->decoder = alac_create_decoder(len - 36, ptr, &l->sample_size, &l->sample_rate, &l->channels);
123 l->play = l->trak;
122 unsigned int block_size;
123 l->play = l->trak;
124 l->decoder = alac_create_decoder(len - 36, ptr, &l->sample_size, &l->sample_rate, &l->channels, &block_size);
125 l->writebuf = malloc(block_size + 256);
126 LOG_INFO("allocated write buffer of %u bytes", block_size);
127 if (!l->writebuf) {
128 LOG_ERROR("allocation failed");
129 return -1;
130 }
124131 }
125132
126133 // extract the total number of samples from stts
375382
376383 // need to create a buffer with contiguous data
377384 if (bytes < block_size) {
378 u8_t *buffer = malloc(block_size);
379 memcpy(buffer, streambuf->readp, bytes);
380 memcpy(buffer + bytes, streambuf->buf, block_size - bytes);
381 iptr = buffer;
385 iptr = malloc(block_size);
386 memcpy(iptr, streambuf->readp, bytes);
387 memcpy(iptr + bytes, streambuf->buf, block_size - bytes);
382388 } else iptr = streambuf->readp;
383389
384390 if (!alac_to_pcm(l->decoder, iptr, l->writebuf, 2, &frames)) {
473479 }
474480 } else if (l->sample_size == 16) {
475481 u16_t *_iptr = (u16_t*) iptr;
482 iptr += count * 4;
476483 while (count--) {
477484 *optr++ = ALIGN16(*_iptr++);
478485 *optr++ = ALIGN16(*_iptr++);
485492 }
486493 } else if (l->sample_size == 32) {
487494 u32_t *_iptr = (u32_t*) iptr;
495 iptr += count * 8;
488496 while (count--) {
489497 *optr++ = ALIGN32(*_iptr++);
490498 *optr++ = ALIGN32(*_iptr++);
510518 return DECODE_RUNNING;
511519 }
512520
513 static void alac_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
514 if (l->decoder) alac_delete_decoder(l->decoder);
515 else l->writebuf = malloc(BLOCK_SIZE * 2);
516
521 static void alac_close(void) {
522 if (l->decoder) alac_delete_decoder(l->decoder);
523 if (l->writebuf) free(l->writebuf);
517524 if (l->chunkinfo) free(l->chunkinfo);
518525 if (l->block_size) free(l->block_size);
519526 if (l->stsc) free(l->stsc);
520 l->decoder = l->chunkinfo = l->stsc = l->block_size = NULL;
521 l->skip = 0;
522 l->samples = l->sttssamples = 0;
523 l->empty = false;
524 l->pos = l->consume = l->sample = l->nextchunk = 0;
527 memset(l, 0, sizeof(struct alac));
525528 }
526529
527 static void alac_close(void) {
528 if (l->decoder) alac_delete_decoder(l->decoder);
529 if (l->chunkinfo) free(l->chunkinfo);
530 if (l->block_size) free(l->block_size);
531 if (l->stsc) free(l->stsc);
532 l->decoder = l->chunkinfo = l->stsc = l->block_size = NULL;
533 free(l->writebuf);
530 static void alac_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
531 alac_close();
534532 }
535533
536534 struct codec *register_alac(void) {
543541 alac_close, // close
544542 alac_decode, // decode
545543 };
546
547 l = malloc(sizeof(struct alac));
548 if (!l) {
549 return NULL;
550 }
551
552 l->decoder = l->chunkinfo = l->stsc = l->block_size = NULL;
553
544
545 l = calloc(1, sizeof(struct alac));
546 if (!l) return NULL;
547
554548 LOG_INFO("using alac to decode alc");
555549 return &ret;
556550 }
3131 /*----------------------------------------------------------------------------*/
3232 extern "C" struct alac_codec_s *alac_create_decoder(int magic_cookie_size, unsigned char *magic_cookie,
3333 unsigned char *sample_size, unsigned *sample_rate,
34 unsigned char *channels) {
34 unsigned char *channels, unsigned int *block_size) {
3535 struct alac_codec_s *codec = (struct alac_codec_s*) malloc(sizeof(struct alac_codec_s));
3636
3737 codec->Decoder = new ALACDecoder;
4242 *sample_size = codec->Decoder->mConfig.bitDepth;
4343
4444 codec->frames_per_packet = codec->Decoder->mConfig.frameLength;
45 codec->block_size = codec->frames_per_packet * (*channels) * (*sample_size) / 8;
45 *block_size = codec->block_size = codec->frames_per_packet * (*channels) * (*sample_size) / 8;
4646
4747 return codec;
4848 }
2727
2828 struct alac_codec_s *alac_create_decoder(int magic_cookie_size, unsigned char *magic_cookie,
2929 unsigned char *sample_size, unsigned *sample_rate,
30 unsigned char *channels);
30 unsigned char *channels, unsigned int *block_size);
3131 void alac_delete_decoder(struct alac_codec_s *codec);
3232 bool alac_to_pcm(struct alac_codec_s *codec, unsigned char* input,
3333 unsigned char *output, char channels, unsigned *out_frames);
2626
2727 // _* called with muxtex locked
2828
29 inline unsigned _buf_used(struct buffer *buf) {
29 #if !WIN
30 inline
31 #endif
32 unsigned _buf_used(struct buffer *buf) {
3033 return buf->writep >= buf->readp ? buf->writep - buf->readp : buf->size - (buf->readp - buf->writep);
3134 }
3235
0 squeezelite (1.9+git20211106.3ffdbb9-1) UNRELEASED; urgency=low
1
2 * New upstream snapshot.
3
4 -- Debian Janitor <janitor@jelmer.uk> Sat, 13 Nov 2021 19:20:43 -0000
5
06 squeezelite (1.9+git20210102.78fef68-3) unstable; urgency=medium
17
28 * Upload to unstable.
122122
123123 *want = bytes;
124124
125 // if there's nothing in the stream buffer, libFLAC will continuously call this function as quickly as possible. slow it down.
126 if (!bytes && !end)
127 usleep(1000);
128
125129 return end ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
126130 }
127131
132132 { "KEY_DOWN", 0x7689b04f, true },
133133 { "KEY_HOME", 0x768922dd, false },
134134 { "KEY_MEDIA_REPEAT", 0x768938c7, false },
135 { "KEY_AGAIN", 0x768938c7, false },
135136 // { "KEY_TITLE", 0x76897887, false }, // Now Playing
136137 // { "KEY_TITLE", 0x7689a25d, false }, // Now Playing
137138 // { "KEY_TEXT", 0x7689f807, false }, // Size
138138 #if LINUX || FREEBSD || SUN
139139 " -z \t\t\tDaemonize\n"
140140 #endif
141 #if RESAMPLE
142141 " -Z <rate>\t\tReport rate to server in helo as the maximum sample rate we can support\n"
143 #endif
144142 " -t \t\t\tLicense terms\n"
145143 " -? \t\t\tDisplay this help text\n"
146144 "\n"
349347
350348 while (optind < argc && strlen(argv[optind]) >= 2 && argv[optind][0] == '-') {
351349 char *opt = argv[optind] + 1;
352 if (strstr("oabcCdefmMnNpPrs"
350 if (strstr("oabcCdefmMnNpPrsZ"
353351 #if ALSA
354352 "UVO"
355 #endif
356 /*
357 * only allow '-Z <rate>' override of maxSampleRate
358 * reported by client if built with the capability to resample!
359 */
360 #if RESAMPLE
361 "Z"
362353 #endif
363354 , opt) && optind < argc - 1) {
364355 optarg = argv[optind + 1];
525516 case 'N':
526517 namefile = optarg;
527518 break;
519 case 'Z':
520 maxSampleRate = atoi(optarg);
521 break;
528522 case 'W':
529523 pcm_check_header = true;
530524 break;
555549 } else {
556550 resample = "";
557551 }
558 break;
559 case 'Z':
560 maxSampleRate = atoi(optarg);
561552 break;
562553 #endif
563554 #if DSD
188188
189189 // work backward to unpack samples (if needed)
190190 iptr = (s16_t *) write_buf + count;
191 optr = (ISAMPLE_T *) write_buf + frames * 2;
191 IF_DIRECT(
192 optr = (ISAMPLE_T *) outputbuf->writep + frames * 2;
193 )
194 IF_PROCESS(
195 optr = (ISAMPLE_T *) write_buf + frames * 2;
196 )
192197
193198 if (channels == 2) {
194199 #if BYTES_PER_FRAME == 4
224229 if (stream.state <= DISCONNECT) {
225230 LOG_INFO("partial decode");
226231 UNLOCK_O_direct;
227 UNLOCK_S;
228232 return DECODE_COMPLETE;
229233 } else {
230234 LOG_INFO("no frame decoded");
4646
4747 frames_t frames, size;
4848 bool silence;
49 u8_t flags = output.channels;
4950
5051 s32_t cross_gain_in = 0, cross_gain_out = 0; s32_t *cross_ptr = NULL;
5152
5859 silence = false;
5960
6061 // start when threshold met
61 if (output.state == OUTPUT_BUFFER && frames > output.threshold * output.next_sample_rate / 10 && frames > output.start_frames) {
62 if (output.state == OUTPUT_BUFFER && (frames * BYTES_PER_FRAME) > output.threshold * output.next_sample_rate / 10 && frames > output.start_frames) {
6263 output.state = OUTPUT_RUNNING;
6364 LOG_INFO("start buffer frames: %u", frames);
6465 wake_controller();
255256 }
256257
257258 out_frames = !silence ? min(size, cont_frames) : size;
258
259 wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);
259
260 IF_DSD(
261 if (output.outfmt != PCM) {
262 flags = 0;
263 }
264 )
265
266 wrote = output.write_cb(out_frames, silence, gainL, gainR, flags, cross_gain_in, cross_gain_out, &cross_ptr);
260267
261268 if (wrote <= 0) {
262269 frames -= size;
383390 output.idle_to = (u32_t) idle;
384391
385392 /* Skip test_open for stdout, set default sample rates */
386 if ( output.device[0] == '-' ) {
393 if ( output.device[0] == '-' || user_rates ) {
387394 for (i = 0; i < MAX_SUPPORTED_SAMPLERATES; ++i) {
388395 output.supported_rates[i] = rates[i];
389396 }
392399 if (!test_open(output.device, output.supported_rates, user_rates)) {
393400 LOG_ERROR("unable to open output device: %s", output.device);
394401 exit(0);
395 }
396 }
397
398 if (user_rates) {
399 for (i = 0; i < MAX_SUPPORTED_SAMPLERATES; ++i) {
400 output.supported_rates[i] = rates[i];
401402 }
402403 }
403404
296296 if (snd_pcm_hw_params_test_rate(pcm, hw_params, ref[i], 0) == 0) {
297297 rates[ind++] = ref[i];
298298 }
299 else {
300 LOG_DEBUG("sample rate %u not supported", ref[i]);
301 }
299302 }
300303 }
301304
546549 return 0;
547550 }
548551
549 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
552 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags,
550553 s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) {
551554
552555 const snd_pcm_channel_area_t *areas;
593596
594597 outputptr = alsa.mmap ? (areas[0].addr + (areas[0].first + offset * areas[0].step) / 8) : alsa.write_buf;
595598
596 _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, output.format);
599 _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, flags, output.format);
597600
598601 } else {
599602
600603 outputptr = (void *)inputptr;
601604
602605 if (!silence) {
603
604 if (gainL != FIXED_ONE || gainR!= FIXED_ONE) {
605 _apply_gain(outputbuf, out_frames, gainL, gainR);
606 }
606 _apply_gain(outputbuf, out_frames, gainL, gainR, flags);
607607 }
608608 }
609609
675675 #if GPIO
676676 // Wake up amp
677677 if (gpio_active) {
678 ampstate = 1;
679678 relay(1);
680679 }
681680 if (power_script != NULL) {
682 ampstate = 1;
683681 relay_script(1);
684682 }
685683 #endif
809807 #if GPIO
810808 // Put Amp to Sleep
811809 if (gpio_active){
812 ampstate = 0;
813810 relay(0);
814811 }
815812 if (power_script != NULL ){
816 ampstate = 0;
817813 relay_script(0);
818814 }
819815 #endif
213213 #endif
214214 switch (err) {
215215 case paInvalidSampleRate:
216 LOG_DEBUG("sample rate %u not supported", ref[i]);
216217 continue;
217218 #if WIN
218219 #ifndef PA18API
447448
448449 static u8_t *optr;
449450
450 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
451 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags,
451452 s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) {
452453
453454 if (!silence) {
457458 }
458459
459460 if (gainL != FIXED_ONE || gainR!= FIXED_ONE) {
460 _apply_gain(outputbuf, out_frames, gainL, gainR);
461 _apply_gain(outputbuf, out_frames, gainL, gainR, flags);
461462 }
462463
463464 IF_DSD(
4242 return (s32_t)(f * 65536.0F);
4343 }
4444
45 void _scale_and_pack_frames(void *outputptr, s32_t *inputptr, frames_t cnt, s32_t gainL, s32_t gainR, output_format format) {
45 void _scale_and_pack_frames(void *outputptr, s32_t *inputptr, frames_t cnt, s32_t gainL, s32_t gainR, u8_t flags, output_format format) {
46 // in-place copy input samples if mono/combined is used (never happens with DSD active)
47 if ((flags & MONO_LEFT) && (flags & MONO_RIGHT)) {
48 s32_t *ptr = inputptr;
49 frames_t count = cnt;
50 while (count--) {
51 // use 64 bits integer for purists but should really not care
52 *ptr = *(ptr + 1) = ((s64_t) *ptr + (s64_t) *(ptr + 1)) / 2;
53 ptr += 2;
54 }
55 } else if (flags & MONO_RIGHT) {
56 s32_t *ptr = inputptr + 1;
57 frames_t count = cnt;
58 while (count--) {
59 *(ptr - 1) = *ptr;
60 ptr += 2;
61 }
62 } else if (flags & MONO_LEFT) {
63 s32_t *ptr = inputptr;
64 frames_t count = cnt;
65 while (count--) {
66 *(ptr + 1) = *ptr;
67 ptr += 2;
68 }
69 }
70
4671 switch(format) {
4772 #if DSD
4873 case U32_LE:
352377 #if !WIN
353378 inline
354379 #endif
355 void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
356 s32_t *ptrL = (s32_t *)(void *)outputbuf->readp;
357 s32_t *ptrR = (s32_t *)(void *)outputbuf->readp + 1;
358 while (count--) {
359 *ptrL = gain(gainL, *ptrL);
360 *ptrR = gain(gainR, *ptrR);
361 ptrL += 2;
362 ptrR += 2;
380 void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR, u8_t flags) {
381 if (gainL == FIXED_ONE && gainR == FIXED_ONE && !(flags & (MONO_LEFT | MONO_RIGHT))) {
382 return;
383 } else if ((flags & MONO_LEFT) && (flags & MONO_RIGHT)) {
384 ISAMPLE_T *ptrL = (ISAMPLE_T *)(void *)outputbuf->readp;
385 ISAMPLE_T *ptrR = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
386 while (count--) {
387 *ptrL = *ptrR = (gain(gainL, *ptrL) + gain(gainR, *ptrR)) / 2;
388 ptrL += 2; ptrR += 2;
389 }
390
391 } else if (flags & MONO_RIGHT) {
392 ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
393 while (count--) {
394 *(ptr - 1) = *ptr = gain(gainR, *ptr);
395 ptr += 2;
396 }
397 } else if (flags & MONO_LEFT) {
398 ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
399 while (count--) {
400 *(ptr + 1) = *ptr = gain(gainL, *ptr);
401 ptr += 2;
402 }
403 } else {
404 ISAMPLE_T *ptrL = (ISAMPLE_T *)(void *)outputbuf->readp;
405 ISAMPLE_T *ptrR = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
406 while (count--) {
407 *ptrL = gain(gainL, *ptrL);
408 *ptrR = gain(gainR, *ptrR);
409 ptrL += 2; ptrR += 2;
410 }
363411 }
364412 }
361361 d->default_sink_name = strdup(l->name);
362362
363363 if (!d->userdef_rates) {
364 d->rates[0] = l->sample_spec.rate;
365 }
364 d->rates[0] = PA_RATE_MAX;
365 }
366 output.default_sample_rate = l->sample_spec.rate;
366367
367368 *d->sample_spec = l->sample_spec;
368369 }
385386 return true;
386387 }
387388
388 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
389 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags,
389390 s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) {
390391 pa_stream_write(pulse.stream, silence ? silencebuf : outputbuf->readp, out_frames * BYTES_PER_FRAME, (pa_free_cb_t)NULL, 0, PA_SEEK_RELATIVE);
391392 return (int)out_frames;
4444 static unsigned buffill;
4545 static int bytes_per_frame;
4646
47 static int _stdout_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
47 static int _stdout_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags,
4848 s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) {
4949
5050 u8_t *obuf;
7474 }
7575 )
7676
77 _scale_and_pack_frames(buf + buffill * bytes_per_frame, (s32_t *)(void *)obuf, out_frames, gainL, gainR, output.format);
77 _scale_and_pack_frames(buf + buffill * bytes_per_frame, (s32_t *)(void *)obuf, out_frames, gainL, gainR, flags, output.format);
7878
7979 buffill += out_frames;
8080
6262 #define MAX_DECODE_FRAMES 4096
6363
6464 static u32_t sample_rates[] = {
65 11025, 22050, 32000, 44100, 48000, 8000, 12000, 16000, 24000, 96000, 88200, 176400, 192000, 352800, 384000, 705600, 768000
65 11025, 22050, 32000, 44100, 48000, 8000, 12000, 16000, 24000, 96000, 88200, 176400, 192000, 352800, 384000, 705600, 768000, 1411200, 1536000
6666 };
6767
6868 static u32_t sample_rate;
119119 }
120120
121121 static void sendHELO(bool reconnect, const char *fixed_cap, const char *var_cap, u8_t mac[6]) {
122 #define BASE_CAP "Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=" VERSION
122 #define BASE_CAP "Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Firmware=" VERSION
123123 #define SSL_CAP "CanHTTPS=1"
124124 const char *base_cap;
125125 struct HELO_packet pkt;
379379 output.fade_mode = strm->transition_type - '0';
380380 output.fade_secs = strm->transition_period;
381381 output.invert = (strm->flags & 0x03) == 0x03;
382 LOG_DEBUG("set fade mode: %u", output.fade_mode);
382 output.channels = (strm->flags & 0x0c) >> 2;
383 LOG_DEBUG("set fade mode: %u, channels: %u, invert: %u", output.fade_mode, output.channels, output.invert);
383384 UNLOCK_O;
384385 }
385386 break;
874875
875876 LOCK_O;
876877 snprintf(fixed_cap, FIXED_CAP_LEN, ",ModelName=%s,MaxSampleRate=%u", modelname ? modelname : MODEL_NAME_STRING,
878 #if RESAMPLE
877879 ((maxSampleRate > 0) ? maxSampleRate : output.supported_rates[0]));
880 #else
881 ((maxSampleRate > 0 && maxSampleRate < output.supported_rates[0]) ? maxSampleRate : output.supported_rates[0]));
882 #endif
878883
879884 for (i = 0; i < MAX_CODECS; i++) {
880885 if (codecs[i] && codecs[i]->id && strlen(fixed_cap) < FIXED_CAP_LEN - 10) {
2424 // make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
2525
2626 #define MAJOR_VERSION "1.9"
27 #define MINOR_VERSION "8"
28 #define MICRO_VERSION "1317"
27 #define MINOR_VERSION "9"
28 #define MICRO_VERSION "1392"
2929
3030 #if defined(CUSTOM_VERSION)
3131 #define VERSION "v" MAJOR_VERSION "." MINOR_VERSION "-" MICRO_VERSION STR(CUSTOM_VERSION)
614614 typedef enum { FADE_UP = 1, FADE_DOWN, FADE_CROSS } fade_dir;
615615 typedef enum { FADE_NONE = 0, FADE_CROSSFADE, FADE_IN, FADE_OUT, FADE_INOUT } fade_mode;
616616
617 #define MAX_SUPPORTED_SAMPLERATES 18
618 #define TEST_RATES = { 768000, 705600, 384000, 352800, 192000, 176400, 96000, 88200, 48000, 44100, 32000, 24000, 22500, 16000, 12000, 11025, 8000, 0 }
617 #define MONO_RIGHT 0x02
618 #define MONO_LEFT 0x01
619 #define MAX_SUPPORTED_SAMPLERATES 20
620 #define TEST_RATES = { 1536000, 1411200, 768000, 705600, 384000, 352800, 192000, 176400, 96000, 88200, 48000, 44100, 32000, 24000, 22500, 16000, 12000, 11025, 8000, 0 }
619621
620622 struct outputstate {
621623 output_state state;
622624 output_format format;
625 u8_t channels;
623626 const char *device;
624627 #if ALSA
625628 unsigned buffer;
631634 unsigned latency;
632635 int pa_hostapi_option;
633636 #endif
634 int (* write_cb)(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr);
637 int (* write_cb)(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags, s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr);
635638 unsigned start_frames;
636639 unsigned frames_played;
637640 unsigned frames_played_dmp;// frames played at the point delay is measured
715718 void output_close_stdout(void);
716719
717720 // output_pack.c
718 void _scale_and_pack_frames(void *outputptr, s32_t *inputptr, frames_t cnt, s32_t gainL, s32_t gainR, output_format format);
721 void _scale_and_pack_frames(void *outputptr, s32_t *inputptr, frames_t cnt, s32_t gainL, s32_t gainR, u8_t flags, output_format format);
719722 void _apply_cross(struct buffer *outputbuf, frames_t out_frames, s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr);
720 void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR);
723 void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR, u8_t flags);
721724 s32_t gain(s32_t gain, s32_t sample);
722725 s32_t to_gain(float f);
723726
758761 struct codec *register_opus(void);
759762 #endif
760763
761 //gpio.c
764 // gpio.c
762765 #if GPIO
763 void relay( int state);
766 void relay(int state);
764767 void relay_script(int state);
765768 int gpio_pin;
766769 bool gpio_active_low;
767770 bool gpio_active;
768771 char *power_script;
769 // my amp state
770 int ampstate;
772
771773 #if RPI
772774 #define PI_INPUT 0
773775 #define PI_OUTPUT 1
106106
107107 unsigned try = 0;
108108 ssize_t n;
109 int error;
109110
110111 while (len) {
111112 n = _send(ssl, fd, ptr, len, MSG_NOSIGNAL);
112113 if (n <= 0) {
113 if (n < 0 && _last_error() == ERROR_WOULDBLOCK && try < 10) {
114 LOG_SDEBUG("retrying (%d) writing to socket", ++try);
114 error = _last_error();
115 #if WIN
116 if (n < 0 && (error == ERROR_WOULDBLOCK || error == WSAENOTCONN) && try < 10) {
117 #else
118 if (n < 0 && error == ERROR_WOULDBLOCK && try < 10) {
119 #endif
120 LOG_DEBUG("retrying (%d) writing to socket", ++try);
115121 usleep(1000);
116122 continue;
117123 }
118 LOG_INFO("failed writing to socket: %s", strerror(last_error()));
124 LOG_WARN("failed writing to socket: %s", strerror(last_error()));
119125 stream.disconnect = LOCAL_DISCONNECT;
120126 stream.state = DISCONNECT;
121127 wake_controller();
394400
395401 n = _recv(ssl, fd, streambuf->writep, space, 0);
396402 if (n == 0) {
397 LOG_INFO("end of stream");
403 LOG_INFO("end of stream (%u bytes)", stream.bytes);
398404 _disconnect(DISCONNECT, DISCONNECT_OK);
399405 }
400406 if (n < 0 && _last_error() != ERROR_WOULDBLOCK) {
556562
557563 *host = '\0';
558564 p = strcasestr(header,"Host:");
559 if (p) sscanf(p, "Host:%255[^:]", host);
565 if (p) {
566 sscanf(p, "Host:%255s", host);
567 if ((p = strchr(host, ':')) != NULL) *p = '\0';
568 }
560569
561570 port = ntohs(port);
562571 sock = connect_socket(use_ssl || port == 443);
488488 }
489489 #endif
490490
491 #if WIN && USE_SSL
491 #if WIN
492492 char *strcasestr(const char *haystack, const char *needle) {
493493 size_t length_needle;
494494 size_t length_haystack;
235235
236236 // work backward to unpack samples (if needed)
237237 iptr = (s16_t *) write_buf + count;
238 optr = (ISAMPLE_T *) write_buf + frames * 2;
238 IF_DIRECT(
239 optr = (ISAMPLE_T *) outputbuf->writep + frames * 2;
240 )
241 IF_PROCESS(
242 optr = (ISAMPLE_T *) write_buf + frames * 2;
243 )
239244
240245 if (channels == 2) {
241246 #if BYTES_PER_FRAME == 4