Changeset 4552:47a0412f706d in roaraudio
- Timestamp:
- 10/25/10 14:03:43 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4548 r4552 14 14 * Added new test system RAT 15 15 * Added support for single sink mode (Closes: #25) 16 * Implemented atomic flag toggling and flag protection. 16 17 17 18 v. 0.4beta0 - Fri Oct 01 2010 13:36 CEST -
roarclients/roarctl.c
r4536 r4552 97 97 " separated list of flags.\n" 98 98 " unflag ID FLAGS - Unsets flags on a stream. See flag.\n" 99 " toogleflag ID FLAGS - Toggels flags on a stream. See flag.\n" 100 " protectflag ID FLAGS - Protects flags on a stream. Those flags can not be\n" 101 " changed anymore after the they got protected. See flag.\n" 99 102 "\n" 100 103 " kick TYPE ID - Kicks object of TYPE with id ID\n" … … 926 929 } 927 930 928 int set_flags (struct roar_connection * con, int id, int reset, char * flags) {929 int f = ROAR_FLAG_NONE;931 int set_flags (struct roar_connection * con, int id, int action, char * flags) { 932 uint32_t f = ROAR_FLAG_NONE; 930 933 char * c; 931 934 struct roar_stream s[1]; … … 976 979 } 977 980 978 return roar_stream_set_flags (con, s, f, reset);981 return roar_stream_set_flags2(con, s, f, action); 979 982 } 980 983 … … 1191 1194 } 1192 1195 i++; 1196 } else if ( !strcmp(k, "toggleflag") ) { 1197 i++; 1198 if ( set_flags(&con, atoi(argv[i]), ROAR_TOGGLE_FLAG, argv[i+1]) == -1 ) { 1199 fprintf(stderr, "Error: can not toggle flags\n"); 1200 } else { 1201 printf("flags changed\n"); 1202 } 1203 i++; 1204 } else if ( !strcmp(k, "protectflag") ) { 1205 i++; 1206 if ( set_flags(&con, atoi(argv[i]), ROAR_NOOP_FLAG|ROAR_PROTECT_FLAG, argv[i+1]) == -1 ) { 1207 fprintf(stderr, "Error: can not protect flags\n"); 1208 } else { 1209 printf("flags protected\n"); 1210 } 1211 i++; 1193 1212 } else if ( !strcmp(k, "metaset") ) { 1194 1213 i++; -
roard/include/streams.h
r4550 r4552 162 162 int streams_get_flag (int id, uint32_t flag); 163 163 164 int streams_protect_flag (int id, uint32_t flag); 165 164 166 int streams_set_name (int id, char * name); 165 167 char * streams_get_name (int id); -
roard/req.c
r4539 r4552 1073 1073 1074 1074 int req_on_set_stream_para (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 1075 struct roar_stream_server * ss; 1075 1076 uint16_t * d = (uint16_t *) mes->data; 1076 uint32_t tmp; 1077 uint32_t tmp, tmp2, flagstore; 1078 int protect = 0; 1077 1079 int i; 1078 1080 … … 1107 1109 tmp |= d[3]; 1108 1110 1109 if ( d[2] == ROAR_RESET_FLAG ) { 1110 if ( streams_reset_flag(mes->stream, tmp) == -1 ) 1111 return -1; 1112 } else { 1113 if ( streams_set_flag(mes->stream, tmp) == -1 ) 1114 return -1; 1115 } 1111 if ( d[2] & ROAR_PROTECT_FLAG ) { 1112 protect = 1; 1113 d[2] -= ROAR_PROTECT_FLAG; 1114 } 1115 1116 switch (d[2]) { 1117 case ROAR_SET_FLAG: 1118 if ( streams_set_flag(mes->stream, tmp) == -1 ) 1119 return -1; 1120 break; 1121 case ROAR_RESET_FLAG: 1122 if ( streams_reset_flag(mes->stream, tmp) == -1 ) 1123 return -1; 1124 break; 1125 case ROAR_NOOP_FLAG: 1126 break; 1127 case ROAR_TOGGLE_FLAG: 1128 if ( streams_get(mes->stream, &ss) == -1 ) 1129 return -1; 1130 1131 flagstore = ss->flags; 1132 1133 tmp2 = flagstore & tmp; // those are the flags we need to reset. 1134 ROAR_DBG("req_on_set_stream_para(*): tmp2=0x%.8lx", (long int)tmp2); 1135 if ( tmp2 ) 1136 if ( streams_reset_flag(mes->stream, tmp2) == -1 ) 1137 return -1; 1138 1139 tmp2 = (flagstore ^ tmp) & tmp; // those are the flags we need to set. 1140 ROAR_DBG("req_on_set_stream_para(*): tmp2=0x%.8lx", (long int)tmp2); 1141 if ( tmp2 ) 1142 if ( streams_set_flag(mes->stream, tmp2) == -1 ) 1143 return -1; 1144 break; 1145 default: 1146 return -1; 1147 break; 1148 } 1149 1150 ROAR_DBG("req_on_set_stream_para(*): protect=%i", protect); 1151 if ( protect ) 1152 if ( streams_protect_flag(mes->stream, tmp) == -1 ) 1153 return -1; 1154 1116 1155 break; 1117 1156 case ROAR_STREAM_PARA_CHANMAP: -
roard/streams.c
r4550 r4552 896 896 flag |= ROAR_FLAG_PRIMARY; 897 897 898 899 // check if flags we are going to change are protected: 900 if ( g_streams[id]->flags_protection & flag ) 901 return -1; 902 903 898 904 if ( flag & ROAR_FLAG_MMAP ) { 899 905 if ( streams_set_mmap(id, 0) == -1 ) { … … 984 990 _CHECK_SID(id); 985 991 992 // check if flags we are going to change are protected: 993 if ( g_streams[id]->flags_protection & flag ) 994 return -1; 995 986 996 if ( g_streams[id]->flags & ROAR_FLAG_IMMUTABLE ) { 987 997 flag |= ROAR_FLAG_PRIMARY; … … 1032 1042 1033 1043 return g_streams[id]->flags & flag ? 1 : 0; 1044 } 1045 1046 int streams_protect_flag (int id, uint32_t flag) { 1047 _CHECK_SID(id); 1048 1049 g_streams[id]->flags_protection |= flag; 1050 1051 return 0; 1034 1052 } 1035 1053
Note: See TracChangeset
for help on using the changeset viewer.