Changeset 577 for trunk/libffado/src/libstreaming
- Timestamp:
- 08/27/07 16:58:41 (17 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libstreaming/MotuStreamProcessor.cpp
r515 r577 121 121 122 122 int fc; 123 int64_t ts_head;124 123 ffado_timestamp_t ts_tmp; 125 124 quadlet_t *quadlet = (quadlet_t *)data; … … 170 169 // initialize the buffer head & tail 171 170 m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_tmp, &fc); // thread safe 172 ts_head = (int64_t)ts_tmp;171 int64_t ts_head = (int64_t)ts_tmp; 173 172 174 173 // the number of cycles the sync source lags (> 0) … … 232 231 // the base timestamp is the one of the next sample in the buffer 233 232 m_data_buffer->getBufferHeadTimestamp(&ts_tmp, &fc); // thread safe 234 ts_head = (int64_t)ts_tmp; 235 int64_t timestamp = ts_head; 233 int64_t timestamp = (int64_t)ts_tmp; 236 234 237 235 // we send a packet some cycles in advance, to avoid the … … 251 249 ticks_to_advance += (int64_t)cycle_diff * TICKS_PER_CYCLE; 252 250 253 254 251 // time until the packet is to be sent (if <= 0: send packet) 255 252 // For Amdtp this looked like … … 291 288 // shutdown if the buffer is read during this time. 292 289 if (m_closedown_count!=-1 || m_data_buffer->readFrames(n_events, (char *)(data + 8))) { 290 float ticks_per_frame = m_SyncSource->m_data_buffer->getRate(); 293 291 294 292 #if TESTTONE … … 297 295 // *never* added during closedown. 298 296 if (m_closedown_count<0) { 299 for (i=0; i<n_events; i++) { 297 signed int int_tpf = (int)ticks_per_frame; 298 unsigned char *sample = data+8+16; 299 for (i=0; i<n_events; i++, sample+=m_event_size) { 300 300 static signed int a_cx = 0; 301 signed int val; 302 val = (int)(0x7fffff*sin(1000.0*2.0*M_PI*(a_cx/24576000.0))); 303 if ((a_cx+=512) >= 24576000) { 301 // Each sample is 3 bytes with MSB in lowest address (ie: 302 // network byte order). After byte order swap, the 24-bit 303 // MSB is in the second byte of val. 304 signed int val = htonl((int)(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx))); 305 memcpy(sample,((char *)&val)+1,3); 306 if ((a_cx+=int_tpf) >= 24576000) { 304 307 a_cx -= 24576000; 305 308 } 306 *(data+8+i*m_event_size+16) = (val >> 16) & 0xff;307 *(data+8+i*m_event_size+17) = (val >> 8) & 0xff;308 *(data+8+i*m_event_size+18) = val & 0xff;309 309 } 310 310 } … … 346 346 m_startup_count--; 347 347 348 // Set up each frames's SPH. Note that the (int) typecast 349 // appears to do rounding. 350 351 float ticks_per_frame = m_SyncSource->m_data_buffer->getRate(); 348 // Set up each frames's SPH. 352 349 for (i=0; i<n_events; i++, quadlet += dbs) { 353 350 //FIXME: not sure which is best for the MOTU