- work to improve the decoding process - many problems fixes + however there are problems yet
This commit is contained in:
@@ -11,7 +11,7 @@ using namespace Audio;
|
||||
DataWindow::DataWindow()
|
||||
{
|
||||
mFilled = 0;
|
||||
mData = NULL;
|
||||
mData = nullptr;
|
||||
mCapacity = 0;
|
||||
}
|
||||
|
||||
@@ -166,6 +166,25 @@ void DataWindow::zero(int length)
|
||||
memset(mData, 0, mFilled);
|
||||
}
|
||||
|
||||
size_t DataWindow::moveTo(DataWindow& dst, size_t size)
|
||||
{
|
||||
Lock l(mMutex);
|
||||
|
||||
size_t avail = std::min(size, (size_t)filled());
|
||||
if (avail != 0)
|
||||
{
|
||||
dst.add(mData, avail);
|
||||
erase(avail);
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds DataWindow::getTimeLength(int samplerate, int channels) const
|
||||
{
|
||||
Lock l(mMutex);
|
||||
return std::chrono::milliseconds(mFilled / sizeof(short) / channels / (samplerate / 1000));
|
||||
}
|
||||
|
||||
void DataWindow::makeStereoFromMono(DataWindow& dst, DataWindow& src)
|
||||
{
|
||||
Lock lockDst(dst.mMutex), lockSrc(src.mMutex);
|
||||
|
||||
@@ -11,37 +11,40 @@
|
||||
|
||||
namespace Audio
|
||||
{
|
||||
class DataWindow
|
||||
{
|
||||
public:
|
||||
class DataWindow
|
||||
{
|
||||
public:
|
||||
DataWindow();
|
||||
~DataWindow();
|
||||
|
||||
void setCapacity(int capacity);
|
||||
int capacity() const;
|
||||
void setCapacity(int capacity);
|
||||
int capacity() const;
|
||||
|
||||
void addZero(int length);
|
||||
void add(const void* data, int length);
|
||||
void add(short sample);
|
||||
int read(void* buffer, int length);
|
||||
void erase(int length = -1);
|
||||
void addZero(int length);
|
||||
void add(const void* data, int length);
|
||||
void add(short sample);
|
||||
int read(void* buffer, int length);
|
||||
void erase(int length = -1);
|
||||
const char* data() const;
|
||||
char* mutableData();
|
||||
int filled() const;
|
||||
void setFilled(int filled);
|
||||
void clear();
|
||||
char* mutableData();
|
||||
int filled() const;
|
||||
void setFilled(int filled);
|
||||
void clear();
|
||||
|
||||
short shortAt(int index) const;
|
||||
void setShortAt(short value, int index);
|
||||
void zero(int length);
|
||||
short shortAt(int index) const;
|
||||
void setShortAt(short value, int index);
|
||||
void zero(int length);
|
||||
size_t moveTo(DataWindow& dst, size_t size);
|
||||
|
||||
std::chrono::milliseconds getTimeLength(int samplerate, int channels) const;
|
||||
|
||||
static void makeStereoFromMono(DataWindow& dst, DataWindow& src);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
mutable Mutex mMutex;
|
||||
char* mData;
|
||||
int mFilled;
|
||||
int mCapacity;
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -51,6 +51,11 @@ struct Format
|
||||
return float((milliseconds * mRate) / 500.0 * mChannels);
|
||||
}
|
||||
|
||||
size_t sizeFromTime(std::chrono::milliseconds ms) const
|
||||
{
|
||||
return sizeFromTime(ms.count());
|
||||
}
|
||||
|
||||
std::string toString()
|
||||
{
|
||||
char buffer[64];
|
||||
|
||||
Reference in New Issue
Block a user