1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 07:41:46 -05:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Edouard Griffiths
0a94970a70
Merge pull request #2328 from srcejon/freq_scanner
DemodAnalyzer: Ensure sample rate is set in worker.
2024-11-12 23:16:04 +01:00
srcejon
875f16f12a Wav Files: Add support for meta-data. 2024-11-12 20:36:33 +00:00
srcejon
c4733a3645 DemodAnalyzer: Ensure sample rate is set in worker. Fixes #2309. 2024-11-12 20:36:10 +00:00
Edouard Griffiths
585841e787
Merge pull request #2327 from srcejon/fix_2322
SDRplayv3: Patch path to libsdrplay_api.so.3
2024-11-12 21:16:46 +01:00
Edouard Griffiths
bba9d0b421
Merge pull request #2326 from srcejon/fix_1734
ADS-B: Fix memory use after delete.
2024-11-12 20:23:35 +01:00
Jon Beniston
600e338bab SDRplayv3: Mac now appears to link with libsdrplay_api.so.3 rather than libsdrplay_api.so.3.15. 2024-11-12 15:38:34 +00:00
srcejon
f03499a9a3 ADS-B: Fix memory use after delete. For #1734 and part of #2315 2024-11-12 12:39:14 +00:00
7 changed files with 151 additions and 2 deletions

View File

@ -105,8 +105,8 @@ ADSBDemod::~ADSBDemod()
delete m_networkManager;
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this);
delete m_basebandSink; // This results in a call to ADSBDemod::stop(), so need to delete before worker and thread
delete m_worker;
delete m_basebandSink;
delete m_thread;
}

View File

@ -5113,6 +5113,7 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
ADSBDemodGUI::~ADSBDemodGUI()
{
m_adsbDemod->setMessageQueueToGUI(nullptr);
disconnect(&MainCore::instance()->getSettings(), &MainSettings::preferenceChanged, this, &ADSBDemodGUI::preferenceChanged);
if (m_templateServer)
{

View File

@ -131,6 +131,7 @@ void DemodAnalyzer::start()
DemodAnalyzerWorker::MsgConfigureDemodAnalyzerWorker *msg
= DemodAnalyzerWorker::MsgConfigureDemodAnalyzerWorker::create(m_settings, QList<QString>(), true);
m_worker->getInputMessageQueue()->push(msg);
m_worker->applySampleRate(m_sampleRate);
if (m_dataPipe)
{

View File

@ -29,6 +29,7 @@ MESSAGE_CLASS_DEFINITION(DemodAnalyzerWorker::MsgConnectFifo, Message)
DemodAnalyzerWorker::DemodAnalyzerWorker() :
m_dataFifo(nullptr),
m_sinkSampleRate(0),
m_msgQueueToFeature(nullptr),
m_sampleBufferSize(0),
m_wavFileRecord(nullptr),

View File

@ -67,6 +67,9 @@ if (APPLE AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm64))
add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change libsdrplay_api.so.3.15 /usr/local/lib/libsdrplay_api.so.3.15 $<TARGET_FILE:${TARGET_NAME}>)
add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change libsdrplay_api.so.3 /usr/local/lib/libsdrplay_api.so.3 $<TARGET_FILE:${TARGET_NAME}>)
endif()
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})

View File

