Changeset 783
- Timestamp:
- 12/29/07 02:18:54 (15 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_dl_mgr.cpp (modified) (2 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (7 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/libavc/general/avc_generic.cpp (modified) (2 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (2 diffs)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (modified) (2 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (8 diffs)
- trunk/libffado/src/libutil/SystemTimeSource.cpp (modified) (1 diff)
- trunk/libffado/src/libutil/Time.c (modified) (1 diff)
- trunk/libffado/src/libutil/Time.h (modified) (3 diffs)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/support/dbus/controlserver.cpp (modified) (3 diffs)
- trunk/libffado/tests/streaming/teststreaming3.c (modified) (5 diffs)
- trunk/libffado/tests/test-echo.cpp (modified) (5 diffs)
- trunk/libffado/tests/test-focusrite.cpp (modified) (2 diffs)
- trunk/libffado/tests/test-ieee1394service.cpp (modified) (2 diffs)
- trunk/libffado/tests/test-timestampedbuffer.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_dl_mgr.cpp
r742 r783 30 30 31 31 #include "libutil/cmd_serialize.h" 32 #include "libutil/Time.h" 32 33 33 34 #include <netinet/in.h> … … 436 437 break; 437 438 } 438 usleep( 100 );439 SleepRelativeUsec( 100 ); 439 440 440 441 if ( !readResponse( ccBlock ) ) { trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp
r750 r783 25 25 #include "focusrite_cmd.h" 26 26 27 #include "libutil/Time.h" 28 27 29 namespace BeBoB { 28 30 namespace Focusrite { … … 385 387 386 388 // the device needs quite some time to reboot 387 usleep(2 * 1000 * 1000);389 SleepRelativeUsec(2 * 1000 * 1000); 388 390 389 391 int timeout = 5; // multiples of 1s … … 393 395 { 394 396 // wait for a while 395 usleep(1000 * 1000);397 SleepRelativeUsec(1000 * 1000); 396 398 } 397 399 if (!timeout) { … … 400 402 401 403 // the device needs quite some time to reboot 402 usleep(2 * 1000 * 1000);404 SleepRelativeUsec(2 * 1000 * 1000); 403 405 404 406 // wait for the device to finish the reboot … … 408 410 { 409 411 // wait for a while 410 usleep(1000 * 1000);412 SleepRelativeUsec(1000 * 1000); 411 413 } 412 414 if (!timeout) { … … 425 427 426 428 // wait for a while 427 usleep(4 * 1000 * 1000);429 SleepRelativeUsec(4 * 1000 * 1000); 428 430 } while (gen_current != get1394Service().getGeneration() 429 431 && --timeout); … … 438 440 439 441 // wait some more 440 usleep(1 * 1000 * 1000);442 SleepRelativeUsec(1 * 1000 * 1000); 441 443 442 444 // we have to rediscover the device trunk/libffado/src/bounce/bounce_slave_avdevice.cpp
r742 r783 27 27 #include "libieee1394/configrom.h" 28 28 #include "libieee1394/ieee1394service.h" 29 30 #include "libutil/Time.h" 29 31 30 32 #include "bounce_slave_avdevice.h" … … 313 315 return false; 314 316 } 315 usleep(100000);317 SleepRelativeUsec(100000); 316 318 } 317 319 trunk/libffado/src/libavc/general/avc_generic.cpp
r742 r783 27 27 28 28 #include "debugmodule/debugmodule.h" 29 30 #include "libutil/Time.h" 29 31 30 32 #include <netinet/in.h> … … 265 267 m_p1394Service->transactionBlockClose(); 266 268 267 usleep( m_time );269 SleepRelativeUsec( m_time ); 268 270 269 271 return result; trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r779 r783 28 28 #include "devicemanager.h" 29 29 30 #include "libutil/Time.h" 31 30 32 #include "libieee1394/ieee1394service.h" 31 33 #include "libieee1394/IsoHandlerManager.h" … … 180 182 181 183 // for example: 182 // usleep(125); // one cycle184 // SleepRelativeUsec(125); // one cycle 183 185 // goto try_block_of_frames; 184 186 trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
r776 r783 30 30 #include "libieee1394/IsoHandlerManager.h" 31 31 #include "libieee1394/cycletimer.h" 32 33 #include "libutil/Time.h" 32 34 33 35 #include "libutil/Atomic.h" … … 923 925 int cnt = timeout_ms; 924 926 while (m_state != state && cnt) { 925 usleep(1000);927 SleepRelativeUsec(1000); 926 928 cnt--; 927 929 } trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r776 r783 26 26 #include "generic/Port.h" 27 27 #include "libieee1394/cycletimer.h" 28 29 #include "libutil/Time.h" 28 30 29 31 #include <errno.h> … … 263 265 } 264 266 265 usleep(125);267 SleepRelativeUsec(125); 266 268 cnt--; 267 269 } … … 332 334 if(time_till_next_period > 0) { 333 335 // wait for the period 334 usleep(time_till_next_period);336 SleepRelativeUsec(time_till_next_period); 335 337 } 336 338 } … … 412 414 int cnt = CYCLES_FOR_STARTUP * 20; // by then it should have started 413 415 while (!m_SyncSource->isRunning() && cnt) { 414 usleep(125);416 SleepRelativeUsec(125); 415 417 cnt--; 416 418 } … … 557 559 ready &= ((*it)->isDryRunning() || (*it)->isStopped()); 558 560 } 559 usleep(125);561 SleepRelativeUsec(125); 560 562 cnt--; 561 563 } … … 597 599 ready &= (*it)->isStopped(); 598 600 } 599 usleep(125);601 SleepRelativeUsec(125); 600 602 cnt--; 601 603 } … … 670 672 671 673 // wait for the period 672 usleep(time_till_next_period);674 SleepRelativeUsec(time_till_next_period); 673 675 674 676 // check for underruns on the ISO side, … … 737 739 if (!ready_for_transfer) { 738 740 739 usleep(125); // MAGIC: one cycle sleep...741 SleepRelativeUsec(125); // MAGIC: one cycle sleep... 740 742 741 743 // in order to avoid this in the future, we increase the sync delay of the sync source SP trunk/libffado/src/libutil/SystemTimeSource.cpp
r742 r783 38 38 39 39 ffado_microsecs_t SystemTimeSource::getCurrentTime() { 40 struct timeval tv; 41 gettimeofday(&tv, NULL); 42 return tv.tv_sec * 1000000ULL + tv.tv_usec; 43 44 // return GetMicroSeconds(); 40 // struct timeval tv; 41 // gettimeofday(&tv, NULL); 42 // return tv.tv_sec * 1000000ULL + tv.tv_usec; 43 struct timespec ts; 44 clock_gettime(CLOCK_MONOTONIC, &ts); 45 return (ffado_microsecs_t)(ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL); 45 46 } 46 47 trunk/libffado/src/libutil/Time.c
r742 r783 22 22 */ 23 23 24 /*25 * Copied from the jackd/jackdmp sources26 * function names changed in order to avoid naming problems when using this in27 * a jackd backend.28 */29 30 /* Original license:31 *32 * Copyright (C) 2001 Paul Davis33 * Copyright (C) 2004-2006 Grame34 *35 * This program is free software; you can redistribute it and/or modify36 * it under the terms of the GNU General Public License as published by37 * the Free Software Foundation; either version 2 of the License, or38 * (at your option) any later version.39 *40 * This program is distributed in the hope that it will be useful,41 * but WITHOUT ANY WARRANTY; without even the implied warranty of42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the43 * GNU General Public License for more details.44 *45 * You should have received a copy of the GNU General Public License46 * along with this program; if not, write to the Free Software47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.48 *49 */50 24 #include "Time.h" 51 25 52 #ifdef GETCYCLE_TIME53 54 #include <stdio.h>55 freebob_microsecs_t GetMhz(void)56 {57 FILE *f = fopen("/proc/cpuinfo", "r");58 if (f == 0)59 {60 perror("can't open /proc/cpuinfo\n");61 exit(1);62 }63 64 for ( ; ; )65 {66 freebob_microsecs_t mhz;67 int ret;68 char buf[1000];69 70 if (fgets(buf, sizeof(buf), f) == NULL) {71 fprintf (stderr,"FATAL: cannot locate cpu MHz in "72 "/proc/cpuinfo\n");73 exit(1);74 }75 76 #if defined(__powerpc__)77 ret = sscanf(buf, "clock\t: %" SCNu64 "MHz", &mhz);78 #elif defined( __i386__ ) || defined (__hppa__) || defined (__ia64__) || \79 defined(__x86_64__)80 ret = sscanf(buf, "cpu MHz : %" SCNu64, &mhz);81 #elif defined( __sparc__ )82 ret = sscanf(buf, "Cpu0Bogo : %" SCNu64, &mhz);83 #elif defined( __mc68000__ )84 ret = sscanf(buf, "Clocking: %" SCNu64, &mhz);85 #elif defined( __s390__ )86 ret = sscanf(buf, "bogomips per cpu: %" SCNu64, &mhz);87 #else /* MIPS, ARM, alpha */88 ret = sscanf(buf, "BogoMIPS : %" SCNu64, &mhz);89 #endif90 if (ret == 1)91 {92 fclose(f);93 return (freebob_microsecs_t)mhz;94 }95 }96 }97 98 freebob_microsecs_t __freebob_cpu_mhz;99 100 void InitTime()101 {102 __freebob_cpu_mhz = GetMhz();103 }104 105 #else106 void InitTime()107 {}108 109 #endif110 trunk/libffado/src/libutil/Time.h
r742 r783 22 22 */ 23 23 24 /*25 * Copied from the jackd/jackdmp sources26 * function names changed in order to avoid naming problems when using this in27 * a jackd backend.28 */29 30 /* Original license:31 *32 * Copyright (C) 2001-2003 Paul Davis33 * Copyright (C) 2004-2006 Grame34 *35 * This program is free software; you can redistribute it and/or modify36 * it under the terms of the GNU General Public License as published by37 * the Free Software Foundation; either version 2 of the License, or38 * (at your option) any later version.39 *40 * This program is distributed in the hope that it will be useful,41 * but WITHOUT ANY WARRANTY; without even the implied warranty of42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the43 * GNU General Public License for more details.44 *45 * You should have received a copy of the GNU General Public License46 * along with this program; if not, write to the Free Software47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.48 *49 */50 51 24 #ifndef __Time__ 52 25 #define __Time__ … … 54 27 #include <stdio.h> 55 28 #include <inttypes.h> 29 #include <unistd.h> 56 30 57 // #define GETCYCLE_TIME 31 #include <time.h> 58 32 59 33 /** … … 61 35 * monotonic clock with units of microseconds. 62 36 */ 63 64 37 typedef uint64_t ffado_microsecs_t; 65 38 66 67 #ifdef __cplusplus 68 extern "C" 69 { 70 #endif 71 72 73 #include <unistd.h> 74 75 static inline void FFADOSleep(long usec) { 76 usleep(usec); 77 } 78 79 #ifdef GETCYCLE_TIME 80 #include "cycles.h" 81 extern ffado_microsecs_t __ffado_cpu_mhz; 82 extern ffado_microsecs_t GetMhz(); 83 extern void InitTime(); 84 static inline ffado_microsecs_t GetMicroSeconds (void) { 85 return get_cycles() / __ffado_cpu_mhz; 86 } 87 #else 88 #include <time.h> 89 extern void InitTime(); 90 static inline ffado_microsecs_t GetMicroSeconds (void) { 91 struct timespec ts; 92 clock_gettime(CLOCK_MONOTONIC, &ts); 93 return (ffado_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; 94 } 95 #endif 96 97 98 #ifdef __cplusplus 39 static inline void SleepRelativeUsec(unsigned long usec) { 40 usleep(usec); 99 41 } 100 42 #endif 101 43 102 44 103 #endif104 45 105 106 trunk/libffado/src/motu/motu_avdevice.cpp
r750 r783 37 37 38 38 #include "libutil/DelayLockedLoop.h" 39 #include "libutil/Time.h" 39 40 40 41 #include <string> … … 959 960 } 960 961 961 usleep(100);962 SleepRelativeUsec(100); 962 963 return (err==0)?0:-1; 963 964 } trunk/libffado/support/dbus/controlserver.cpp
r742 r783 26 26 #include "libcontrol/BasicElements.h" 27 27 #include "libcontrol/MatrixMixer.h" 28 #include "libutil/Time.h" 28 29 29 30 namespace DBusControl { … … 172 173 m_Slave.setValue(value); 173 174 /* 174 usleep(1000*500);175 SleepRelativeUsec(1000*500); 175 176 176 177 debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() ); … … 202 203 m_Slave.setValue(value); 203 204 204 /* usleep(1000*500);205 /* SleepRelativeUsec(1000*500); 205 206 debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() ); 206 207 trunk/libffado/tests/streaming/teststreaming3.c
r750 r783 37 37 38 38 #include <signal.h> 39 #include <sched.h> 39 40 40 41 #include "libffado/ffado.h" … … 47 48 { 48 49 run = 0; 50 set_realtime_priority(0); 51 } 52 53 int set_realtime_priority(unsigned int prio) 54 { 55 if (prio > 0) { 56 struct sched_param schp; 57 /* 58 * set the process to realtime privs 59 */ 60 memset(&schp, 0, sizeof(schp)); 61 schp.sched_priority = prio; 62 63 if (sched_setscheduler(0, SCHED_FIFO, &schp) != 0) { 64 perror("sched_setscheduler"); 65 exit(1); 66 } 67 } else { 68 struct sched_param schp; 69 /* 70 * set the process to realtime privs 71 */ 72 memset(&schp, 0, sizeof(schp)); 73 schp.sched_priority = prio; 74 75 if (sched_setscheduler(0, SCHED_OTHER, &schp) != 0) { 76 perror("sched_setscheduler"); 77 exit(1); 78 } 79 80 } 81 return 0; 49 82 } 50 83 … … 69 102 run=1; 70 103 71 printf("F fadostreaming test application (3)\n");104 printf("FFADO streaming test application (3)\n"); 72 105 73 106 signal (SIGINT, sighandler); … … 86 119 87 120 dev_options.realtime=1; 88 dev_options.packetizer_priority= 70;121 dev_options.packetizer_priority=60; 89 122 90 123 dev_options.verbose = 6; … … 203 236 start_flag = ffado_streaming_start(dev); 204 237 238 set_realtime_priority(dev_options.packetizer_priority-1); 205 239 fprintf(stderr,"Entering receive loop (%d,%d)\n",nb_in_channels,nb_out_channels); 206 240 while(run && start_flag==0) { trunk/libffado/tests/test-echo.cpp
r742 r783 26 26 #include <libiec61883/iec61883.h> 27 27 #include <libavc1394/avc1394.h> 28 #include "libutil/Time.h" 28 29 29 30 #include <argp.h> … … 145 146 // cmd[1] = 0x01FF0000; 146 147 // avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 147 // usleep(100000);148 // SleepRelativeUsec(100000); 148 149 // 149 150 // cerr << "Reading descriptor" << endl; … … 156 157 // 157 158 // avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 3, &response_len, 10); 158 // usleep(100000);159 // SleepRelativeUsec(100000); 159 160 // 160 161 // cerr << "Closing descriptor" << endl; … … 162 163 // cmd[1] = 0x00FF0000; 163 164 // avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 164 // usleep(100000);165 // SleepRelativeUsec(100000); 165 166 166 167 cerr << "getting signal source" << endl; … … 196 197 cmd[1] = 0xFFFE6000; 197 198 avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 198 // usleep(100000);199 // SleepRelativeUsec(100000); 199 200 200 201 cmd[0] = 0x01FF1AFF; 201 202 cmd[1] = 0xFFFEFF00; 202 203 avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 203 usleep(100000);204 SleepRelativeUsec(100000); 204 205 205 206 trunk/libffado/tests/test-focusrite.cpp
r742 r783 32 32 #include "libutil/cmd_serialize.h" 33 33 #include "libavc/general/avc_generic.h" 34 #include "libutil/Time.h" 34 35 35 36 #include "bebob/focusrite/focusrite_cmd.h" … … 191 192 } 192 193 } 193 usleep(1000000);194 SleepRelativeUsec(1000000); 194 195 } 195 196 trunk/libffado/tests/test-ieee1394service.cpp
r752 r783 44 44 45 45 #include <libraw1394/raw1394.h> 46 #include "libutil/Time.h" 46 47 47 48 DECLARE_GLOBAL_DEBUG_MODULE; … … 130 131 fflush(stderr); 131 132 fflush(stdout); 132 usleep(900*1000);133 SleepRelativeUsec(900*1000); 133 134 134 135 uint32_t cycle_timer; trunk/libffado/tests/test-timestampedbuffer.cpp
r748 r783 40 40 41 41 #include "src/libutil/TimestampedBuffer.h" 42 #include "libutil/Time.h" 42 43 43 44 #include <pthread.h> … … 297 298 t->prepare(); 298 299 299 usleep(1000);300 SleepRelativeUsec(1000); 300 301 301 302 debugOutput(DEBUG_LEVEL_NORMAL, "Start setBufferHeadTimestamp test...\n"); … … 365 366 366 367 // allow for the messagebuffer thread to catch up 367 usleep(200);368 SleepRelativeUsec(200); 368 369 369 370 if(!run) break; … … 480 481 481 482 // allow for the messagebuffer thread to catch up 482 usleep(200);483 SleepRelativeUsec(200); 483 484 484 485 if(!run) break; … … 580 581 581 582 // allow for the messagebuffer thread to catch up 582 usleep(200);583 SleepRelativeUsec(200); 583 584 584 585 if(!run) break;