File: stream.h

package info (click to toggle)
tone-generator 1.6.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 356 kB
  • sloc: ansic: 3,037; sh: 61; makefile: 28
file content (109 lines) | stat: -rw-r--r-- 3,799 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*************************************************************************
This file is part of tone-generator

Copyright (C) 2010 Nokia Corporation.

This library is free software; you can redistribute
it and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA.
*************************************************************************/

#ifndef __TONEGEND_STREAM_H__
#define __TONEGEND_STREAM_H__

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <pulse/pulseaudio.h>

#define STREAM_INDICATOR    "indtone"
#define STREAM_DTMF         "dtmf"
#define STREAM_NOTES        "ringtone"
#define STREAM_NOTIFICATION "notiftone"

#define PROP_STREAM_RESTORE "module-stream-restore.id"
#define PROP_MEDIA_ROLE     "media.role"
#define ID_KEYPRESS         "x-maemo-key-pressed"
#define ID_PHONE            "phone"
#define INPUT_BY_ROLE       "sink-input-by-media-role"

struct ausrv;

struct stream_stat {
    uint64_t           firstwr;      /* first writting time */
    uint64_t           wrtime;       /* time of last writting */
    uint32_t           wrcnt;        /* write count */
    uint32_t           minbuf;
    uint32_t           maxbuf;
    uint32_t           mingap;
    uint32_t           maxgap;
    uint64_t           sumgap;
    uint32_t           mincalc;
    uint32_t           maxcalc;
    uint64_t           sumcalc;
    uint32_t           cpucalc;
    uint32_t           underflows;
    uint32_t           late;
};

struct stream {
    struct stream     *next;
    struct ausrv      *ausrv;
    int                id;       /* stream id */
    char              *name;     /* stream name */
    uint32_t           rate;     /* sample rate */
    pa_stream         *pastr;    /* pulse audio stream */
    uint64_t           start;    /* wall clock time of stream creation */
    uint32_t           time;     /* buffer time in usecs */
    uint32_t           end;      /* buffer timeout for the stream in usec */
    int                flush;    /* flush on destroy */
    int                killed;
    uint32_t           bufsize;  /* write-ahead-buffer size (ie. minreq) */
    uint32_t           bcnt;     /* byte count */
    uint32_t         (*write)(struct stream *, int16_t *, int);
    void             (*destroy)(void *);
    void              *data;     /* extension */
    struct stream_stat stat;     /* statistics */
    struct {
        int16_t  *samples;
        size_t    buflen;
        uint32_t  cpu;
    }                  buf;
};

int stream_init(int, char **);
void stream_set_default_samplerate(uint32_t);
void stream_print_statistics(int);
void stream_buffering_parameters(int, int);
struct stream *stream_create(struct ausrv *, char *, char *, uint32_t,
                             uint32_t (*)(struct stream *, int16_t*, int),
                             void (*)(void*), void *, void *);
void stream_destroy(struct stream *);
void stream_set_timeout(struct stream *, uint32_t);
void stream_kill_all(struct ausrv *);
void stream_clean_buffer(struct stream *);
struct stream *stream_find(struct ausrv *, char *);
void *stream_parse_properties(char *);
void stream_free_properties(void *);


#endif /* __TONEGEND_STREAM_H__ */

/*
 * Local Variables:
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */