Use jack_client_open instead of old jack_client_new.
[jack2.git] / common / timestamps.c
blob7a48e8a9e47c44fdee52b42adcbfed94ce0ffc32
1 /*
2 Copyright (C) 2002-2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <stdlib.h>
21 #include <string.h>
22 #include "timestamps.h"
23 #include "JackTime.h"
25 typedef struct {
26 jack_time_t when;
27 const char *what;
28 } jack_timestamp_t;
30 static jack_timestamp_t *timestamps = 0;
31 static unsigned long timestamp_cnt = 0;
32 static unsigned long timestamp_index;
34 void
35 jack_init_timestamps (unsigned long howmany)
37 if (timestamps) {
38 free (timestamps);
40 timestamps = (jack_timestamp_t *)
41 malloc (howmany * sizeof(jack_timestamp_t));
42 timestamp_cnt = howmany;
43 memset (timestamps, 0, sizeof(jack_timestamp_t) * howmany);
44 timestamp_index = 0;
47 void
48 jack_timestamp (const char *what)
50 if (timestamp_index < timestamp_cnt) {
51 timestamps[timestamp_index].when = GetMicroSeconds();
52 timestamps[timestamp_index].what = what;
53 ++timestamp_index;
57 void
58 jack_dump_timestamps (FILE *out)
60 unsigned long i;
62 for (i = 0; i < timestamp_index; ++i) {
63 fprintf (out, "%-.32s %" PRIu64 " %" PRIu64,
64 timestamps[i].what, timestamps[i].when,
65 timestamps[i].when - timestamps[0].when);
66 if (i > 0) {
67 fprintf (out, " %" PRIu64,
68 timestamps[i].when - timestamps[i-1].when);
70 fputc ('\n', out);
74 void
75 jack_reset_timestamps ()
77 timestamp_index = 0;