mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-10 04:37:37 +01:00
more progress on the network source
This commit is contained in:
parent
2b752bb267
commit
01ab1831e8
@ -35,6 +35,13 @@ enum SampleType {
|
|||||||
SAMPLE_TYPE_FLOAT32
|
SAMPLE_TYPE_FLOAT32
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const size_t SAMPLE_TYPE_SIZE[] {
|
||||||
|
sizeof(int8_t)*2,
|
||||||
|
sizeof(int16_t)*2,
|
||||||
|
sizeof(int32_t)*2,
|
||||||
|
sizeof(float)*2,
|
||||||
|
};
|
||||||
|
|
||||||
class NetworkSourceModule : public ModuleManager::Instance {
|
class NetworkSourceModule : public ModuleManager::Instance {
|
||||||
public:
|
public:
|
||||||
NetworkSourceModule(std::string name) {
|
NetworkSourceModule(std::string name) {
|
||||||
@ -237,40 +244,28 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void worker() {
|
void worker() {
|
||||||
int frameSize = samplerate / 200;
|
int blockSize = samplerate / 200;
|
||||||
switch (sampType) {
|
int frameSize = blockSize*SAMPLE_TYPE_SIZE[sampType];
|
||||||
case SAMPLE_TYPE_INT8:
|
uint8_t* buffer = dsp::buffer::alloc<uint8_t>(frameSize);
|
||||||
frameSize *= 2*sizeof(int8_t);;
|
|
||||||
break;
|
|
||||||
case SAMPLE_TYPE_INT16:
|
|
||||||
frameSize *= 2*sizeof(int16_t);
|
|
||||||
break;
|
|
||||||
case SAMPLE_TYPE_INT32:
|
|
||||||
frameSize *= 2*sizeof(int32_t);
|
|
||||||
break;
|
|
||||||
case SAMPLE_TYPE_FLOAT32:
|
|
||||||
frameSize *= sizeof(dsp::complex_t);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint8_t* buffer = dsp::buffer::alloc<uint8_t>(STREAM_BUFFER_SIZE*sizeof(uint32_t));
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Read samples from socket
|
// Read samples from socket
|
||||||
|
{
|
||||||
|
std::lock_guard lck(sockMtx);
|
||||||
int bytes = sock->recv(buffer, frameSize, true);
|
int bytes = sock->recv(buffer, frameSize, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to CF32
|
// Convert to CF32
|
||||||
int count;
|
int count;
|
||||||
switch (sampType) {
|
switch (sampType) {
|
||||||
case SAMPLE_TYPE_INT8:
|
case SAMPLE_TYPE_INT8:
|
||||||
frameSize *= 2*sizeof(int8_t);;
|
|
||||||
break;
|
break;
|
||||||
case SAMPLE_TYPE_INT16:
|
case SAMPLE_TYPE_INT16:
|
||||||
frameSize *= 2*sizeof(int16_t);
|
|
||||||
break;
|
break;
|
||||||
case SAMPLE_TYPE_INT32:
|
case SAMPLE_TYPE_INT32:
|
||||||
frameSize *= 2*sizeof(int32_t);
|
|
||||||
break;
|
break;
|
||||||
case SAMPLE_TYPE_FLOAT32:
|
case SAMPLE_TYPE_FLOAT32:
|
||||||
//memcpy(stream.writeBuf, buffer, )
|
//memcpy(stream.writeBuf, buffer, )
|
||||||
@ -280,7 +275,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send out converted samples
|
// Send out converted samples
|
||||||
//if (!stream.swap(bufferSize))
|
if (!stream.swap(count)) { break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
dsp::buffer::free(buffer);
|
dsp::buffer::free(buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user