Changeset 4740:f3abf82e2ead in roaraudio
- Timestamp:
- 01/31/11 02:21:19 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4737 r4740 1 v. 0.4beta4 - ? 2 * Added support for UNMAPPED volume control (Closes: #55) 3 1 4 v. 0.4beta3 - Wed Jan 26 2011 23:26 CET 2 5 Prereleases: 0: Thu Jan 20 2011 19:36 CET -
include/libroar/ctl.h
r4708 r4740 66 66 67 67 int roar_set_vol (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels); 68 int roar_set_vol2 (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels, int mode); 68 69 int roar_get_vol (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int * channels); 69 70 -
libroar/ctl.c
r4708 r4740 228 228 229 229 int roar_set_vol (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels) { 230 return roar_set_vol2(con, id, mixer, channels, ROAR_SET_VOL_ALL); 231 } 232 233 int roar_set_vol2 (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels, int mode) { 230 234 struct roar_message m; 231 235 uint16_t * info = (uint16_t *) m.data; … … 239 243 info[0] = ROAR_HOST2NET16(1); 240 244 info[1] = ROAR_HOST2NET16(mixer->scale); 241 info[2] = ROAR_HOST2NET16( ROAR_SET_VOL_ALL);245 info[2] = ROAR_HOST2NET16(mode); 242 246 243 247 for (i = 0; i < channels; i++) -
libroar/vs.c
r4719 r4740 829 829 int oldchannels; 830 830 int handled; 831 int mode = ROAR_SET_VOL_ALL; 831 832 832 833 _ckvss(-1); … … 864 865 mixer.scale = 65535; 865 866 866 if ( channels != oldchannels ) { 867 handled = 0; 868 switch (oldchannels) { 869 case 1: 870 if ( channels == 2 ) { 871 mixer.mixer[0] = (mixer.mixer[0] + mixer.mixer[1]) / 2; 872 handled = 1; 873 } 874 break; 875 case 2: 876 if ( channels == 1 ) { 877 mixer.mixer[1] = mixer.mixer[0]; 878 handled = 1; 879 } 880 break; 881 case 4: 882 if ( channels == 1 ) { 883 mixer.mixer[1] = mixer.mixer[0]; 884 mixer.mixer[2] = mixer.mixer[0]; 885 mixer.mixer[3] = mixer.mixer[0]; 886 handled = 1; 887 } else if ( channels == 2 ) { 888 mixer.mixer[2] = mixer.mixer[0]; 889 mixer.mixer[3] = mixer.mixer[1]; 890 handled = 1; 891 } 892 break; 893 } 894 if ( handled ) { 895 channels = oldchannels; 896 } else { 897 _seterr(ROAR_ERROR_INVAL); 898 return -1; 899 } 900 } 901 902 if ( roar_set_vol(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, channels) == -1 ) { 867 if ( channels != oldchannels ) 868 mode = ROAR_SET_VOL_UNMAPPED; 869 870 if ( roar_set_vol2(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, channels, mode) == 0 ) 871 return 0; 872 873 if ( mode == ROAR_SET_VOL_ALL ) { 874 _seterrre(); 875 return -1; 876 } 877 878 if ( roar_conv_volume(&mixer, &mixer, oldchannels, channels) == -1 ) { 879 _seterrre(); 880 return -1; 881 } 882 883 channels = oldchannels; 884 mode = ROAR_SET_VOL_ALL; 885 886 if ( roar_set_vol2(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, channels, mode) == -1 ) { 903 887 _seterrre(); 904 888 return -1; -
roarclients/roarctl.c
r4708 r4740 644 644 int len; 645 645 int old_chans; 646 int vol_l, vol_r, vol_mono;647 646 char * k; 648 647 struct roar_mixer_settings mixer; 649 648 struct roar_mixer_settings old_mixer; 649 int mode = ROAR_SET_VOL_ALL; 650 650 651 651 if (*cur + 2 > max) … … 655 655 656 656 k = arg[++(*cur)]; 657 658 if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) {659 fprintf(stderr, "Error: can not get stream mixer info for stream %i\n", id);660 return -1;661 }662 657 663 658 if ( !strcmp(arg[*cur + 1], "scale") ) { … … 667 662 } 668 663 669 // TODO: clean up code here as the % vs. abs code is very duplicate... 670 671 if ( strcmp(k, "mono") == 0 && old_chans != 1 ) { 664 mixer.scale = scale; 665 666 if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) { 667 fprintf(stderr, "Error: can not get stream mixer info for stream %i\n", id); 668 return -1; 669 } 670 671 if ( strcmp(k, "mono") == 0 ) { 672 672 chans = 1; 673 674 if ( *cur + 1 > max ) 675 return -1; 676 673 mode = ROAR_SET_VOL_UNMAPPED; 674 } else if ( strcmp(k, "stereo") == 0 ) { 675 chans = 2; 676 mode = ROAR_SET_VOL_UNMAPPED; 677 } else { 678 chans = atoi(k); 679 } 680 681 // ensure most simple mode: 682 if ( old_chans == chans && mode == ROAR_SET_VOL_UNMAPPED ) 683 mode = ROAR_SET_VOL_ALL; 684 685 if ( *cur + chans > max ) 686 return -1; 687 688 for (i = 0; i < chans; i++) { 677 689 k = arg[++(*cur)]; 678 690 len = strlen(k); 679 691 680 vol_mono = set_mixer_parse_volume(k, len, scale); 681 682 for (i = 0; i < old_chans; i++) 683 mixer.mixer[i] = vol_mono; 684 685 chans = old_chans; 686 687 } else if ( strcmp(k, "stereo") == 0 && old_chans != 2 ) { 688 chans = old_chans; 689 690 if ( *cur + 2 > max ) 691 return -1; 692 693 k = arg[++(*cur)]; 694 len = strlen(k); 695 696 vol_l = set_mixer_parse_volume(k, len, scale); 697 698 k = arg[++(*cur)]; 699 len = strlen(k); 700 701 vol_r = set_mixer_parse_volume(k, len, scale); 702 703 vol_mono = (vol_l + vol_r) / 2; 704 705 mixer.mixer[0] = vol_l; 706 mixer.mixer[1] = vol_r; 707 708 switch (chans) { 709 case 1: 710 mixer.mixer[0] = vol_mono; 711 break; 712 // case 2: classic stereo... 713 case 3: 714 mixer.mixer[2] = vol_mono; 715 break; 716 case 4: 717 mixer.mixer[2] = vol_l; 718 mixer.mixer[3] = vol_r; 719 break; 720 case 5: 721 mixer.mixer[2] = vol_mono; 722 mixer.mixer[3] = vol_l; 723 mixer.mixer[4] = vol_r; 724 break; 725 case 6: 726 mixer.mixer[2] = vol_mono; 727 mixer.mixer[3] = vol_mono; 728 mixer.mixer[4] = vol_l; 729 mixer.mixer[5] = vol_r; 730 break; 731 default: 732 ROAR_ERR("mode stereo not supported on stream with %i channels", chans); 733 return -1; 734 break; 735 } 736 737 } else { 738 if ( strcmp(k, "mono") == 0 ) { 739 chans = 1; 740 } else if ( strcmp(k, "stereo") == 0 ) { 741 chans = 2; 742 } else { 743 chans = atoi(k); 744 } 745 746 // printf("mode: int; chans=%i, old_chans=%i\n", chans, old_chans); 747 748 if ( *cur + chans > max ) 749 return -1; 750 751 for (i = 0; i < chans; i++) { 752 k = arg[++(*cur)]; 753 len = strlen(k); 754 755 mixer.mixer[i] = set_mixer_parse_volume(k, len, scale); 756 } 757 } 758 759 mixer.scale = scale; 760 761 return roar_set_vol(con, id, &mixer, chans); 692 mixer.mixer[i] = set_mixer_parse_volume(k, len, scale); 693 } 694 695 if ( roar_set_vol2(con, id, &mixer, chans, mode) == 0 ) 696 return 0; 697 698 // no fallback if already using ROAR_SET_VOL_ALL: 699 if ( mode == ROAR_SET_VOL_ALL ) 700 return -1; 701 702 if ( roar_conv_volume(&mixer, &mixer, old_chans, chans) == -1 ) 703 return -1; 704 705 chans = old_chans; 706 mode = ROAR_SET_VOL_ALL; 707 708 if ( roar_set_vol2(con, id, &mixer, chans, mode) == 0 ) 709 return 0; 710 711 return -1; 762 712 } 763 713 -
roarclients/roarradio.c
r4708 r4740 43 43 ); 44 44 45 } 46 47 static void die(const char * msg) { 48 fprintf(stderr, "Fatal error: %s\n", msg); 49 abort(); 45 50 } 46 51 … … 62 67 char buf0[80], buf1[80]; 63 68 int proto = P_UNKNOWN; 69 ssize_t slen; 64 70 65 71 for (i = 1; i < argc; i++) { … … 160 166 161 167 while (*buf0 != '\r' && *buf0 != '\n') { 162 fgets(buf0, 80, http); 168 if ( fgets(buf0, 80, http) == NULL ) 169 die("Can not read header lion"); 163 170 } 164 171 … … 173 180 } 174 181 // TODO: do some error checks here 175 write(in, file, strlen(file)); 176 write(in, "\r\n", 2); 182 slen = strlen(file); 183 if ( write(in, file, slen) != slen ) 184 die("Can not write selector"); 185 if ( write(in, "\r\n", 2) != 2 ) 186 die("Can not write selector terminator"); 177 187 ROAR_SHUTDOWN(in, SHUT_WR); 178 188 break; -
roard/req.c
r4738 r4740 1371 1371 1372 1372 int req_on_set_vol (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 1373 struct roar_mixer_settings tmpmixer; 1373 1374 struct roar_stream_server * s; 1374 1375 uint16_t * info = (uint16_t *) mes->data; … … 1450 1451 s->mixer.scale = scale; 1451 1452 break; 1453 case ROAR_SET_VOL_UNMAPPED: 1454 chans = (mes->datalen/2) - 3; 1455 1456 if ( chans >= ROAR_MAX_CHANNELS ) 1457 return -1; 1458 1459 memcpy(&tmpmixer, &(s->mixer), sizeof(tmpmixer)); 1460 1461 for (i = 0; i < chans; i++) { 1462 tmpmixer.mixer[i] = ROAR_NET2HOST16(info[i+3]); 1463 } 1464 1465 tmpmixer.scale = scale; 1466 1467 if ( roar_conv_volume(&(s->mixer), &tmpmixer, ROAR_STREAM(s)->info.channels, chans) == -1 ) 1468 return -1; 1469 1470 break; 1471 case ROAR_SET_VOL_MS: 1452 1472 default: 1453 1473 return -1;
Note: See TracChangeset
for help on using the changeset viewer.