@ -204,6 +204,126 @@ bool WavFileRecord::startRecording()
return true;
}
void addString(QByteArray& buffer, const QString& type, const QString text)
{
buffer.append(type.toUtf8(), 4);
QByteArray s = text.toUtf8();
s.append('\0'); // Strings should be null terminated
if (s.size() & 1) {
s.append('\0');
}
quint16 textSize = s.size();
buffer.append(textSize & 0xff);
buffer.append((textSize >> 8) & 0xff);
buffer.append((textSize >> 16) & 0xff);
buffer.append((textSize >> 24) & 0xff);
buffer.append(s, textSize);
}
void addTag(QByteArray& buffer, const QString& id, const QString text)
{
buffer.append(id.toUtf8(), 4);
QByteArray s = text.toUtf8();
int size = s.size() + 1;
buffer.append((size >> 24) & 0xff); // MSB first
buffer.append((size >> 16) & 0xff);
buffer.append((size >> 8) & 0xff);
buffer.append(size & 0xff);
buffer.append((char)0); // flags
buffer.append((char)0); // flags
buffer.append((char)0); // text encoding (0 ISO-8859-1, 1 Unicode)
buffer.append(s);
}
void WavFileRecord::setMetaData(const QString& trackTitle, const QString& album, const QString& artist)
{
m_trackTitle = trackTitle;
m_album = album;
m_artist = artist;
}
bool WavFileRecord::hasMetaData() const
{
return !m_trackTitle.isEmpty() || !m_album.isEmpty() || !m_artist.isEmpty();
}
void WavFileRecord::writeInfoList()
{
QByteArray meta;
meta.append("INFO", 4);
if (!m_trackTitle.isEmpty()) {
addString(meta, "INAM", m_trackTitle);
}
if (!m_album.isEmpty()) {
addString(meta, "IPRD", m_album);
}
if (!m_artist.isEmpty()) {
addString(meta, "IART", m_artist);
}
struct Chunk list;
list.m_id[0] = 'L';
list.m_id[1] = 'I';
list.m_id[2] = 'S';
list.m_id[3] = 'T';
list.m_size = meta.size();
m_sampleFile.write((char*)&list, sizeof(Chunk));
m_sampleFile.write((char*)meta.data(), meta.size());
}
// ID3 v2.3
// https://mutagen-specs.readthedocs.io/en/latest/id3/id3v2.3.0.html
void WavFileRecord::writeID3()
{
QByteArray meta;
QByteArray textInfo;
if (!m_artist.isEmpty()) {
addTag(textInfo, "TPE1", m_artist);
}
if (!m_trackTitle.isEmpty()) {
addTag(textInfo, "TIT2", m_trackTitle);
}
if (!m_album.isEmpty()) {
addTag(textInfo, "TALB", m_album);
}
meta.append("ID3", 3);
meta.append((char)3); // .3 version
meta.append((char)0); // revision
meta.append((char)0); // flags
int textInfoSize = textInfo.size();
meta.append((textInfoSize >> 24) & 0xff); // MSB first
meta.append((textInfoSize >> 16) & 0xff);
meta.append((textInfoSize >> 8) & 0xff);
meta.append(textInfoSize & 0xff);
meta.append(textInfo);
if (meta.size() & 1) {
meta.append((char)0);
}
struct Chunk id3;
id3.m_id[0] = 'i';
id3.m_id[1] = 'd';
id3.m_id[2] = '3';
id3.m_id[3] = ' ';
id3.m_size = meta.size();
m_sampleFile.write((char*)&id3, sizeof(Chunk));
m_sampleFile.write((char*)meta.data(), meta.size());
}
bool WavFileRecord::stopRecording()
{
#ifdef ANDROID
@ -213,6 +333,20 @@ bool WavFileRecord::stopRecording()
#endif
{
qDebug() << "WavFileRecord::stopRecording";
#ifdef ANDROID
long dataSize = (long)m_sampleFile.size();
#else
long dataSize = m_sampleFile.tellp();
#endif
// Write meta data
if (hasMetaData())
{
writeInfoList();
writeID3();
}
// Fix up chunk sizes
#ifdef ANDROID
long fileSize = (long)m_sampleFile.size();
@ -228,7 +362,7 @@ bool WavFileRecord::stopRecording()
#else
m_sampleFile.seekp(offsetof(Header, m_dataHeader.m_size));
#endif
size = fileSize - sizeof(Header);
size = dataSize - sizeof(Header);
m_sampleFile.write((char *)&size, 4);
m_sampleFile.close();
m_recordOn = false;

View File

@ -114,6 +114,9 @@ public:
virtual bool stopRecording() override;
virtual bool isRecording() const override { return m_recordOn; }
void setMetaData(const QString& trackTitle="", const QString& album="", const QString& artist="");
bool hasMetaData() const;
static bool readHeader(std::ifstream& samplefile, Header& header, bool check=true);
static bool readHeader(QFile& samplefile, Header& header);
static void writeHeader(std::ofstream& samplefile, Header& header);
@ -140,7 +143,13 @@ private:
qint64 m_msShift;
int m_nbChannels;
QString m_trackTitle;
QString m_album;
QString m_artist;
void writeHeader();
void writeInfoList();
void writeID3();
static bool checkHeader(Header& header);
};