Changeset 205f1add in mainline for uspace/app/wavplay/dplay.c


Ignore:
Timestamp:
2018-08-23T21:14:56Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
f33c989e
Parents:
e2625b1a
git-author:
Jakub Jermar <jakub@…> (2018-08-21 21:58:52)
git-committer:
Jakub Jermar <jakub@…> (2018-08-23 21:14:56)
Message:

Get rid of sys/time.h

This commit moves the POSIX-like time functionality from libc's
sys/time.h to libposix and introduces C99-like or HelenOS-specific
interfaces to libc.

Specifically, use of sys/time.h, struct timeval, suseconds_t and
gettimeofday is replaced by time.h (C99), struct timespec (C99),
usec_t (HelenOS) and getuptime / getrealtime (HelenOS).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/wavplay/dplay.c

    re2625b1a r205f1add  
    4242#include <pcm/format.h>
    4343#include <as.h>
    44 #include <sys/time.h>
     44#include <time.h>
    4545#include <inttypes.h>
    4646#include <stdbool.h>
     
    242242
    243243#define DPRINTF(f, ...) \
    244         printf("%.2lu:%.6lu   "f, time.tv_sec % 100, time.tv_usec, __VA_ARGS__)
     244        printf("%.2lld:%.6lld   "f, time.tv_sec % 100, \
     245            NSEC2USEC(time.tv_nsec), __VA_ARGS__)
    245246
    246247/**
     
    255256        printf("Playing: %dHz, %s, %d channel(s).\n", pb->f.sampling_rate,
    256257            pcm_sample_format_str(pb->f.sample_format), pb->f.channels);
    257         useconds_t work_time = 50000; /* 50 ms */
     258        usec_t work_time = 50000; /* 50 ms */
    258259        bool started = false;
    259260        size_t pos = 0;
    260         struct timeval time = { 0 };
     261        struct timespec time = { 0 };
    261262        getuptime(&time);
    262263        while (true) {
     
    303304                }
    304305                const size_t to_play = buffer_occupied(pb, pos);
    305                 const useconds_t usecs =
    306                     pcm_format_size_to_usec(to_play, &pb->f);
     306                const usec_t usecs = pcm_format_size_to_usec(to_play, &pb->f);
    307307
    308308                /* Compute delay time */
    309                 const useconds_t real_delay = (usecs > work_time) ?
     309                const usec_t real_delay = (usecs > work_time) ?
    310310                    usecs - work_time : 0;
    311                 DPRINTF("POS %zu: %u usecs (%u) to play %zu bytes.\n",
     311                DPRINTF("POS %zu: %lld usecs (%lld) to play %zu bytes.\n",
    312312                    pos, usecs, real_delay, to_play);
    313313                if (real_delay)
Note: See TracChangeset for help on using the changeset viewer.