Started to work on nmux today

feature/nmux
ha7ilm 2017-01-10 10:34:42 +01:00
rodzic 11d639b7a3
commit 377faec68e
4 zmienionych plików z 16 dodań i 8 usunięć

Wyświetl plik

@ -44,7 +44,7 @@ PARAMS_MISC = -Wno-unused-result
FFTW_PACKAGE = fftw-3.3.3
.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
@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)

Wyświetl plik

@ -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.
*/
#include "tsmpool.h"
#include "nmux.h"
int host_port = 0;
char host_address[100] = "127.0.0.1";
@ -38,7 +38,7 @@ int thread_cntr = 0;
int bufsize = 1024; //! currently unused
int bufcnt = 1024;
char* global_argv;
char** global_argv;
int global_argc;
tsmpool* pool;
@ -150,8 +150,9 @@ int main(int argc, char* argv[])
unsigned char* current_write_buffer = pool->get_write_buffer();
int index_in_current_write_buffer = 0;
pthread_cond_t* wait_condition = new wait_condition;
pthread_cond_init(wait_condition, NULL);
pthread_cond_t* wait_condition = new pthread_cond_t;
if(!pthread_cond_init(wait_condition, NULL))
print_exit(MSG_START "pthread_cond_init failed"); //cond_attrs is ignored by Linux
for(;;)
{
@ -181,7 +182,6 @@ int main(int argc, char* argv[])
}
else
{
fprintf(stderr, MSG_START "pthread_create() failed.\n");
}
}

6
nmux.h
Wyświetl plik

@ -1,5 +1,9 @@
#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: "

Wyświetl plik

@ -3,6 +3,10 @@
//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).
#include <vector>
using namespace std;
typedef struct tsmthread_s
{
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);
int index_next(int index) { return (index+1==size)?0:index; }
int index_before(int index) { return (index-1<0)?size-1:index; }
}
};