forked from tryphon/rivendell2-debian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdaudio_port.cpp
189 lines (153 loc) · 3.82 KB
/
rdaudio_port.cpp
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// rdaudio_port.cpp
//
// Abstract a Rivendell Audio Port.
//
// (C) Copyright 2002-2003 Fred Gleason <[email protected]>
//
// $Id: rdaudio_port.cpp,v 1.12.8.1 2012/08/03 16:52:39 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rddb.h>
#include <rdaudio_port.h>
//
// Global Classes
//
RDAudioPort::RDAudioPort(QString station,int card,bool create)
{
RDSqlQuery *q;
QString sql;
port_station=station;
port_card=card;
if(create) {
sql=QString().sprintf("select ID from AUDIO_PORTS where \
(STATION_NAME=\"%s\")&&(CARD_NUMBER=%d)",(const char *)port_station,port_card);
q=new RDSqlQuery(sql);
if(q->size()!=1) {
delete q;
sql=QString().sprintf("INSERT INTO AUDIO_PORTS SET STATION_NAME=\"%s\",\
CARD_NUMBER=%d",
(const char *)port_station,port_card);
q=new RDSqlQuery(sql);
delete q;
}
else {
delete q;
}
}
}
QString RDAudioPort::station() const
{
return port_station;
}
int RDAudioPort::card() const
{
return port_card;
}
RDCae::ClockSource RDAudioPort::clockSource()
{
return (RDCae::ClockSource)GetIntValue("CLOCK_SOURCE");
}
void RDAudioPort::setClockSource(RDCae::ClockSource src)
{
SetRow("CLOCK_SOURCE",(int)src);
}
RDAudioPort::PortType RDAudioPort::inputPortType(int port)
{
if(port<0) {
return RDAudioPort::Analog;
}
return
(RDAudioPort::PortType)GetIntValue(QString().sprintf("INPUT_%d_TYPE",port));
}
void RDAudioPort::setInputPortType(int port,RDAudioPort::PortType type)
{
if(port<0) {
return;
}
SetRow(QString().sprintf("INPUT_%d_TYPE",port),(int)type);
}
RDCae::ChannelMode RDAudioPort::inputPortMode(int port)
{
if(port<0) {
return RDCae::Normal;
}
return
(RDCae::ChannelMode)GetIntValue(QString().sprintf("INPUT_%d_MODE",port));
}
void RDAudioPort::setInputPortMode(int port,RDCae::ChannelMode mode)
{
if(port<0) {
return;
}
SetRow(QString().sprintf("INPUT_%d_MODE",port),(int)mode);
}
int RDAudioPort::inputPortLevel(int port)
{
if(port<0) {
return 400;
}
return GetIntValue(QString().sprintf("INPUT_%d_LEVEL",port));
}
void RDAudioPort::setInputPortLevel(int port,int level)
{
if(port<0) {
return;
}
SetRow(QString().sprintf("INPUT_%d_LEVEL",port),level);
}
int RDAudioPort::outputPortLevel(int port)
{
if(port<0) {
return 400;
}
return GetIntValue(QString().sprintf("OUTPUT_%d_LEVEL",port));
}
void RDAudioPort::setOutputPortLevel(int port,int level)
{
if(port<0) {
return;
}
SetRow(QString().sprintf("OUTPUT_%d_LEVEL",port),level);
}
int RDAudioPort::GetIntValue(QString field)
{
QString sql;
RDSqlQuery *q;
int accum;
sql=QString().sprintf("select %s from AUDIO_PORTS where \
(STATION_NAME=\"%s\")&&(CARD_NUMBER=%d)",(const char *)field,
(const char *)port_station,port_card);
q=new RDSqlQuery(sql);
if(q->first()) {
accum=q->value(0).toInt();
delete q;
return accum;
}
delete q;
return 0;
}
void RDAudioPort::SetRow(QString param,int value)
{
RDSqlQuery *q;
QString sql;
sql=QString().sprintf("UPDATE AUDIO_PORTS SET %s=%d \
WHERE (STATION_NAME=\"%s\")&&(CARD_NUMBER=%d)",
(const char *)param,
value,
(const char *)port_station,
port_card);
q=new RDSqlQuery(sql);
delete q;
}