Changeset 1240 for trunk/libffado/tests/streaming/test-ipcclient.cpp
- Timestamp:
- 06/01/08 09:15:34 (16 years ago)
- Files:
-
- trunk/libffado/tests/streaming/test-ipcclient.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/tests/streaming/test-ipcclient.cpp
r1172 r1240 51 51 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 52 52 static char doc[] = "test-avccmd -- test program to test the ipc ringbuffer class."; 53 static char args_doc[] = " DIRECTION";53 static char args_doc[] = ""; 54 54 static struct argp_option options[] = { 55 55 {"verbose", 'v', "level", 0, "Produce verbose output" }, … … 146 146 break; 147 147 case ARGP_KEY_END: 148 if(arguments->nargs <= 0) {149 printMessage("not enough arguments\n");150 return -1;151 }148 // if(arguments->nargs <= 0) { 149 // printMessage("not enough arguments\n"); 150 // return -1; 151 // } 152 152 break; 153 153 default: … … 168 168 signal (SIGPIPE, sighandler); 169 169 170 arguments.verbose = 6; 171 arguments.period = 1024; 172 arguments.nb_buffers = 3; 173 arguments.playback = 0; 174 arguments.capture = 0; 175 170 176 // arg parsing 171 177 if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { … … 182 188 183 189 printMessage("Testing shared memory streaming IPC\n"); 190 printMessage(" period %d, nb_buffers %d, playback %d, capture %d\n", 191 arguments.period, arguments.nb_buffers, 192 arguments.playback, 193 arguments.capture ); 184 194 185 195 // prepare the IPC buffers … … 188 198 IpcRingBuffer* capturebuffer = NULL; 189 199 IpcRingBuffer* playbackbuffer = NULL; 190 if(arguments.playback == 0) {200 if(arguments.playback) { 191 201 playbackbuffer = new IpcRingBuffer("playbackbuffer", 192 202 IpcRingBuffer::eBT_Slave, … … 231 241 232 242 int cnt = 0; 233 243 int pbkcnt = 0; 234 244 235 245 run=1; … … 237 247 // write the data 238 248 IpcRingBuffer::eResult res; 239 res = playbackbuffer->Write(playback_buff); 240 if(res != IpcRingBuffer::eR_OK && res != IpcRingBuffer::eR_Again) { 241 debugError("Could not write to segment\n"); 242 goto out_err; 243 } 244 if(res == IpcRingBuffer::eR_Again) { 245 printMessage(" Try playback again on %d...\n", cnt); 246 } 247 248 res = capturebuffer->Read(capture_buff); 249 if(res != IpcRingBuffer::eR_OK && res != IpcRingBuffer::eR_Again) { 250 debugError("Could not receive from queue\n"); 251 goto out_err; 252 } 253 if(res == IpcRingBuffer::eR_Again) { 254 printMessage(" Try again on %d...\n", cnt); 255 } else { 256 if(cnt%10==0) { 257 uint32_t *tmp = (uint32_t *)capture_buff; 258 for(int i=0;i<arguments.capture;i++) { 259 printMessage(" channel %d: ", i); 260 for(int j=0; j < 6;j+=1) { 261 uint32_t tmp2 = tmp[j] << 8; 262 int32_t *tmp3 = (int32_t *)&tmp2; 263 printMessageShort("%10d ", *tmp3); 249 if(playbackbuffer) { 250 res = playbackbuffer->Write(playback_buff); 251 if(res != IpcRingBuffer::eR_OK && res != IpcRingBuffer::eR_Again) { 252 debugError("Could not write to segment\n"); 253 goto out_err; 254 } 255 if(res == IpcRingBuffer::eR_Again) { 256 printMessage(" Try playback again on %d...\n", cnt); 257 } else { 258 if(pbkcnt%100==0) { 259 printMessage(" Period %d...\n", pbkcnt); 260 } 261 pbkcnt++; 262 } 263 } 264 // read data 265 if (capturebuffer) { 266 res = capturebuffer->Read(capture_buff); 267 if(res != IpcRingBuffer::eR_OK && res != IpcRingBuffer::eR_Again) { 268 debugError("Could not receive from queue\n"); 269 goto out_err; 270 } 271 if(res == IpcRingBuffer::eR_Again) { 272 printMessage(" Try again on %d...\n", cnt); 273 } else { 274 if(cnt%10==0) { 275 uint32_t *tmp = (uint32_t *)capture_buff; 276 for(int i=0;i<arguments.capture;i++) { 277 printMessage(" channel %d: ", i); 278 for(int j=0; j < 6;j+=1) { 279 uint32_t tmp2 = tmp[j] << 8; 280 int32_t *tmp3 = (int32_t *)&tmp2; 281 printMessageShort("%10d ", *tmp3); 282 } 283 tmp += arguments.period; 284 printMessageShort("\n"); 264 285 } 265 tmp += arguments.period;266 printMessageShort("\n");267 286 } 268 }269 cnt++;287 cnt++; 288 } 270 289 } 271 290 }