aboutsummaryrefslogtreecommitdiff
path: root/bin/pcmi.cpp
blob: edb9e567994e2cca6812f451176c337da87fe5d7 (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
 * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the Artistic License 2.0 as published by
 * The Perl Foundation.
 *
 * This source 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
 * Artistic License 2.0 for more details.
 *
 * You should have received a copy of the Artistic License 2.0
 * along the source as a COPYING file. If not, obtain it from
 * http://www.perlfoundation.org/artistic_license_2_0.
 */

#include <pcmi.h>
#include <zita-alsa-pcmi.h>

pcmi_t *
pcmi_new(const char *play_name, const char *capt_name, uint32_t srate,
	uint32_t frsize, uint32_t nfrags, int twochan, int debug)
{
	unsigned int opts = 0;
	if(debug)
		opts |= Alsa_pcmi::DEBUG_ALL;
	if(twochan) // force 2 channels
		opts |= Alsa_pcmi::FORCE_2CH;

	Alsa_pcmi *_pcmi = new Alsa_pcmi(play_name, capt_name, NULL,
		srate, frsize, nfrags, opts);
	if(_pcmi->state())
	{
		delete _pcmi;
		return NULL;
	}

	return (pcmi_t *)_pcmi;
}

void
pcmi_free(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	delete _pcmi;
}

void
pcmi_printinfo(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->printinfo();
}

int
pcmi_ncapt(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	return _pcmi->ncapt();
}

int
pcmi_nplay(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	return _pcmi->nplay();
}

void
pcmi_pcm_start(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->pcm_start();
}

int
pcmi_pcm_wait(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	return _pcmi->pcm_wait();
}

int
pcmi_pcm_idle(pcmi_t *pcmi, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	return _pcmi->pcm_idle(frsize);
}

void
pcmi_pcm_stop(pcmi_t *pcmi)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->pcm_stop();
}

void
pcmi_capt_init(pcmi_t *pcmi, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->capt_init(frsize);
}

void
pcmi_capt_chan(pcmi_t *pcmi, uint32_t channel, float *dst, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->capt_chan(channel, dst, frsize);
}

void
pcmi_capt_done(pcmi_t *pcmi, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->capt_done(frsize);
}

void
pcmi_play_init(pcmi_t *pcmi, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->play_init(frsize);
}

void
pcmi_clear_chan(pcmi_t *pcmi, uint32_t channel, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->clear_chan(channel, frsize);
}

void
pcmi_play_chan(pcmi_t *pcmi, uint32_t channel, const float *src, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->play_chan(channel, src, frsize);
}

void
pcmi_play_done(pcmi_t *pcmi, uint32_t frsize)
{
	Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;

	_pcmi->play_done(frsize);
}