Repository navigation
Expand file tree
/
Copy pathtransfermode.h
More file actions
360 lines (331 loc) · 13 KB
/
Copy pathtransfermode.h
File metadata and controls
360 lines (331 loc) · 13 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/**
* Copyright (C) 2025 Jo2003 (olenka.joerg@gmail.com)
* This file is part of NetMD Wizard
*
* NetMD Wizard is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NetMD Wizard 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
*/
#pragma once
#include <cstdint>
#include "cnetmd.h"
#include "cxenc.h"
//------------------------------------------------------------------------------
//! @brief This class describes a transfer mode.
//------------------------------------------------------------------------------
class TransferMode
{
public:
using XEncCmd = CXEnc::XEncCmd;
using NetMDCmd = CNetMD::NetMDCmd;
enum ETransferMode
{
TM_TAO_START,
TM_TAO_SP,
TM_TAO_SP_MONO,
TM_TAO_LP2,
TM_TAO_LP4,
TM_TAO_END,
TM_DAO_START,
TM_DAO_SP,
TM_DAO_SP_MONO,
TM_DAO_SP_PREENC,
TM_DAO_LP2,
TM_DAO_LP4,
TM_DAO_END,
TM_UNKNOWN
};
struct TFModeDescr
{
ETransferMode mMode;
const char* mName;
const char* mTrackMode;
const char* mIconSrc;
int mMulti;
XEncCmd mEncCmd;
NetMDCmd mNetMDCmd;
XEncCmd mEncCmdOtf;
NetMDCmd mNetMDCmdOtf;
};
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param[in] m transfer mode value
//--------------------------------------------------------------------------
TransferMode(ETransferMode m = ETransferMode::TM_UNKNOWN)
: mTransferMode(m)
{
}
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param[in] m transfer mode value
//--------------------------------------------------------------------------
TransferMode(int m)
: mTransferMode(static_cast<ETransferMode>(m))
{
}
//--------------------------------------------------------------------------
//! @brief Etransfermode conversion operator.
//--------------------------------------------------------------------------
operator ETransferMode() const
{
return mTransferMode;
}
//--------------------------------------------------------------------------
//! @brief Bool conversion operator.
//--------------------------------------------------------------------------
operator bool() const
{
return isValid();
}
//--------------------------------------------------------------------------
//! @brief Assignment operator.
//!
//! @param[in] other The other
//!
//! @return The result of the assignment
//--------------------------------------------------------------------------
TransferMode& operator=(ETransferMode other)
{
mTransferMode = other;
return *this;
}
//--------------------------------------------------------------------------
//! @brief Assignment operator.
//!
//! @param[in] other The other
//!
//! @return The result of the assignment
//--------------------------------------------------------------------------
TransferMode& operator=(int other)
{
mTransferMode = static_cast<ETransferMode>(other);
return *this;
}
//--------------------------------------------------------------------------
//! @brief Determines if dao.
//!
//! @return True if dao, False otherwise.
//--------------------------------------------------------------------------
bool isDao() const
{
return ((mTransferMode > TM_DAO_START) && (mTransferMode < TM_DAO_END));
}
//--------------------------------------------------------------------------
//! @brief Determines if tao.
//!
//! @return True if tao, False otherwise.
//--------------------------------------------------------------------------
bool isTao() const
{
return ((mTransferMode > TM_TAO_START) && (mTransferMode < TM_TAO_END));
}
//--------------------------------------------------------------------------
//! @brief Determines if valid.
//!
//! @return True if valid, False otherwise.
//--------------------------------------------------------------------------
bool isValid() const
{
return (isDao() || isTao());
}
//--------------------------------------------------------------------------
//! @brief does this mode require TOC manipulation
//!
//! @return true if yes, False otherwise
//--------------------------------------------------------------------------
bool tocManip() const
{
return ((mTransferMode == TM_DAO_SP) || (mTransferMode == TM_DAO_SP_MONO) || (mTransferMode == TM_DAO_SP_PREENC));
}
//--------------------------------------------------------------------------
//! @brief does this mode require SP upload
//!
//! @return true if yes, False otherwise
//--------------------------------------------------------------------------
bool spUpld() const
{
return mTransferMode == TM_DAO_SP_PREENC;
}
//--------------------------------------------------------------------------
//! @brief get short mode name
//!
//! @return name or nullptr
//--------------------------------------------------------------------------
const char* name() const
{
if (const auto* m = find(mTransferMode))
{
return m->mName;
}
return nullptr;
}
//--------------------------------------------------------------------------
//! @brief get track mode
//!
//! @return mode or nullptr
//--------------------------------------------------------------------------
const char* trackMode() const
{
if (const auto* m = find(mTransferMode))
{
return m->mTrackMode;
}
return nullptr;
}
//--------------------------------------------------------------------------
//! @brief get icon source
//!
//! @return icon source or nullptr
//--------------------------------------------------------------------------
const char* iconSrc() const
{
if (const auto* m = find(mTransferMode))
{
return m->mIconSrc;
}
return nullptr;
}
//--------------------------------------------------------------------------
//! @brief get time multiplicator
//!
//! @return multiplicator
//--------------------------------------------------------------------------
int multi() const
{
if (const auto* m = find(mTransferMode))
{
return m->mMulti;
}
return 1;
}
//--------------------------------------------------------------------------
//! @brief get NetMD command
//!
//! @param[in] otf on the fly marker
//!
//! @return The net md command.
//--------------------------------------------------------------------------
NetMDCmd netMDCmd(bool otf) const
{
if (const auto* m = find(mTransferMode))
{
return otf ? m->mNetMDCmdOtf : m->mNetMDCmd;
}
return NetMDCmd::UNKNWON;
}
//--------------------------------------------------------------------------
//! @brief get encoder command
//!
//! @param[in] otf on the fly marker
//!
//! @return The encode command.
//--------------------------------------------------------------------------
XEncCmd xencCmd(bool otf) const
{
if (const auto* m = find(mTransferMode))
{
return otf ? m->mEncCmdOtf : m->mEncCmd;
}
return XEncCmd::NONE;
}
//--------------------------------------------------------------------------
//! @brief check if mode is supported (device feature dependent)
//!
//! @param[in] tocMnp The toc manipulation flag
//! @param[in] spUpd The sp update flag
//! @param[in] mono The sp mono support flag
//!
//! @return true if supported, false otherwise
//--------------------------------------------------------------------------
bool supports(bool tocMnp, bool spUpd, bool mono) const
{
return ((!tocManip() || (tocManip() && tocMnp))
&& (!spUpld() || (spUpld() && spUpd))
&& (!isMono() || (isMono() && mono)));
}
//--------------------------------------------------------------------------
//! @brief const char* conversion operator.
//--------------------------------------------------------------------------
operator const char*() const
{
#define mkCase(x_) case x_: c = #x_; break
const char* c;
switch(mTransferMode)
{
mkCase(TM_TAO_SP);
mkCase(TM_TAO_SP_MONO);
mkCase(TM_TAO_LP2);
mkCase(TM_TAO_LP4);
mkCase(TM_DAO_SP);
mkCase(TM_DAO_SP_MONO);
mkCase(TM_DAO_SP_PREENC);
mkCase(TM_DAO_LP2);
mkCase(TM_DAO_LP4);
default: c = ""; break;
}
return c;
#undef mkCase
}
//--------------------------------------------------------------------------
//! @brief Determines if mono.
//!
//! @return True if mono, False otherwise.
//--------------------------------------------------------------------------
bool isMono() const
{
return ((mTransferMode == TM_TAO_SP_MONO) || (mTransferMode == TM_DAO_SP_MONO));
}
//--------------------------------------------------------------------------
//! @brief Determines if lp.
//!
//! @return True if lp, False otherwise.
//--------------------------------------------------------------------------
bool isLP() const
{
return ((mTransferMode == TM_TAO_LP2) || (mTransferMode == TM_TAO_LP4)
|| (mTransferMode == TM_DAO_LP2) || (mTransferMode == TM_DAO_LP4));
}
protected:
//--------------------------------------------------------------------------
//! @brief Searches for the first match.
//!
//! @param[in] m ETransferMode to search for
//!
//! @return pointer to description, nullptr if not found
//--------------------------------------------------------------------------
const TFModeDescr* find(ETransferMode m) const
{
for (int i = 0; i < VALID_TF_COUNT; i++)
{
if (mModeMap[i].mMode == m)
{
return &mModeMap[i];
}
}
return nullptr;
}
private:
ETransferMode mTransferMode;
static constexpr int VALID_TF_COUNT = 9;
const TFModeDescr mModeMap[VALID_TF_COUNT] = {
{ ETransferMode::TM_TAO_SP , "SP" , "SP" , ":/view/audio", 1, XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP },
{ ETransferMode::TM_TAO_SP_MONO , "SP Mono" , "SP Mono", ":/view/audio", 2, XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP_MONO , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP_MONO },
{ ETransferMode::TM_TAO_LP2 , "LP2" , "LP2" , ":/view/audio", 2, XEncCmd::LP2_ENCODE , NetMDCmd::WRITE_TRACK_SP , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_LP2 },
{ ETransferMode::TM_TAO_LP4 , "LP4" , "LP4" , ":/view/audio", 4, XEncCmd::LP4_ENCODE , NetMDCmd::WRITE_TRACK_SP , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_LP4 },
{ ETransferMode::TM_DAO_SP , "SP" , "SP" , ":/buttons/cd", 1, XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP },
{ ETransferMode::TM_DAO_SP_MONO , "SP Mono" , "SP Mono", ":/buttons/cd", 2, XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP_MONO , XEncCmd::NONE , NetMDCmd::WRITE_TRACK_SP_MONO },
{ ETransferMode::TM_DAO_SP_PREENC, "SP Preenc", "SP" , ":/buttons/cd", 1, XEncCmd::DAO_SP_ENCODE , NetMDCmd::WRITE_TRACK_SP_PREENC, XEncCmd::DAO_SP_ENCODE , NetMDCmd::WRITE_TRACK_SP_PREENC },
{ ETransferMode::TM_DAO_LP2 , "LP2" , "LP2" , ":/buttons/cd", 2, XEncCmd::DAO_LP2_ENCODE, NetMDCmd::WRITE_TRACK_SP , XEncCmd::DAO_LP2_ENCODE, NetMDCmd::WRITE_TRACK_SP },
{ ETransferMode::TM_DAO_LP4 , "LP4" , "LP4" , ":/buttons/cd", 4, XEncCmd::DAO_LP4_ENCODE, NetMDCmd::WRITE_TRACK_SP , XEncCmd::DAO_LP4_ENCODE, NetMDCmd::WRITE_TRACK_SP },
};
};