Skip to content

Commit

Permalink
sync window
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Oct 25, 2024
1 parent 2f0a8cb commit 3bff44c
Show file tree
Hide file tree
Showing 43 changed files with 636 additions and 263 deletions.
Binary file modified FileWriter.o
Binary file not shown.
Binary file modified LockFreeQueue.o
Binary file not shown.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#~ GTKMM=`pkg-config --cflags --libs gtkmm-4.0`

TARGET=linux
TARGET=win32
#TARGET=win32

VERSION=`git rev-list --count HEAD`

Expand Down Expand Up @@ -37,13 +37,13 @@ all: amprack
amprack: version.o FileWriter.o main.o rack.o presets.o SharedLibrary.o engine.o jack.o process.o util.o snd.o knob.o
$(CPP) *.o -o amprack $(GTK) $(LV2) $(JACK) $(OPTIMIZE) $(SNDFILE) $(OPUS) $(LAME) $(DLFCN)

main.o: main.cc main.h rack.o presets.o log.o
main.o: main.cc main.h rack.o presets.o log.o sync.o
$(CPP) main.cc -c $(GTK) $(LV2) $(OPTIMIZE) -Wno-deprecated-declarations

log.o: log.c log.h
$(CC) log.c -c $(GTK)

rack.o: rack.cc rack.h settings.o knob.o pluginui.o
rack.o: rack.cc rack.h settings.o knob.o pluginui.o
$(CPP) rack.cc -c $(GTK) $(LV2) $(OPTIMIZE)

settings.o: settings.cc settings.h
Expand Down Expand Up @@ -103,3 +103,6 @@ vringbuffer.o: upwaker.c vringbuffer.cc

win32-release:
export VER=$(VERSION) ; cd .. ; zip -r releases/amprack-$$VER.zip win/

sync.o: sync.cc sync.h
$(CPP) -c sync.cc $(GTK)
Binary file modified Plugin.o
Binary file not shown.
Binary file modified PluginControl.o
Binary file not shown.
Binary file modified SharedLibrary.o
Binary file not shown.
Binary file added amprack
Binary file not shown.
Binary file added amprack-setup.exe
Binary file not shown.
Binary file modified amprack.exe
Binary file not shown.
Binary file modified cairo.o
Binary file not shown.
130 changes: 130 additions & 0 deletions client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#include "client.h"

Client::Client(string host, int port) {
// setup variables
host_ = host;
port_ = port;
buflen_ = 1024;
buf_ = new char[buflen_+1];
}

Client::~Client() {
}

void Client::run() {
// connect to the server and run echo program
create();
echo();
}

void
Client::create() {
struct sockaddr_in server_addr;

// use DNS to get IP address
struct hostent *hostEntry;
hostEntry = gethostbyname(host_.c_str());
if (!hostEntry) {
cout << "No such host name: " << host_ << endl;
exit(-1);
}

// setup socket address structure
memset(&server_addr,0,sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port_);
memcpy(&server_addr.sin_addr, hostEntry->h_addr_list[0], hostEntry->h_length);

// create socket
server_ = socket(PF_INET,SOCK_STREAM,0);
if (!server_) {
perror("socket");
exit(-1);
}

// connect to server
if (connect(server_,(const struct sockaddr *)&server_addr,sizeof(server_addr)) < 0) {
perror("connect");
exit(-1);
}
}

void
Client::close_socket() {
close(server_);
}

void
Client::echo() {
string line;

// loop to handle user interface
while (getline(cin,line)) {
// append a newline
line += "\n";
// send request
bool success = send_request(line);
// break if an error occurred
if (not success)
break;
// get a response
success = get_response();
// break if an error occurred
if (not success)
break;
}
close_socket();
}

bool
Client::send_request(string request) {
// prepare to send request
const char* ptr = request.c_str();
int nleft = request.length();
int nwritten;
// loop to be sure it is all sent
while (nleft) {
if ((nwritten = send(server_, ptr, nleft, 0)) < 0) {
if (errno == EINTR) {
// the socket call was interrupted -- try again
continue;
} else {
// an error occurred, so break out
perror("write");
return false;
}
} else if (nwritten == 0) {
// the socket is closed
return false;
}
nleft -= nwritten;
ptr += nwritten;
}
return true;
}

bool
Client::get_response() {
string response = "";
// read until we get a newline
while (response.find("\n") == string::npos) {
int nread = recv(server_,buf_,1024,0);
if (nread < 0) {
if (errno == EINTR)
// the socket call was interrupted -- try again
continue;
else
// an error occurred, so break out
return "";
} else if (nread == 0) {
// the socket is closed
return "";
}
// be sure to use append in case we have binary data
response.append(buf_,nread);
}
// a better client would cut off anything after the newline and
// save it in a cache
cout << response;
return true;
}
37 changes: 37 additions & 0 deletions client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>

#include <fstream>
#include <iostream>
#include <string>

using namespace std;

class Client {
public:
Client(string host, int port);
~Client();

void run();

private:
virtual void create();
virtual void close_socket();
void echo();
bool send_request(string);
bool get_response();

string host_;
int port_;
int server_;
int buflen_;
char* buf_;
};
1 change: 1 addition & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define no false
#define brake break
#define wtf LOGD
#define GW (GtkWidget *)

#ifdef How_to_dismantle_an_atomic_bomb
typedef void vodi ;
Expand Down
Binary file modified dictionary.o
Binary file not shown.
2 changes: 1 addition & 1 deletion engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ENGINE_H

#ifdef __linux__
#include <lilv/lilv.h>
//~ #include <lilv/lilv.h>
#include <sys/utsname.h>
#include "snd.h"
#include "jack.h"
Expand Down
Binary file modified engine.o
Binary file not shown.
Binary file modified jack.o
Binary file not shown.
Binary file modified knob.o
Binary file not shown.
Binary file modified log.o
Binary file not shown.
Binary file modified lv2_ext.o
Binary file not shown.
Loading

0 comments on commit 3bff44c

Please sign in to comment.