summaryrefslogtreecommitdiff
path: root/media-sound/qmmp/files/qmmp-2.3.2-libsidplayfp-3.patch
blob: b59451537864c0b04eea719dfe6244178c7493a0 (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
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
add support for libsidplayfp-3
backport from svn master: r13128, r13131, r13132, r13133, r13136, r13139
--- a/src/plugins/Input/sid/CMakeLists.txt
+++ b/src/plugins/Input/sid/CMakeLists.txt
@@ -1,8 +1,18 @@
 project(libsid)
 
+include(CheckIncludeFileCXX)
+
 # libsidplayfp
 pkg_search_module(SIDPLAYFP libsidplayfp>=1.0.3 IMPORTED_TARGET)
 
+# libresidfp support
+if(SIDPLAYFP_FOUND)
+    check_include_file_cxx(sidplayfp/builders/residfp.h RESIDFP_HEADER_FOUND ${SIDPLAYFP_CFLAGS})
+    if(RESIDFP_HEADER_FOUND)
+        add_definitions(-DHAVE_RESIDFP_HEADER)
+    endif(RESIDFP_HEADER_FOUND)
+endif(SIDPLAYFP_FOUND)
+
 SET(libsid_SRCS
   decoder_sid.cpp
   decodersidfactory.cpp
--- a/src/plugins/Input/sid/decoder_sid.cpp
+++ b/src/plugins/Input/sid/decoder_sid.cpp
@@ -24,8 +24,14 @@
 #include <sidplayfp/SidTune.h>
 #include <sidplayfp/sidbuilder.h>
 #include <sidplayfp/SidConfig.h>
-#include <sidplayfp/builders/residfp.h>
+#if LIBSIDPLAYFP_VERSION_MAJ >= 3
+#include <sidplayfp/builders/sidlite.h>
+#else
 #include <sidplayfp/builders/resid.h>
+#endif
+#ifdef HAVE_RESIDFP_HEADER
+#include <sidplayfp/builders/residfp.h>
+#endif
 #include <sidplayfp/SidInfo.h>
 #include <sidplayfp/SidTuneInfo.h>
 #include <sidplayfp/SidDatabase.h>
@@ -52,13 +58,14 @@ bool DecoderSID::initialize()
     int track = -1;
     QString path = TrackInfo::pathFromUrl(m_url, &track);
 
-    m_tune.load(qPrintable(path));
-    if(!m_tune.getInfo())
+    m_tune = std::make_unique<SidTune>(nullptr);
+    m_tune->load(qPrintable(path));
+    if(!m_tune->getInfo())
     {
-        qCWarning(plugin, "unable to load tune, error: %s", m_tune.statusString());
+        qCWarning(plugin, "unable to load tune, error: %s", m_tune->statusString());
         return false;
     }
-    int count = m_tune.getInfo()->songs();
+    int count = m_tune->getInfo()->songs();
 
     if(track > count || track < 1)
     {
@@ -66,16 +73,16 @@ bool DecoderSID::initialize()
         return false;
     }
 
-    m_tune.selectSong(track);
+    m_tune->selectSong(track);
 
-    if(!m_tune.getStatus())
+    if(!m_tune->getStatus())
     {
-        qCWarning(plugin, "error: %s", m_tune.statusString());
+        qCWarning(plugin, "error: %s", m_tune->statusString());
         return false;
     }
 
     //send metadata for pseudo-protocol
-    const SidTuneInfo *tune_info = m_tune.getInfo();
+    const SidTuneInfo *tune_info = m_tune->getInfo();
     QMap<Qmmp::MetaData, QString> metadata;
     metadata.insert(Qmmp::TITLE, QString::fromUtf8(tune_info->infoString(0)));
     metadata.insert(Qmmp::ARTIST, QString::fromUtf8(tune_info->infoString(1)));
@@ -89,7 +96,7 @@ bool DecoderSID::initialize()
     if(settings.value(u"use_hvsc"_s, false).toBool())
     {
         char md5[SidTune::MD5_LENGTH + 1];
-        m_tune.createMD5(md5);
+        m_tune->createMD5(md5);
         m_length = m_db->length(md5, track);
     }
 
@@ -98,26 +105,43 @@ bool DecoderSID::initialize()
 
     qCDebug(plugin, "song length: %d", m_length);
 
-    sidbuilder *rs = nullptr;
+#if LIBSIDPLAYFP_VERSION_MAJ >= 3
+#ifdef HAVE_RESIDFP_HEADER
+    if(settings.value(u"engine"_s, u"sidlite"_s).toString() == "residfp"_L1)
+    {
+        m_builder = std::make_unique<ReSIDfpBuilder>("ReSIDfp");
+    }
+    else
+#endif
+    {
+        m_builder = std::make_unique<SIDLiteBuilder>("SIDLite");
+    }
+#else
+#ifdef HAVE_RESIDFP_HEADER
     if(settings.value(u"engine"_s, u"residfp"_s).toString() == "residfp"_L1)
     {
-        rs = new ReSIDfpBuilder("ReSIDfp builder");
-        qCDebug(plugin, "using ReSIDfp emulation");
+        m_builder = std::make_unique<ReSIDfpBuilder>("ReSIDfp");
     }
     else
+#endif
     {
-        rs = new ReSIDBuilder("ReSID builder");
-        qCDebug(plugin, "using ReSID emulation");
+        m_builder = std::make_unique<ReSIDBuilder>("ReSID");
     }
-    rs->create(m_player->info().maxsids());
+    m_builder->create(m_player->info().maxsids());
+#endif
+
+    qCDebug(plugin, "using %s emulation", m_builder->name());
 
     SidConfig cfg = m_player->config();
     cfg.frequency    = settings.value(u"sample_rate"_s, 48000).toInt();
     int sm = settings.value(u"resampling_method"_s, SidConfig::INTERPOLATE).toInt();
-    cfg.samplingMethod = (SidConfig::sampling_method_t) sm;
+    cfg.samplingMethod = static_cast<SidConfig::sampling_method_t>(sm);
+
+    cfg.sidEmulation = m_builder.get();
+#if LIBSIDPLAYFP_VERSION_MAJ < 3
     cfg.playback     = SidConfig::STEREO;
-    cfg.sidEmulation = rs;
     cfg.fastSampling = settings.value(u"fast_resampling"_s, false).toBool();
+#endif
     settings.endGroup();
 
     if(!m_player->config(cfg))
@@ -126,7 +150,7 @@ bool DecoderSID::initialize()
         return false;
     }
 
-    if(!m_player->load(&m_tune))
+    if(!m_player->load(m_tune.get()))
     {
         qCWarning(plugin, "unable to load tune, error: %s", m_player->error());
         return false;
--- a/src/plugins/Input/sid/decoder_sid.h
+++ b/src/plugins/Input/sid/decoder_sid.h
@@ -21,11 +21,13 @@
 #ifndef DECODER_SID_H
 #define DECODER_SID_H
 
+#include <memory>
 #include <qmmp/decoder.h>
 
 class sidplayfp;
 class SidDatabase;
 class SidTune;
+class sidbuilder;
 
 /**
    @author Ilya Kotov <forkotov02@ya.ru>
@@ -50,7 +52,8 @@ private:
     int m_length = 0;
     qint64 m_length_in_bytes = 0;
     qint64 m_read_bytes = 0;
-    SidTune m_tune;
+    std::unique_ptr<SidTune> m_tune;
+    std::unique_ptr<sidbuilder> m_builder;
 };
 
 #endif // DECODER_SID_H
--- a/src/plugins/Input/sid/sid.pro
+++ b/src/plugins/Input/sid/sid.pro
@@ -17,6 +17,8 @@ RESOURCES = translations/translations.qrc
 FORMS += \
     sidsettingsdialog.ui
 
+DEFINES += HAVE_RESIDFP_HEADER
+
 unix{
     target.path = $$PLUGIN_DIR/Input
     INSTALLS += target
--- a/src/plugins/Input/sid/sidsettingsdialog.cpp
+++ b/src/plugins/Input/sid/sidsettingsdialog.cpp
@@ -22,6 +22,7 @@
 #include <QFileInfo>
 #include <qmmp/qmmp.h>
 #include <sidplayfp/SidConfig.h>
+#include <sidplayfp/sidplayfp.h>
 #include "sidsettingsdialog.h"
 #include "ui_sidsettingsdialog.h"
 
@@ -40,20 +41,33 @@ SidSettingsDialog::SidSettingsDialog(SidDatabase *db, QWidget *parent) : QDialog
 
     m_ui->sampleRateComboBox->addItem(tr("44100 Hz"), 44100);
     m_ui->sampleRateComboBox->addItem(tr("48000 Hz"), 48000);
-    int i = m_ui->sampleRateComboBox->findData(settings.value(u"sample_rate"_s, 48000).toInt());
-    m_ui->sampleRateComboBox->setCurrentIndex(i);
+    int index = m_ui->sampleRateComboBox->findData(settings.value(u"sample_rate"_s, 48000).toInt());
+    m_ui->sampleRateComboBox->setCurrentIndex(index);
 
+#if LIBSIDPLAYFP_VERSION_MAJ >= 3
+    m_ui->emuComboBox->addItem(u"SIDLite"_s, u"sidlite"_s);
+    m_ui->emuComboBox->addItem(u"ReSIDfp"_s, u"residfp"_s);
+    index = m_ui->emuComboBox->findData(settings.value(u"engine"_s, u"sidlite"_s).toString());
+    m_ui->emuComboBox->setCurrentIndex(qMax(index, 0));
+    m_ui->fastResampligCheckBox->setVisible(false);
+#else
     m_ui->emuComboBox->addItem(u"ReSID"_s, u"resid"_s);
     m_ui->emuComboBox->addItem(u"ReSIDfp"_s, u"residfp"_s);
-    i = m_ui->emuComboBox->findData(settings.value(u"engine"_s, u"residfp"_s).toString());
-    m_ui->emuComboBox->setCurrentIndex(i);
-
+    index = m_ui->emuComboBox->findData(settings.value(u"engine"_s, u"residfp"_s).toString());
+    m_ui->emuComboBox->setCurrentIndex(qMax(index, 0));
     m_ui->fastResampligCheckBox->setChecked(settings.value(u"fast_resampling"_s, false).toBool());
+#endif
+
+//TODO use QFormLayout::setRowVisible
+#ifndef HAVE_RESIDFP_HEADER
+    m_ui->emulationLabel->setVisible(false);
+    m_ui->emuComboBox->setVisible(false);
+#endif
 
     m_ui->resamplingComboBox->addItem(u"Interpolate"_s, SidConfig::INTERPOLATE);
     m_ui->resamplingComboBox->addItem(u"Resample Interpolate"_s, SidConfig::RESAMPLE_INTERPOLATE);
-    i = m_ui->resamplingComboBox->findData(settings.value(u"resampling_method"_s, SidConfig::INTERPOLATE).toInt());
-    m_ui->resamplingComboBox->setCurrentIndex(i);
+    index = m_ui->resamplingComboBox->findData(settings.value(u"resampling_method"_s, SidConfig::INTERPOLATE).toInt());
+    m_ui->resamplingComboBox->setCurrentIndex(index);
 
     settings.endGroup();
 }
--- a/src/plugins/Input/sid/sidsettingsdialog.ui
+++ b/src/plugins/Input/sid/sidsettingsdialog.ui
@@ -6,14 +6,14 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>445</width>
-    <height>286</height>
+    <width>475</width>
+    <height>287</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>SID Plugin Settings</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
+  <layout class="QVBoxLayout" name="verticalLayout">
    <property name="leftMargin">
     <number>6</number>
    </property>
@@ -23,20 +23,102 @@
    <property name="bottomMargin">
     <number>6</number>
    </property>
-   <item row="2" column="1">
-    <widget class="QSpinBox" name="defaultLengthSpinBox">
-     <property name="minimum">
-      <number>5</number>
-     </property>
-     <property name="maximum">
-      <number>1000</number>
+   <item>
+    <layout class="QFormLayout" name="formLayout">
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>HVSC database file:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="hvscPathLineEdit">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Defaults song length, sec:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QSpinBox" name="defaultLengthSpinBox">
+       <property name="minimum">
+        <number>5</number>
+       </property>
+       <property name="maximum">
+        <number>1000</number>
+       </property>
+       <property name="value">
+        <number>180</number>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Sample rate:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QComboBox" name="sampleRateComboBox"/>
+     </item>
+     <item row="4" column="0">
+      <widget class="QLabel" name="emulationLabel">
+       <property name="text">
+        <string>Emulation:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QComboBox" name="emuComboBox"/>
+     </item>
+     <item row="5" column="0">
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>Resampling method:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="1">
+      <widget class="QComboBox" name="resamplingComboBox"/>
+     </item>
+     <item row="6" column="0" colspan="2">
+      <widget class="QCheckBox" name="fastResampligCheckBox">
+       <property name="text">
+        <string>Fast resampling</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="0" colspan="2">
+      <widget class="QCheckBox" name="useHVSCCheckBox">
+       <property name="text">
+        <string>Enable HVSC song length database</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
      </property>
-     <property name="value">
-      <number>180</number>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
      </property>
-    </widget>
+    </spacer>
    </item>
-   <item row="9" column="0" colspan="2">
+   <item>
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -49,71 +131,6 @@
      </property>
     </widget>
    </item>
-   <item row="8" column="0" colspan="2">
-    <widget class="QCheckBox" name="fastResampligCheckBox">
-     <property name="text">
-      <string>Fast resampling</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="label_2">
-     <property name="text">
-      <string>Sample rate:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0">
-    <widget class="QLabel" name="label_5">
-     <property name="text">
-      <string>HVSC database file:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="0">
-    <widget class="QLabel" name="label_4">
-     <property name="text">
-      <string>Resampling method:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="1">
-    <widget class="QComboBox" name="sampleRateComboBox"/>
-   </item>
-   <item row="1" column="1">
-    <widget class="QLineEdit" name="hvscPathLineEdit">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="label">
-     <property name="text">
-      <string>Defaults song length, sec:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="2">
-    <widget class="QCheckBox" name="useHVSCCheckBox">
-     <property name="text">
-      <string>Enable HVSC song length database</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="0">
-    <widget class="QLabel" name="label_3">
-     <property name="text">
-      <string>Emulation:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="1">
-    <widget class="QComboBox" name="emuComboBox"/>
-   </item>
-   <item row="6" column="1">
-    <widget class="QComboBox" name="resamplingComboBox"/>
-   </item>
   </layout>
  </widget>
  <resources/>