2 * Copyright (c) 2012-2014, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __SRS_DAEMON_PULSE_H__
31 #define __SRS_DAEMON_PULSE_H__
34 #include <murphy/common/macros.h>
35 #include <pulse/pulseaudio.h>
37 #include "srs/daemon/voice.h"
46 SRS_STREAM_EVENT_NONE = SRS_VOICE_EVENT_STARTED - 1,
47 SRS_STREAM_EVENT_STARTED = SRS_VOICE_EVENT_STARTED,
48 SRS_STREAM_EVENT_PROGRESS = SRS_VOICE_EVENT_PROGRESS,
49 SRS_STREAM_EVENT_COMPLETED = SRS_VOICE_EVENT_COMPLETED,
50 SRS_STREAM_EVENT_TIMEOUT = SRS_VOICE_EVENT_TIMEOUT,
51 SRS_STREAM_EVENT_ABORTED = SRS_VOICE_EVENT_ABORTED,
52 SRS_STREAM_EVENT_CORKED,
53 SRS_STREAM_EVENT_UNCORKED,
54 } srs_stream_event_type_t;
56 #define SRS_STREAM_MASK_NONE SRS_VOICE_MASK_NONE
57 #define SRS_STREAM_MASK_STARTED SRS_VOICE_MASK_STARTED
58 #define SRS_STREAM_MASK_PROGRESS SRS_VOICE_MASK_PROGRESS
59 #define SRS_STREAM_MASK_COMPLETED SRS_VOICE_MASK_COMPLETED
60 #define SRS_STREAM_MASK_ABORTED SRS_VOICE_MASK_ABORTED
61 #define SRS_STREAM_MASK_CORKED (1 << SRS_STREAM_EVENT_CORKED)
62 #define SRS_STREAM_MASK_UNCORKED (1 << SRS_STREAM_EVENT_UNCORKED)
63 #define SRS_STREAM_MASK_ONESHOT (~(SRS_STREAM_MASK_PROGRESS))
64 #define SRS_STREAM_MASK_ALL (SRS_STREAM_MASK_STARTED | \
65 SRS_STREAM_MASK_PROGRESS | \
66 SRS_STREAM_MASK_COMPLETED | \
67 SRS_STREAM_MASK_ABORTED)
69 typedef srs_voice_event_t srs_stream_event_t;
71 typedef void (*srs_stream_cb_t)(srs_pulse_t *p, srs_stream_event_t *event,
74 /** Set up the PulseAudio interface. */
75 srs_pulse_t *srs_pulse_setup(pa_mainloop_api *pa, const char *name);
77 /** Clean up the audio interface. */
78 void srs_pulse_cleanup(srs_pulse_t *p);
80 /** Render an stream (a buffer of audio samples). */
81 uint32_t srs_play_stream(srs_pulse_t *p, void *sample_buf, int sample_rate,
82 int nchannel, uint32_t nsample, char **tags,
83 int event_mask, srs_stream_cb_t cb,
86 /** Stop an ongoing stream. */
87 int srs_stop_stream(srs_pulse_t *p, uint32_t id, int drain, int notify);
91 #endif /* __SRS_DAEMON_PULSE_H__ */