diff options
| author | Lennart Poettering <lennart@poettering.net> | 2004-12-11 00:10:41 +0000 | 
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2004-12-11 00:10:41 +0000 | 
| commit | 73eabece3365c1bb47bf6b009682219c4492fda5 (patch) | |
| tree | 907b66e2fe29705a512e5f3a240210590b8fe9ba /polyp/util.c | |
| parent | 5be9641ffe18c482294c99345306c382ba4cf750 (diff) | |
* add first part of zeroconf publisher
* bump version to 0.7.1.
* improve logging subsystem (introducing log levels)
* remove verbose flag on cli
* add new API pa_sample_format_to_string()
* replace strtol() by usages of pa_atou() and pa_atoi()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@317 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/util.c')
| -rw-r--r-- | polyp/util.c | 49 | 
1 files changed, 41 insertions, 8 deletions
| diff --git a/polyp/util.c b/polyp/util.c index 970ebb93..ff1aebf3 100644 --- a/polyp/util.c +++ b/polyp/util.c @@ -381,9 +381,9 @@ supported.*/  void pa_raise_priority(void) {      if (setpriority(PRIO_PROCESS, 0, NICE_LEVEL) < 0) -        pa_log(__FILE__": setpriority() failed: %s\n", strerror(errno)); -/*     else */ -/*         pa_log(__FILE__": Successfully gained nice level %i.\n", NICE_LEVEL); */ +        pa_log_warn(__FILE__": setpriority() failed: %s\n", strerror(errno)); +    else  +        pa_log_info(__FILE__": Successfully gained nice level %i.\n", NICE_LEVEL);   #ifdef _POSIX_PRIORITY_SCHEDULING      { @@ -396,11 +396,11 @@ void pa_raise_priority(void) {          sp.sched_priority = 1;          if (sched_setscheduler(0, SCHED_FIFO, &sp) < 0) { -            pa_log(__FILE__": sched_setscheduler() failed: %s\n", strerror(errno)); +            pa_log_warn(__FILE__": sched_setscheduler() failed: %s\n", strerror(errno));              return;          } -/*         pa_log(__FILE__": Successfully enabled SCHED_FIFO scheduling.\n"); */ +        pa_log_info(__FILE__": Successfully enabled SCHED_FIFO scheduling.\n");       }  #endif  } @@ -698,17 +698,17 @@ int pa_unlock_lockfile(const char *fn, int fd) {      assert(fn && fd >= 0);      if (unlink(fn) < 0) { -        pa_log(__FILE__": WARNING: unable to remove lock file '%s': %s\n", fn, strerror(errno)); +        pa_log_warn(__FILE__": WARNING: unable to remove lock file '%s': %s\n", fn, strerror(errno));          r = -1;      }      if (pa_lock_fd(fd, 0) < 0) { -        pa_log(__FILE__": WARNING: failed to unlock file '%s'.\n", fn); +        pa_log_warn(__FILE__": WARNING: failed to unlock file '%s'.\n", fn);          r = -1;      }      if (close(fd) < 0) { -        pa_log(__FILE__": WARNING: failed to close lock file '%s': %s\n", fn, strerror(errno)); +        pa_log_warn(__FILE__": WARNING: failed to close lock file '%s': %s\n", fn, strerror(errno));          r = -1;      } @@ -862,6 +862,7 @@ char *pa_runtime_path(const char *fn, char *s, size_t l) {      return s;  } +/* Wait t milliseconds */  int pa_msleep(unsigned long t) {      struct timespec ts; @@ -870,3 +871,35 @@ int pa_msleep(unsigned long t) {      return nanosleep(&ts, NULL);  } + +/* Convert the string s to a signed integer in *ret_i */ +int pa_atoi(const char *s, int32_t *ret_i) { +    char *x = NULL; +    long l; +    assert(s && ret_i); + +    l = strtol(s, &x, 0); + +    if (x || *x) +        return -1; + +    *ret_i = (int32_t) l; +     +    return 0; +} + +/* Convert the string s to an unsigned integer in *ret_u */ +int pa_atou(const char *s, uint32_t *ret_u) { +    char *x = NULL; +    unsigned long l; +    assert(s && ret_u); + +    l = strtoul(s, &x, 0); + +    if (!x || *x) +        return -1; + +    *ret_u = (uint32_t) l; +     +    return 0; +} | 
