Several minor improvements

* Improve CI testing
* Fix compilation warnings
* Bump up version
This commit is contained in:
Manolis Surligas 2018-01-19 22:20:19 +02:00
parent f8df9c2824
commit de05c3f1c4
11 changed files with 3182 additions and 2084 deletions

View File

@ -7,6 +7,14 @@ test:
script:
- mkdir -p build
- cd build
- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr ..
- make
- make install
- ldconfig
- python -c "import satnogs"
- rm -rf *
- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINCLUDE_DEBUG_BLOCKS=OFF -DCMAKE_INSTALL_PREFIX=/usr ..
- make
- make install
- ldconfig
- python -c "import satnogs"

View File

@ -48,7 +48,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 1)
set(VERSION_INFO_API_COMPAT 2)
set(VERSION_INFO_MINOR_VERSION 2)
set(VERSION_INFO_MINOR_VERSION 3)
set(VERSION_INFO_MAINT_VERSION git)
########################################################################

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
* Copyright (C) 2016,2018 Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,21 +24,25 @@
#include <satnogs/utils.h>
#include <satnogs/log.h>
#include <limits.h>
#include <stdint.h>
#include <string>
namespace gr
{
namespace satnogs
{
const size_t AX25_MIN_ADDR_LEN = 14;
const size_t AX25_MAX_ADDR_LEN = 28;
const size_t AX25_MIN_CTRL_LEN = 1;
const size_t AX25_MAX_CTRL_LEN = 2;
const size_t AX25_MIN_ADDR_LEN = 14;
const size_t AX25_MAX_ADDR_LEN = 28;
const size_t AX25_MIN_CTRL_LEN = 1;
const size_t AX25_MAX_CTRL_LEN = 2;
const size_t AX25_MAX_FRAME_LEN = 256;
const uint8_t AX25_SYNC_FLAG = 0x7E;
const uint8_t AX25_CALLSIGN_MAX_LEN = 6;
const float AX25_SYNC_FLAG_MAP[8] = {-1, 1, 1, 1, 1, 1, 1, -1};
const uint8_t AX25_SYNC_FLAG_MAP_BIN[8] = {0, 1, 1, 1, 1, 1, 1, 0};
const float AX25_SYNC_FLAG_MAP[8] =
{ -1, 1, 1, 1, 1, 1, 1, -1 };
const uint8_t AX25_SYNC_FLAG_MAP_BIN[8] =
{ 0, 1, 1, 1, 1, 1, 1, 0 };
/**
* AX.25 Frame types
*/
@ -52,14 +56,12 @@ namespace gr
typedef enum
{
AX25_ENC_FAIL,
AX25_ENC_OK
AX25_ENC_FAIL, AX25_ENC_OK
} ax25_encode_status_t;
typedef enum
{
AX25_DEC_FAIL,
AX25_DEC_OK
AX25_DEC_FAIL, AX25_DEC_OK
} ax25_decode_status_t;
typedef struct
@ -85,7 +87,7 @@ namespace gr
{
uint16_t fcs = 0xFFFF;
while (len--) {
fcs = (fcs >> 8) ^ crc16_ccitt_table_reverse[(fcs ^ *buffer++) & 0xFF];
fcs = (fcs >> 8) ^ crc16_ccitt_table_reverse[(fcs ^ *buffer++) & 0xFF];
}
return fcs ^ 0xFFFF;
}
@ -100,35 +102,35 @@ namespace gr
*/
static inline size_t
ax25_create_addr_field (uint8_t *out, std::string dest_addr,
uint8_t dest_ssid, std::string src_addr,
uint8_t src_ssid)
uint8_t dest_ssid, std::string src_addr,
uint8_t src_ssid)
{
size_t i;
for(i = 0; i < dest_addr.length(); i++) {
*out++ = dest_addr[i] << 1;
for (i = 0; i < dest_addr.length (); i++) {
*out++ = dest_addr[i] << 1;
}
/*
* Perhaps the destination callsign was smaller that the maximum allowed.
* In this case the leftover bytes should be filled with space
*/
for(; i < AX25_CALLSIGN_MAX_LEN; i++){
*out++ = ' ' << 1;
for (; i < AX25_CALLSIGN_MAX_LEN; i++) {
*out++ = ' ' << 1;
}
/* Apply SSID, reserved and C bit */
/* FIXME: C bit is set to 0 implicitly */
*out++ = ((0b1111 & dest_ssid) << 1) | 0b01100000;
for(i = 0; i < src_addr.length(); i++) {
*out++ = dest_addr[i] << 1;
for (i = 0; i < src_addr.length (); i++) {
*out++ = dest_addr[i] << 1;
}
for(; i < AX25_CALLSIGN_MAX_LEN; i++){
*out++ = ' ' << 1;
for (; i < AX25_CALLSIGN_MAX_LEN; i++) {
*out++ = ' ' << 1;
}
/* Apply SSID, reserved and C bit. As this is the last address field
* the trailing bit is set to 1.
* /
/* FIXME: C bit is set to 0 implicitly */
/* FIXME: C bit is set to 0 implicitly */
*out++ = ((0b1111 & dest_ssid) << 1) | 0b01100001;
return AX25_MIN_ADDR_LEN;
}
@ -139,7 +141,7 @@ namespace gr
* @return the destination SSID
*/
static inline uint8_t
ax25_get_dest_ssid(const uint8_t *in)
ax25_get_dest_ssid (const uint8_t *in)
{
uint8_t ret;
ret = in[AX25_CALLSIGN_MAX_LEN];
@ -148,34 +150,34 @@ namespace gr
static inline size_t
ax25_prepare_frame (uint8_t *out, const uint8_t *info, size_t info_len,
ax25_frame_type_t type, uint8_t *addr, size_t addr_len,
uint16_t ctrl, size_t ctrl_len, size_t preamble_len,
size_t postamble_len)
ax25_frame_type_t type, uint8_t *addr, size_t addr_len,
uint16_t ctrl, size_t ctrl_len, size_t preamble_len,
size_t postamble_len)
{
uint16_t fcs;
size_t i;
if(info_len > AX25_MAX_FRAME_LEN) {
return 0;
if (info_len > AX25_MAX_FRAME_LEN) {
return 0;
}
memset(out, AX25_SYNC_FLAG, preamble_len);
memset (out, AX25_SYNC_FLAG, preamble_len);
i = preamble_len;
/* Insert address and control fields */
if( addr_len == AX25_MIN_ADDR_LEN || addr_len == AX25_MAX_ADDR_LEN){
memcpy(out + i, addr, addr_len);
i += addr_len;
if (addr_len == AX25_MIN_ADDR_LEN || addr_len == AX25_MAX_ADDR_LEN) {
memcpy (out + i, addr, addr_len);
i += addr_len;
}
else{
return 0;
else {
return 0;
}
if( ctrl_len == AX25_MIN_CTRL_LEN || ctrl_len == AX25_MAX_CTRL_LEN){
memcpy(out + i, &ctrl, ctrl_len);
i += ctrl_len;
if (ctrl_len == AX25_MIN_CTRL_LEN || ctrl_len == AX25_MAX_CTRL_LEN) {
memcpy (out + i, &ctrl, ctrl_len);
i += ctrl_len;
}
else{
return 0;
else {
return 0;
}
/*
@ -184,17 +186,17 @@ namespace gr
* inserted
*/
if (type == AX25_I_FRAME || type == AX25_UI_FRAME) {
out[i++] = 0xF0;
out[i++] = 0xF0;
}
memcpy(out + i, info, info_len);
memcpy (out + i, info, info_len);
i += info_len;
/* Compute the FCS. Ignore the first flag byte */
fcs = ax25_fcs(out + preamble_len, i - preamble_len);
fcs = ax25_fcs (out + preamble_len, i - preamble_len);
/* The MS bits are sent first ONLY at the FCS field */
out[i++] = fcs & 0xFF;
out[i++] = (fcs >> 8) & 0xFF;
memset(out + i, AX25_SYNC_FLAG, postamble_len);
memset (out + i, AX25_SYNC_FLAG, postamble_len);
return i + postamble_len;
}
@ -215,12 +217,18 @@ namespace gr
*
* @param buffer_len the length of the input buffer.
*
* @param preamble_len the number of consecutive AX.25 flags that will
* be placed in the preamble. This preamble will be NOT bit-stuffed.
*
* @param postamble_len the number of consecutive AX.25 flags that will
* be placed in the postamble. This postamble will be NOT bit-stuffed.
*
* @return the resulting status of the encoding
*/
static inline ax25_encode_status_t
ax25_nrz_bit_stuffing (float *out, size_t *out_len, const uint8_t *buffer,
size_t buffer_len, size_t preamble_len,
size_t postamble_len)
size_t buffer_len, size_t preamble_len,
size_t postamble_len)
{
uint8_t bit;
uint8_t prev_bit = 0;
@ -231,44 +239,44 @@ namespace gr
size_t i;
/* Leading FLAG field does not need bit stuffing */
for(i = 0; i < preamble_len; i++) {
memcpy(out + out_idx, AX25_SYNC_FLAG_MAP, 8 * sizeof(float));
out_idx += 8;
for (i = 0; i < preamble_len; i++) {
memcpy (out + out_idx, AX25_SYNC_FLAG_MAP, 8 * sizeof(float));
out_idx += 8;
}
/* Skip the leading and trailing FLAG field */
buffer += preamble_len;
for(i = 0; i < 8 * (buffer_len - preamble_len - postamble_len); i++){
bit = (buffer[i / 8] >> ( i % 8)) & 0x1;
out[out_idx++] = bit ? 1.0 : -1.0;
for (i = 0; i < 8 * (buffer_len - preamble_len - postamble_len); i++) {
bit = (buffer[i / 8] >> (i % 8)) & 0x1;
out[out_idx++] = bit ? 1.0 : -1.0;
/* Check if bit stuffing should be applied */
if(bit & prev_bit){
cont_1++;
total_cont_1++;
if(cont_1 == 4){
out[out_idx++] = -1.0;
cont_1 = 0;
}
}
else{
cont_1 = total_cont_1 = 0;
}
prev_bit = bit;
/* Check if bit stuffing should be applied */
if (bit & prev_bit) {
cont_1++;
total_cont_1++;
if (cont_1 == 4) {
out[out_idx++] = -1.0;
cont_1 = 0;
}
}
else {
cont_1 = total_cont_1 = 0;
}
prev_bit = bit;
/*
* If the total number of continuous 1's is 15 the the frame should be
* dropped
*/
if(total_cont_1 >= 14) {
return AX25_ENC_FAIL;
}
/*
* If the total number of continuous 1's is 15 the the frame should be
* dropped
*/
if (total_cont_1 >= 14) {
return AX25_ENC_FAIL;
}
}
/* Trailing FLAG field does not need bit stuffing */
for(i = 0; i < postamble_len; i++) {
memcpy(out + out_idx, AX25_SYNC_FLAG_MAP, 8 * sizeof(float));
out_idx += 8;
for (i = 0; i < postamble_len; i++) {
memcpy (out + out_idx, AX25_SYNC_FLAG_MAP, 8 * sizeof(float));
out_idx += 8;
}
*out_len = out_idx;
@ -291,12 +299,18 @@ namespace gr
*
* @param buffer_len the length of the input buffer.
*
* @param preamble_len the number of consecutive AX.25 flags that will
* be placed in the preamble. This preamble will be NOT bit-stuffed.
*
* @param postamble_len the number of consecutive AX.25 flags that will
* be placed in the postamble. This postamble will be NOT bit-stuffed.
*
* @return the resulting status of the encoding
*/
static inline ax25_encode_status_t
ax25_bit_stuffing (uint8_t *out, size_t *out_len, const uint8_t *buffer,
const size_t buffer_len, size_t preamble_len,
size_t postamble_len)
const size_t buffer_len, size_t preamble_len,
size_t postamble_len)
{
uint8_t bit;
uint8_t shift_reg = 0x0;
@ -305,29 +319,29 @@ namespace gr
size_t i;
/* Leading FLAG field does not need bit stuffing */
for(i = 0; i < preamble_len; i++) {
memcpy(out + out_idx, AX25_SYNC_FLAG_MAP_BIN, 8 * sizeof(uint8_t));
out_idx += 8;
for (i = 0; i < preamble_len; i++) {
memcpy (out + out_idx, AX25_SYNC_FLAG_MAP_BIN, 8 * sizeof(uint8_t));
out_idx += 8;
}
/* Skip the leading and trailing FLAG field */
buffer += preamble_len;
for(i = 0; i < 8 * (buffer_len - preamble_len - postamble_len); i++){
bit = (buffer[i / 8] >> ( i % 8)) & 0x1;
shift_reg = (shift_reg << 1) | bit;
out[out_idx++] = bit;
for (i = 0; i < 8 * (buffer_len - preamble_len - postamble_len); i++) {
bit = (buffer[i / 8] >> (i % 8)) & 0x1;
shift_reg = (shift_reg << 1) | bit;
out[out_idx++] = bit;
/* Check if bit stuffing should be applied */
if( (shift_reg & 0x1F) == 0x1F){
out[out_idx++] = 0x0;
shift_reg = 0x0;
}
/* Check if bit stuffing should be applied */
if ((shift_reg & 0x1F) == 0x1F) {
out[out_idx++] = 0x0;
shift_reg = 0x0;
}
}
/* Trailing FLAG field does not need bit stuffing */
for(i = 0; i < postamble_len; i++) {
memcpy(out + out_idx, AX25_SYNC_FLAG_MAP_BIN, 8 * sizeof(uint8_t));
out_idx += 8;
for (i = 0; i < postamble_len; i++) {
memcpy (out + out_idx, AX25_SYNC_FLAG_MAP_BIN, 8 * sizeof(uint8_t));
out_idx += 8;
}
*out_len = out_idx;
@ -335,8 +349,8 @@ namespace gr
}
static inline ax25_decode_status_t
ax25_decode (uint8_t *out, size_t *out_len,
const uint8_t *ax25_frame, size_t len)
ax25_decode (uint8_t *out, size_t *out_len, const uint8_t *ax25_frame,
size_t len)
{
size_t i;
size_t frame_start = UINT_MAX;
@ -349,82 +363,81 @@ namespace gr
uint16_t fcs;
uint16_t recv_fcs;
/* Start searching for the SYNC flag */
for(i = 0; i < len - sizeof(AX25_SYNC_FLAG_MAP_BIN); i++) {
res = (AX25_SYNC_FLAG_MAP_BIN[0] ^ ax25_frame[i]) |
(AX25_SYNC_FLAG_MAP_BIN[1] ^ ax25_frame[i + 1]) |
(AX25_SYNC_FLAG_MAP_BIN[2] ^ ax25_frame[i + 2]) |
(AX25_SYNC_FLAG_MAP_BIN[3] ^ ax25_frame[i + 3]) |
(AX25_SYNC_FLAG_MAP_BIN[4] ^ ax25_frame[i + 4]) |
(AX25_SYNC_FLAG_MAP_BIN[5] ^ ax25_frame[i + 5]) |
(AX25_SYNC_FLAG_MAP_BIN[6] ^ ax25_frame[i + 6]) |
(AX25_SYNC_FLAG_MAP_BIN[7] ^ ax25_frame[i + 7]);
/* Found it! */
if(res == 0){
frame_start = i;
break;
}
for (i = 0; i < len - sizeof(AX25_SYNC_FLAG_MAP_BIN); i++) {
res = (AX25_SYNC_FLAG_MAP_BIN[0] ^ ax25_frame[i])
| (AX25_SYNC_FLAG_MAP_BIN[1] ^ ax25_frame[i + 1])
| (AX25_SYNC_FLAG_MAP_BIN[2] ^ ax25_frame[i + 2])
| (AX25_SYNC_FLAG_MAP_BIN[3] ^ ax25_frame[i + 3])
| (AX25_SYNC_FLAG_MAP_BIN[4] ^ ax25_frame[i + 4])
| (AX25_SYNC_FLAG_MAP_BIN[5] ^ ax25_frame[i + 5])
| (AX25_SYNC_FLAG_MAP_BIN[6] ^ ax25_frame[i + 6])
| (AX25_SYNC_FLAG_MAP_BIN[7] ^ ax25_frame[i + 7]);
/* Found it! */
if (res == 0) {
frame_start = i;
break;
}
}
/* We failed to find the SYNC flag */
if(frame_start == UINT_MAX){
return AX25_DEC_FAIL;
if (frame_start == UINT_MAX) {
return AX25_DEC_FAIL;
}
for(i = frame_start + sizeof(AX25_SYNC_FLAG_MAP_BIN);
i < len - sizeof(AX25_SYNC_FLAG_MAP_BIN) + 1; i++) {
/* Check if we reached the frame end */
res = (AX25_SYNC_FLAG_MAP_BIN[0] ^ ax25_frame[i]) |
(AX25_SYNC_FLAG_MAP_BIN[1] ^ ax25_frame[i + 1]) |
(AX25_SYNC_FLAG_MAP_BIN[2] ^ ax25_frame[i + 2]) |
(AX25_SYNC_FLAG_MAP_BIN[3] ^ ax25_frame[i + 3]) |
(AX25_SYNC_FLAG_MAP_BIN[4] ^ ax25_frame[i + 4]) |
(AX25_SYNC_FLAG_MAP_BIN[5] ^ ax25_frame[i + 5]) |
(AX25_SYNC_FLAG_MAP_BIN[6] ^ ax25_frame[i + 6]) |
(AX25_SYNC_FLAG_MAP_BIN[7] ^ ax25_frame[i + 7]);
/* Found it! */
if(res == 0){
frame_stop = i;
break;
}
for (i = frame_start + sizeof(AX25_SYNC_FLAG_MAP_BIN);
i < len - sizeof(AX25_SYNC_FLAG_MAP_BIN) + 1; i++) {
/* Check if we reached the frame end */
res = (AX25_SYNC_FLAG_MAP_BIN[0] ^ ax25_frame[i])
| (AX25_SYNC_FLAG_MAP_BIN[1] ^ ax25_frame[i + 1])
| (AX25_SYNC_FLAG_MAP_BIN[2] ^ ax25_frame[i + 2])
| (AX25_SYNC_FLAG_MAP_BIN[3] ^ ax25_frame[i + 3])
| (AX25_SYNC_FLAG_MAP_BIN[4] ^ ax25_frame[i + 4])
| (AX25_SYNC_FLAG_MAP_BIN[5] ^ ax25_frame[i + 5])
| (AX25_SYNC_FLAG_MAP_BIN[6] ^ ax25_frame[i + 6])
| (AX25_SYNC_FLAG_MAP_BIN[7] ^ ax25_frame[i + 7]);
/* Found it! */
if (res == 0) {
frame_stop = i;
break;
}
if (ax25_frame[i]) {
cont_1++;
decoded_byte |= 1 << bit_cnt;
bit_cnt++;
}
else {
/* If 5 consecutive 1's drop the extra zero*/
if (cont_1 >= 5) {
cont_1 = 0;
}
else{
bit_cnt++;
cont_1 = 0;
}
}
if (ax25_frame[i]) {
cont_1++;
decoded_byte |= 1 << bit_cnt;
bit_cnt++;
}
else {
/* If 5 consecutive 1's drop the extra zero*/
if (cont_1 >= 5) {
cont_1 = 0;
}
else {
bit_cnt++;
cont_1 = 0;
}
}
/* Fill the fully constructed byte */
if(bit_cnt == 8){
out[received_bytes++] = decoded_byte;
bit_cnt = 0;
decoded_byte = 0x0;
}
/* Fill the fully constructed byte */
if (bit_cnt == 8) {
out[received_bytes++] = decoded_byte;
bit_cnt = 0;
decoded_byte = 0x0;
}
}
if(frame_stop == UINT_MAX || received_bytes < AX25_MIN_ADDR_LEN){
return AX25_DEC_FAIL;
if (frame_stop == UINT_MAX || received_bytes < AX25_MIN_ADDR_LEN) {
return AX25_DEC_FAIL;
}
/* Now check the CRC */
fcs = ax25_fcs (out, received_bytes - sizeof(uint16_t));
recv_fcs = (((uint16_t) out[received_bytes - 2]) << 8)
| out[received_bytes - 1];
| out[received_bytes - 1];
if(fcs != recv_fcs) {
LOG_WARN("AX.25 CRC-16 failed");
return AX25_DEC_FAIL;
if (fcs != recv_fcs) {
LOG_WARN("AX.25 CRC-16 failed");
return AX25_DEC_FAIL;
}
*out_len = received_bytes - sizeof(uint16_t);
@ -436,6 +449,4 @@ namespace gr
} // namespace gr
#endif /* INCLUDE_SATNOGS_AX25_H_ */

View File

@ -44,14 +44,14 @@ namespace gr
/*!
*
* @param filename the OGG audio file path
* @param number of channels of the OGG stream. If the actual OGG stream
* contains a different number of channels than specified an exception
* is raised
* @param channels number of channels of the OGG stream.
* If the actual OGG stream contains a different number of channels
* than specified an exception is raised
* @param repeat if set to true, when EOF is reached the block
* will continue to output samples from the beginning of the OGG file.
*/
static sptr
make (const std::string& filename, size_t channels = 1,
make (const std::string& filename, int channels = 1,
bool repeat = false);
};

View File

@ -47,12 +47,12 @@ namespace gr
*
* @param addr the address of the interface to listen at
* @param port the TCP port to listen or connect
* @param serve_mode If set to yes this block, act as a rigctl server.
* @param server_mode If set to yes this block, act as a rigctl server.
* Otherwise as a rigctl client
* @param interval_ms The interval in milliseconds at which the client
* request the frequency from the rigctl
* @param mtu the maximum MTU
* @return
* @return shared pointer of the block
*/
static sptr
make (const std::string& addr, uint16_t port, bool server_mode,

View File

@ -77,20 +77,19 @@ namespace gr
* delivered at the sink block out-of-sync causing the frame transmission
* to terminate sooner.
*
* @param ax25_dest_addr the destination AX.25 address
* @param ax25_dest_ssid the destination AX.25 SSID
* @param ax25_src_addr the source AX.25 address
* @param ax25_src_ssid the source AX.25 SSID
*
*/
static sptr
make (const std::vector<uint8_t>& preamble,
const std::vector<uint8_t>& sync_word,
bool append_crc,
bool whitening,
bool manchester,
bool msb_first,
bool ax25_format,
const std::string& ax25_dest_addr,
uint8_t ax25_dest_ssid,
const std::string& ax25_src_addr,
uint8_t ax25_src_ssid,
size_t settling_samples);
const std::vector<uint8_t>& sync_word, bool append_crc,
bool whitening, bool manchester, bool msb_first, bool ax25_format,
const std::string& ax25_dest_addr, uint8_t ax25_dest_ssid,
const std::string& ax25_src_addr, uint8_t ax25_src_ssid,
size_t settling_samples);
};
} // namespace satnogs

View File

@ -126,7 +126,7 @@ namespace gr
void
noaa_apt_sink_impl::write_image (png::image<png::gray_pixel> image,
std::string filename)
std::string filename)
{
// In case the flip option is set
if(d_flip) {

View File

@ -36,7 +36,7 @@ namespace gr {
namespace satnogs {
ogg_source::sptr
ogg_source::make (const std::string& filename, size_t channels, bool repeat)
ogg_source::make (const std::string& filename, int channels, bool repeat)
{
return gnuradio::get_initial_sptr (
new ogg_source_impl (filename, channels, repeat));
@ -46,7 +46,7 @@ namespace gr {
* The private constructor
*/
ogg_source_impl::ogg_source_impl (const std::string& filename,
size_t channels, bool repeat) :
int channels, bool repeat) :
gr::sync_block (
"ogg_source", gr::io_signature::make (0, 0, 0),
gr::io_signature::make (channels, channels, sizeof(float))),
@ -102,12 +102,13 @@ namespace gr {
long int ret;
int section = 0;
int available = (noutput_items / d_channels);
int available_samples = 0;
int produced = 0;
ret = ov_read (&d_ogvorb_f, (char *)d_in_buffer,
available * sizeof(int16_t),
0, sizeof(int16_t), 1, &section);
if(ret < sizeof(int16_t)) {
if(ret <= 0) {
/*
* If return value is EOF and the repeat mode is set seek back to the
* start of the ogg stream
@ -122,12 +123,13 @@ namespace gr {
return WORK_DONE;
}
available_samples = ret / sizeof(int16_t);
/* Convert to float the signed-short audio samples */
volk_16i_s32f_convert_32f (d_out_buffer, d_in_buffer, 2 << 15,
ret / sizeof(int16_t));
available_samples);
/* De-interleave the available channels */
for(int i = 0; i < ret / sizeof(int16_t); i += d_channels, produced++) {
for(int i = 0; i < available_samples; i += d_channels, produced++) {
for(int chan = 0; chan < d_channels; chan++){
((float *)output_items[chan])[produced] = d_out_buffer[i * d_channels + chan];
}

View File

@ -33,7 +33,7 @@ namespace gr
class ogg_source_impl : public ogg_source
{
private:
const size_t d_channels;
const int d_channels;
const bool d_repeat;
OggVorbis_File d_ogvorb_f;
@ -41,7 +41,7 @@ namespace gr
float *d_out_buffer;
public:
ogg_source_impl (const std::string& filename, size_t channels,
ogg_source_impl (const std::string& filename, int channels,
bool repeat);
~ogg_source_impl ();