* New upstream version 1.9+git20210513.556de56
Identifies player as "Firmware: v1.9.9-1386"
* Update debian/gbp.conf for debian/latest (DEP-14)
* Bump Standards-Version to 4.6.0
tony mancill authored 1 year, 7 months ago
Debian Janitor committed 1 year, 7 months ago
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 | |
2 | 2 | |
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 | |
4 | 4 | |
5 | 5 | LDADD = -lportaudio -lpthread -ldl -lm -framework CoreVideo -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon |
6 | 6 |
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/MacOSX11.1.sdk -mmacosx-version-min=11.0 | |
2 | ||
3 | LDFLAGS = -arch arm64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.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 |
0 | 0 | # 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 | |
2 | 2 | |
3 | 3 | 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 |
4 | 4 |
119 | 119 | // extract audio config from within alac |
120 | 120 | if (!strcmp(type, "alac") && bytes > len) { |
121 | 121 | 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 | } | |
124 | 131 | } |
125 | 132 | |
126 | 133 | // extract the total number of samples from stts |
375 | 382 | |
376 | 383 | // need to create a buffer with contiguous data |
377 | 384 | 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); | |
382 | 388 | } else iptr = streambuf->readp; |
383 | 389 | |
384 | 390 | if (!alac_to_pcm(l->decoder, iptr, l->writebuf, 2, &frames)) { |
473 | 479 | } |
474 | 480 | } else if (l->sample_size == 16) { |
475 | 481 | u16_t *_iptr = (u16_t*) iptr; |
482 | iptr += count * 4; | |
476 | 483 | while (count--) { |
477 | 484 | *optr++ = ALIGN16(*_iptr++); |
478 | 485 | *optr++ = ALIGN16(*_iptr++); |
485 | 492 | } |
486 | 493 | } else if (l->sample_size == 32) { |
487 | 494 | u32_t *_iptr = (u32_t*) iptr; |
495 | iptr += count * 8; | |
488 | 496 | while (count--) { |
489 | 497 | *optr++ = ALIGN32(*_iptr++); |
490 | 498 | *optr++ = ALIGN32(*_iptr++); |
510 | 518 | return DECODE_RUNNING; |
511 | 519 | } |
512 | 520 | |
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); | |
517 | 524 | if (l->chunkinfo) free(l->chunkinfo); |
518 | 525 | if (l->block_size) free(l->block_size); |
519 | 526 | 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)); | |
525 | 528 | } |
526 | 529 | |
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(); | |
534 | 532 | } |
535 | 533 | |
536 | 534 | struct codec *register_alac(void) { |
543 | 541 | alac_close, // close |
544 | 542 | alac_decode, // decode |
545 | 543 | }; |
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 | ||
554 | 548 | LOG_INFO("using alac to decode alc"); |
555 | 549 | return &ret; |
556 | 550 | } |
31 | 31 | /*----------------------------------------------------------------------------*/ |
32 | 32 | extern "C" struct alac_codec_s *alac_create_decoder(int magic_cookie_size, unsigned char *magic_cookie, |
33 | 33 | unsigned char *sample_size, unsigned *sample_rate, |
34 | unsigned char *channels) { | |
34 | unsigned char *channels, unsigned int *block_size) { | |
35 | 35 | struct alac_codec_s *codec = (struct alac_codec_s*) malloc(sizeof(struct alac_codec_s)); |
36 | 36 | |
37 | 37 | codec->Decoder = new ALACDecoder; |
42 | 42 | *sample_size = codec->Decoder->mConfig.bitDepth; |
43 | 43 | |
44 | 44 | 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; | |
46 | 46 | |
47 | 47 | return codec; |
48 | 48 | } |
27 | 27 | |
28 | 28 | struct alac_codec_s *alac_create_decoder(int magic_cookie_size, unsigned char *magic_cookie, |
29 | 29 | unsigned char *sample_size, unsigned *sample_rate, |
30 | unsigned char *channels); | |
30 | unsigned char *channels, unsigned int *block_size); | |
31 | 31 | void alac_delete_decoder(struct alac_codec_s *codec); |
32 | 32 | bool alac_to_pcm(struct alac_codec_s *codec, unsigned char* input, |
33 | 33 | unsigned char *output, char channels, unsigned *out_frames); |
26 | 26 | |
27 | 27 | // _* called with muxtex locked |
28 | 28 | |
29 | inline unsigned _buf_used(struct buffer *buf) { | |
29 | #if !WIN | |
30 | inline | |
31 | #endif | |
32 | unsigned _buf_used(struct buffer *buf) { | |
30 | 33 | return buf->writep >= buf->readp ? buf->writep - buf->readp : buf->size - (buf->readp - buf->writep); |
31 | 34 | } |
32 | 35 |
0 | squeezelite (1.9+git20210513.556de56-1) unstable; urgency=medium | |
1 | ||
2 | * New upstream version 1.9+git20210513.556de56 | |
3 | Identifies player as "Firmware: v1.9.9-1386" | |
4 | * Update debian/gbp.conf for debian/latest (DEP-14) | |
5 | * Bump Standards-Version to 4.6.0 | |
6 | ||
7 | -- tony mancill <tmancill@debian.org> Mon, 23 Aug 2021 08:44:50 -0700 | |
8 | ||
0 | 9 | squeezelite (1.9+git20210102.78fef68-3) unstable; urgency=medium |
1 | 10 | |
2 | 11 | * Upload to unstable. |
16 | 16 | libssl-dev, |
17 | 17 | libvorbis-dev, |
18 | 18 | portaudio19-dev, |
19 | Standards-Version: 4.5.1 | |
19 | Standards-Version: 4.6.0 | |
20 | 20 | Homepage: https://github.com/ralph-irving/squeezelite |
21 | 21 | Vcs-Git: https://salsa.debian.org/debian/squeezelite.git |
22 | 22 | Vcs-Browser: https://salsa.debian.org/debian/squeezelite |
0 | 0 | [DEFAULT] |
1 | debian-branch = debian/unstable | |
1 | debian-branch = debian/latest | |
2 | 2 | pristine-tar = True |
3 | 3 | upstream-branch = upstream/latest |
4 | 4 |
132 | 132 | { "KEY_DOWN", 0x7689b04f, true }, |
133 | 133 | { "KEY_HOME", 0x768922dd, false }, |
134 | 134 | { "KEY_MEDIA_REPEAT", 0x768938c7, false }, |
135 | { "KEY_AGAIN", 0x768938c7, false }, | |
135 | 136 | // { "KEY_TITLE", 0x76897887, false }, // Now Playing |
136 | 137 | // { "KEY_TITLE", 0x7689a25d, false }, // Now Playing |
137 | 138 | // { "KEY_TEXT", 0x7689f807, false }, // Size |
138 | 138 | #if LINUX || FREEBSD || SUN |
139 | 139 | " -z \t\t\tDaemonize\n" |
140 | 140 | #endif |
141 | #if RESAMPLE | |
142 | 141 | " -Z <rate>\t\tReport rate to server in helo as the maximum sample rate we can support\n" |
143 | #endif | |
144 | 142 | " -t \t\t\tLicense terms\n" |
145 | 143 | " -? \t\t\tDisplay this help text\n" |
146 | 144 | "\n" |
349 | 347 | |
350 | 348 | while (optind < argc && strlen(argv[optind]) >= 2 && argv[optind][0] == '-') { |
351 | 349 | char *opt = argv[optind] + 1; |
352 | if (strstr("oabcCdefmMnNpPrs" | |
350 | if (strstr("oabcCdefmMnNpPrsZ" | |
353 | 351 | #if ALSA |
354 | 352 | "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" | |
362 | 353 | #endif |
363 | 354 | , opt) && optind < argc - 1) { |
364 | 355 | optarg = argv[optind + 1]; |
525 | 516 | case 'N': |
526 | 517 | namefile = optarg; |
527 | 518 | break; |
519 | case 'Z': | |
520 | maxSampleRate = atoi(optarg); | |
521 | break; | |
528 | 522 | case 'W': |
529 | 523 | pcm_check_header = true; |
530 | 524 | break; |
555 | 549 | } else { |
556 | 550 | resample = ""; |
557 | 551 | } |
558 | break; | |
559 | case 'Z': | |
560 | maxSampleRate = atoi(optarg); | |
561 | 552 | break; |
562 | 553 | #endif |
563 | 554 | #if DSD |
188 | 188 | |
189 | 189 | // work backward to unpack samples (if needed) |
190 | 190 | 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 | ) | |
192 | 197 | |
193 | 198 | if (channels == 2) { |
194 | 199 | #if BYTES_PER_FRAME == 4 |
46 | 46 | |
47 | 47 | frames_t frames, size; |
48 | 48 | bool silence; |
49 | u8_t flags = output.channels; | |
49 | 50 | |
50 | 51 | s32_t cross_gain_in = 0, cross_gain_out = 0; s32_t *cross_ptr = NULL; |
51 | 52 | |
58 | 59 | silence = false; |
59 | 60 | |
60 | 61 | // 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) { | |
62 | 63 | output.state = OUTPUT_RUNNING; |
63 | 64 | LOG_INFO("start buffer frames: %u", frames); |
64 | 65 | wake_controller(); |
255 | 256 | } |
256 | 257 | |
257 | 258 | 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); | |
260 | 267 | |
261 | 268 | if (wrote <= 0) { |
262 | 269 | frames -= size; |
546 | 546 | return 0; |
547 | 547 | } |
548 | 548 | |
549 | static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, | |
549 | static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags, | |
550 | 550 | s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) { |
551 | 551 | |
552 | 552 | const snd_pcm_channel_area_t *areas; |
593 | 593 | |
594 | 594 | outputptr = alsa.mmap ? (areas[0].addr + (areas[0].first + offset * areas[0].step) / 8) : alsa.write_buf; |
595 | 595 | |
596 | _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, output.format); | |
596 | _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, flags, output.format); | |
597 | 597 | |
598 | 598 | } else { |
599 | 599 | |
600 | 600 | outputptr = (void *)inputptr; |
601 | 601 | |
602 | 602 | if (!silence) { |
603 | ||
604 | if (gainL != FIXED_ONE || gainR!= FIXED_ONE) { | |
605 | _apply_gain(outputbuf, out_frames, gainL, gainR); | |
606 | } | |
603 | _apply_gain(outputbuf, out_frames, gainL, gainR, flags); | |
607 | 604 | } |
608 | 605 | } |
609 | 606 | |
675 | 672 | #if GPIO |
676 | 673 | // Wake up amp |
677 | 674 | if (gpio_active) { |
678 | ampstate = 1; | |
679 | 675 | relay(1); |
680 | 676 | } |
681 | 677 | if (power_script != NULL) { |
682 | ampstate = 1; | |
683 | 678 | relay_script(1); |
684 | 679 | } |
685 | 680 | #endif |
809 | 804 | #if GPIO |
810 | 805 | // Put Amp to Sleep |
811 | 806 | if (gpio_active){ |
812 | ampstate = 0; | |
813 | 807 | relay(0); |
814 | 808 | } |
815 | 809 | if (power_script != NULL ){ |
816 | ampstate = 0; | |
817 | 810 | relay_script(0); |
818 | 811 | } |
819 | 812 | #endif |
447 | 447 | |
448 | 448 | static u8_t *optr; |
449 | 449 | |
450 | static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, | |
450 | static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, u8_t flags, | |
451 | 451 | s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) { |
452 | 452 | |
453 | 453 | if (!silence) { |
457 | 457 | } |
458 | 458 | |
459 | 459 | if (gainL != FIXED_ONE || gainR!= FIXED_ONE) { |
460 | _apply_gain(outputbuf, out_frames, gainL, gainR); | |
460 | _apply_gain(outputbuf, out_frames, gainL, gainR, flags); | |
461 | 461 | } |
462 | 462 | |
463 | 463 | IF_DSD( |
42 | 42 | return (s32_t)(f * 65536.0F); |
43 | 43 | } |
44 | 44 | |
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 | ||
46 | 71 | switch(format) { |
47 | 72 | #if DSD |
48 | 73 | case U32_LE: |
352 | 377 | #if !WIN |
353 | 378 | inline |
354 | 379 | #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 | } | |
363 | 411 | } |
364 | 412 | } |
361 | 361 | d->default_sink_name = strdup(l->name); |
362 | 362 | |
363 | 363 | 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; | |
366 | 367 | |
367 | 368 | *d->sample_spec = l->sample_spec; |
368 | 369 | } |
385 | 386 | return true; |
386 | 387 | } |
387 | 388 | |
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, | |
389 | 390 | s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) { |
390 | 391 | pa_stream_write(pulse.stream, silence ? silencebuf : outputbuf->readp, out_frames * BYTES_PER_FRAME, (pa_free_cb_t)NULL, 0, PA_SEEK_RELATIVE); |
391 | 392 | return (int)out_frames; |
44 | 44 | static unsigned buffill; |
45 | 45 | static int bytes_per_frame; |
46 | 46 | |
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, | |
48 | 48 | s32_t cross_gain_in, s32_t cross_gain_out, s32_t **cross_ptr) { |
49 | 49 | |
50 | 50 | u8_t *obuf; |
74 | 74 | } |
75 | 75 | ) |
76 | 76 | |
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); | |
78 | 78 | |
79 | 79 | buffill += out_frames; |
80 | 80 |
119 | 119 | } |
120 | 120 | |
121 | 121 | 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 | |
123 | 123 | #define SSL_CAP "CanHTTPS=1" |
124 | 124 | const char *base_cap; |
125 | 125 | struct HELO_packet pkt; |
379 | 379 | output.fade_mode = strm->transition_type - '0'; |
380 | 380 | output.fade_secs = strm->transition_period; |
381 | 381 | 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); | |
383 | 384 | UNLOCK_O; |
384 | 385 | } |
385 | 386 | break; |
874 | 875 | |
875 | 876 | LOCK_O; |
876 | 877 | snprintf(fixed_cap, FIXED_CAP_LEN, ",ModelName=%s,MaxSampleRate=%u", modelname ? modelname : MODEL_NAME_STRING, |
878 | #if RESAMPLE | |
877 | 879 | ((maxSampleRate > 0) ? maxSampleRate : output.supported_rates[0])); |
880 | #else | |
881 | ((maxSampleRate > 0 && maxSampleRate < output.supported_rates[0]) ? maxSampleRate : output.supported_rates[0])); | |
882 | #endif | |
878 | 883 | |
879 | 884 | for (i = 0; i < MAX_CODECS; i++) { |
880 | 885 | if (codecs[i] && codecs[i]->id && strlen(fixed_cap) < FIXED_CAP_LEN - 10) { |
24 | 24 | // make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build |
25 | 25 | |
26 | 26 | #define MAJOR_VERSION "1.9" |
27 | #define MINOR_VERSION "8" | |
28 | #define MICRO_VERSION "1317" | |
27 | #define MINOR_VERSION "9" | |
28 | #define MICRO_VERSION "1386" | |
29 | 29 | |
30 | 30 | #if defined(CUSTOM_VERSION) |
31 | 31 | #define VERSION "v" MAJOR_VERSION "." MINOR_VERSION "-" MICRO_VERSION STR(CUSTOM_VERSION) |
614 | 614 | typedef enum { FADE_UP = 1, FADE_DOWN, FADE_CROSS } fade_dir; |
615 | 615 | typedef enum { FADE_NONE = 0, FADE_CROSSFADE, FADE_IN, FADE_OUT, FADE_INOUT } fade_mode; |
616 | 616 | |
617 | #define MONO_RIGHT 0x02 | |
618 | #define MONO_LEFT 0x01 | |
617 | 619 | #define MAX_SUPPORTED_SAMPLERATES 18 |
618 | 620 | #define TEST_RATES = { 768000, 705600, 384000, 352800, 192000, 176400, 96000, 88200, 48000, 44100, 32000, 24000, 22500, 16000, 12000, 11025, 8000, 0 } |
619 | 621 | |
620 | 622 | struct outputstate { |
621 | 623 | output_state state; |
622 | 624 | output_format format; |
625 | u8_t channels; | |
623 | 626 | const char *device; |
624 | 627 | #if ALSA |
625 | 628 | unsigned buffer; |
631 | 634 | unsigned latency; |
632 | 635 | int pa_hostapi_option; |
633 | 636 | #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); | |
635 | 638 | unsigned start_frames; |
636 | 639 | unsigned frames_played; |
637 | 640 | unsigned frames_played_dmp;// frames played at the point delay is measured |
715 | 718 | void output_close_stdout(void); |
716 | 719 | |
717 | 720 | // 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); | |
719 | 722 | 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); | |
721 | 724 | s32_t gain(s32_t gain, s32_t sample); |
722 | 725 | s32_t to_gain(float f); |
723 | 726 | |
758 | 761 | struct codec *register_opus(void); |
759 | 762 | #endif |
760 | 763 | |
761 | //gpio.c | |
764 | // gpio.c | |
762 | 765 | #if GPIO |
763 | void relay( int state); | |
766 | void relay(int state); | |
764 | 767 | void relay_script(int state); |
765 | 768 | int gpio_pin; |
766 | 769 | bool gpio_active_low; |
767 | 770 | bool gpio_active; |
768 | 771 | char *power_script; |
769 | // my amp state | |
770 | int ampstate; | |
772 | ||
771 | 773 | #if RPI |
772 | 774 | #define PI_INPUT 0 |
773 | 775 | #define PI_OUTPUT 1 |
106 | 106 | |
107 | 107 | unsigned try = 0; |
108 | 108 | ssize_t n; |
109 | int error; | |
109 | 110 | |
110 | 111 | while (len) { |
111 | 112 | n = _send(ssl, fd, ptr, len, MSG_NOSIGNAL); |
112 | 113 | 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); | |
115 | 121 | usleep(1000); |
116 | 122 | continue; |
117 | 123 | } |
118 | LOG_INFO("failed writing to socket: %s", strerror(last_error())); | |
124 | LOG_WARN("failed writing to socket: %s", strerror(last_error())); | |
119 | 125 | stream.disconnect = LOCAL_DISCONNECT; |
120 | 126 | stream.state = DISCONNECT; |
121 | 127 | wake_controller(); |
394 | 400 | |
395 | 401 | n = _recv(ssl, fd, streambuf->writep, space, 0); |
396 | 402 | if (n == 0) { |
397 | LOG_INFO("end of stream"); | |
403 | LOG_INFO("end of stream (%u bytes)", stream.bytes); | |
398 | 404 | _disconnect(DISCONNECT, DISCONNECT_OK); |
399 | 405 | } |
400 | 406 | if (n < 0 && _last_error() != ERROR_WOULDBLOCK) { |
556 | 562 | |
557 | 563 | *host = '\0'; |
558 | 564 | 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 | } | |
560 | 569 | |
561 | 570 | port = ntohs(port); |
562 | 571 | sock = connect_socket(use_ssl || port == 443); |
488 | 488 | } |
489 | 489 | #endif |
490 | 490 | |
491 | #if WIN && USE_SSL | |
491 | #if WIN | |
492 | 492 | char *strcasestr(const char *haystack, const char *needle) { |
493 | 493 | size_t length_needle; |
494 | 494 | size_t length_haystack; |
235 | 235 | |
236 | 236 | // work backward to unpack samples (if needed) |
237 | 237 | 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 | ) | |
239 | 244 | |
240 | 245 | if (channels == 2) { |
241 | 246 | #if BYTES_PER_FRAME == 4 |