Started to work on nmux today
This commit is contained in:
parent
11d639b7a3
commit
377faec68e
4 changed files with 16 additions and 8 deletions
2
Makefile
2
Makefile
|
@ -44,7 +44,7 @@ PARAMS_MISC = -Wno-unused-result
|
||||||
FFTW_PACKAGE = fftw-3.3.3
|
FFTW_PACKAGE = fftw-3.3.3
|
||||||
|
|
||||||
.PHONY: clean-vect clean
|
.PHONY: clean-vect clean
|
||||||
all: csdr ddcd
|
all: csdr nmux
|
||||||
libcsdr.so: fft_fftw.c fft_rpi.c libcsdr_wrapper.c libcsdr.c libcsdr_gpl.c fastddc.c fastddc.h fft_fftw.h fft_rpi.h ima_adpcm.h libcsdr_gpl.h libcsdr.h predefined.h
|
libcsdr.so: fft_fftw.c fft_rpi.c libcsdr_wrapper.c libcsdr.c libcsdr_gpl.c fastddc.c fastddc.h fft_fftw.h fft_rpi.h ima_adpcm.h libcsdr_gpl.h libcsdr.h predefined.h
|
||||||
@echo NOTE: you may have to manually edit Makefile to optimize for your CPU \(especially if you compile on ARM, please edit PARAMS_NEON\).
|
@echo NOTE: you may have to manually edit Makefile to optimize for your CPU \(especially if you compile on ARM, please edit PARAMS_NEON\).
|
||||||
@echo Auto-detected optimization parameters: $(PARAMS_SIMD)
|
@echo Auto-detected optimization parameters: $(PARAMS_SIMD)
|
||||||
|
|
10
nmux.cpp
10
nmux.cpp
|
@ -28,7 +28,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tsmpool.h"
|
#include "nmux.h"
|
||||||
|
|
||||||
int host_port = 0;
|
int host_port = 0;
|
||||||
char host_address[100] = "127.0.0.1";
|
char host_address[100] = "127.0.0.1";
|
||||||
|
@ -38,7 +38,7 @@ int thread_cntr = 0;
|
||||||
int bufsize = 1024; //! currently unused
|
int bufsize = 1024; //! currently unused
|
||||||
int bufcnt = 1024;
|
int bufcnt = 1024;
|
||||||
|
|
||||||
char* global_argv;
|
char** global_argv;
|
||||||
int global_argc;
|
int global_argc;
|
||||||
tsmpool* pool;
|
tsmpool* pool;
|
||||||
|
|
||||||
|
@ -150,8 +150,9 @@ int main(int argc, char* argv[])
|
||||||
unsigned char* current_write_buffer = pool->get_write_buffer();
|
unsigned char* current_write_buffer = pool->get_write_buffer();
|
||||||
int index_in_current_write_buffer = 0;
|
int index_in_current_write_buffer = 0;
|
||||||
|
|
||||||
pthread_cond_t* wait_condition = new wait_condition;
|
pthread_cond_t* wait_condition = new pthread_cond_t;
|
||||||
pthread_cond_init(wait_condition, NULL);
|
if(!pthread_cond_init(wait_condition, NULL))
|
||||||
|
print_exit(MSG_START "pthread_cond_init failed"); //cond_attrs is ignored by Linux
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -181,7 +182,6 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, MSG_START "pthread_create() failed.\n");
|
fprintf(stderr, MSG_START "pthread_create() failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
nmux.h
6
nmux.h
|
@ -1,5 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <socket.h>
|
#include <stdlib.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include "tsmpool.h"
|
||||||
|
|
||||||
#define MSG_START "nmux: "
|
#define MSG_START "nmux: "
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
//It implements a big circular buffer that one thread writes into, and multiple threads read from.
|
//It implements a big circular buffer that one thread writes into, and multiple threads read from.
|
||||||
//The reader threads have lower priority than the writer thread (they can be left behind if the don't read fast enough).
|
//The reader threads have lower priority than the writer thread (they can be left behind if the don't read fast enough).
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
typedef struct tsmthread_s
|
typedef struct tsmthread_s
|
||||||
{
|
{
|
||||||
int read_index; //it always points to the next buffer to be read
|
int read_index; //it always points to the next buffer to be read
|
||||||
|
@ -31,4 +35,4 @@ public:
|
||||||
void* get_read_buffer(tsmthread_t* thread);
|
void* get_read_buffer(tsmthread_t* thread);
|
||||||
int index_next(int index) { return (index+1==size)?0:index; }
|
int index_next(int index) { return (index+1==size)?0:index; }
|
||||||
int index_before(int index) { return (index-1<0)?size-1:index; }
|
int index_before(int index) { return (index-1<0)?size-1:index; }
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in a new issue