mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
Ref T730, style
This commit is contained in:
committed by
Mat Sutcliffe
parent
cd58108bfe
commit
6a9109bf8f
@@ -9,8 +9,8 @@
|
||||
#include <qendian.h>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
// #include "utils.h"
|
||||
#include "wavfile.h"
|
||||
// #include "utils.h"
|
||||
|
||||
namespace BlackSound
|
||||
{
|
||||
@@ -50,29 +50,29 @@ namespace BlackSound
|
||||
WAVEHeader wave;
|
||||
};
|
||||
|
||||
WavFile::WavFile(QObject *parent) :
|
||||
CWavFile::CWavFile(QObject *parent) :
|
||||
QFile(parent),
|
||||
m_headerLength(0)
|
||||
{ }
|
||||
|
||||
bool WavFile::open(const QString &fileName)
|
||||
bool CWavFile::open(const QString &fileName)
|
||||
{
|
||||
close();
|
||||
setFileName(fileName);
|
||||
return QFile::open(QIODevice::ReadOnly) && readHeader();
|
||||
}
|
||||
|
||||
const QAudioFormat &WavFile::fileFormat() const
|
||||
const QAudioFormat &CWavFile::fileFormat() const
|
||||
{
|
||||
return m_fileFormat;
|
||||
}
|
||||
|
||||
qint64 WavFile::headerLength() const
|
||||
qint64 CWavFile::headerLength() const
|
||||
{
|
||||
return m_headerLength;
|
||||
}
|
||||
|
||||
bool WavFile::readHeader()
|
||||
bool CWavFile::readHeader()
|
||||
{
|
||||
seek(0);
|
||||
CombinedHeader header;
|
||||
@@ -132,15 +132,14 @@ namespace BlackSound
|
||||
|
||||
if (memcmp(&dataHeader.descriptor.id, "data", 4) == 0)
|
||||
{
|
||||
qint32 dataLength = qFromLittleEndian<qint32>(dataHeader.descriptor.size);
|
||||
const qint32 dataLength = qFromLittleEndian<qint32>(dataHeader.descriptor.size);
|
||||
m_audioData = read(dataLength);
|
||||
if (m_audioData.size() != dataLength)
|
||||
{
|
||||
return false;
|
||||
m_audioData.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -20,22 +20,30 @@ namespace BlackSound
|
||||
namespace Wav
|
||||
{
|
||||
//! * WAV file
|
||||
class WavFile : public QFile
|
||||
class CWavFile : public QFile
|
||||
{
|
||||
public:
|
||||
//! Ctor
|
||||
WavFile(QObject *parent = nullptr);
|
||||
CWavFile(QObject *parent = nullptr);
|
||||
|
||||
//! Standard open
|
||||
using QFile::open;
|
||||
|
||||
//! Open
|
||||
bool open(const QString &fileName);
|
||||
|
||||
//! Audio format
|
||||
const QAudioFormat &fileFormat() const;
|
||||
|
||||
//! Header length
|
||||
qint64 headerLength() const;
|
||||
QByteArray audioData() { return m_audioData; }
|
||||
|
||||
//! The audio data
|
||||
const QByteArray &audioData() const { return m_audioData; }
|
||||
|
||||
private:
|
||||
bool readHeader();
|
||||
|
||||
private:
|
||||
QAudioFormat m_fileFormat;
|
||||
qint64 m_headerLength;
|
||||
QByteArray m_audioData;
|
||||
|
||||
Reference in New Issue
Block a user