40 lines
872 B
C
Raw Normal View History

2019-10-26 01:51:40 +02:00
#pragma once
#include <cstdint>
#include <memory>
namespace tc {
namespace audio {
#ifdef WIN32
#pragma pack(push,1)
#define __attribute__packed_1
#else
#define __attribute__packed_1 __attribute__((packed, aligned(1)))
#endif
/* Every sample is a float (4byte) */
struct __attribute__packed_1 SampleBuffer {
static constexpr size_t HEAD_LENGTH = 4;
uint16_t sample_size;
uint16_t sample_index;
char sample_data[
#ifndef WIN32
0
#else
1 /* windows does not allow zero sized arrays */
#endif
];
static std::shared_ptr<SampleBuffer> allocate(uint8_t /* channels */, uint16_t /* samples */);
};
#ifndef WIN32
static_assert(sizeof(SampleBuffer) == 4, "Invalid SampleBuffer packaging!");
#else
#pragma pack(pop)
static_assert(sizeof(SampleBuffer) == 5, "Invalid SampleBuffer packaging!");
#endif
}
}