Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation patch (Ubuntu 20.10) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))

.PHONY: all
all: $(OBJS)
all: $(MAIN)

$(MAIN): $(OBJS)
$(CC) -o $(MAIN) $? $(CFLAGS_1) $(LIBS)


$(OBJS): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INCLUDES)
$(CC) -c -o $@ $< $(LIBS) $(CFLAGS_1)

clean:
rm bin/main
rm lib/*.o
rm -f bin/main
rm -f lib/*.o
4 changes: 2 additions & 2 deletions include/capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ typedef struct {
unsigned channels;
} capHW;

capHW hw;
int err;
extern capHW hw;
extern int err;

void loadCapSettings(const char name[], const unsigned sr, const unsigned c);

Expand Down
12 changes: 6 additions & 6 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
#include <ncurses.h>

// Windows
WINDOW *selectorContainer;
WINDOW *selector;
extern WINDOW *selectorContainer;
extern WINDOW *selector;

// Geometrical features
int LEN_CONTAINER, POSX_CONTAINER;
int LEN_SELECTOR, POSX0_SELECTOR, POSX1_SELECTOR, POSX2_SELECTOR;
int POSX_STEREO, POSX_FRONT, POSX_SURROUND;
extern int LEN_CONTAINER, POSX_CONTAINER;
extern int LEN_SELECTOR, POSX0_SELECTOR, POSX1_SELECTOR, POSX2_SELECTOR;
extern int POSX_STEREO, POSX_FRONT, POSX_SURROUND;

void initGui(char const *dev_names[]); // init interface
void refreshGui(); // updates screen
void killGui(); // deallocate used memory

void toogleSelectorGui(unsigned char t);

#endif
#endif
5 changes: 2 additions & 3 deletions include/playback.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ typedef struct {
long unsigned frames;
} PlaybackHW;

PlaybackHW hwpb;
int err;
extern PlaybackHW hwpb;

void loadPBSettings(const char name[], const unsigned sr, const unsigned c, const unsigned f);
snd_pcm_t * playbackSetup();
Expand All @@ -36,4 +35,4 @@ do { \
} \
} while (0)

#endif
#endif
14 changes: 7 additions & 7 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
#include <alsa/asoundlib.h>

// Alsa handlers
snd_pcm_t *cHandle; // capture handler
snd_pcm_t *pbHandle; // playback handler
extern snd_pcm_t *cHandle; // capture handler
extern snd_pcm_t *pbHandle; // playback handler

// Variables
short bufRead[CHANNELS * M]; // buffer for capturing
short bufWrite[CHANNELS * M]; // buffer for playback
int readData, writeData; // number of samples captured
extern short bufRead[CHANNELS * M]; // buffer for capturing
extern short bufWrite[CHANNELS * M]; // buffer for playback
extern int readData, writeData; // number of samples captured

struct BufferSem inBufferSem, outBufferSem; // to synch tasks
extern struct BufferSem inBufferSem, outBufferSem; // to synch tasks

extern unsigned short exitLoop;
extern unsigned char toggle;
Expand All @@ -35,4 +35,4 @@ void *captureThread(void *arg);
void *playbackThread(void *arg);


#endif
#endif
5 changes: 4 additions & 1 deletion src/capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include "capture.h"

capHW hw;
int err;

void loadCapSettings(const char name[], const unsigned sr, const unsigned c){
strcpy(hw.name, name);
hw.samplerate = sr;
Expand Down Expand Up @@ -95,4 +98,4 @@ int capture(snd_pcm_t *h, short *b, const size_t f) {
count -= res;

return res;
}
}
11 changes: 10 additions & 1 deletion src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

#include <ncurses.h>

// Windows
WINDOW *selectorContainer;
WINDOW *selector;

// Geometrical features
int LEN_CONTAINER, POSX_CONTAINER;
int LEN_SELECTOR, POSX0_SELECTOR, POSX1_SELECTOR, POSX2_SELECTOR;
int POSX_STEREO, POSX_FRONT, POSX_SURROUND;

void computeGeometricalParams(){
// Geometry for Container
LEN_CONTAINER = COLS / 3;
Expand Down Expand Up @@ -106,4 +115,4 @@ void toogleSelectorGui(unsigned char t) {

void killGui() {
endwin();
}
}
3 changes: 3 additions & 0 deletions src/playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <sys/time.h>
#include "playback.h"

PlaybackHW hwpb;

void loadPBSettings(const char name[], const unsigned sr, const unsigned c, const unsigned f) {
strcpy(hwpb.name, name);
hwpb.samplerate = sr;
Expand All @@ -18,6 +20,7 @@ void loadPBSettings(const char name[], const unsigned sr, const unsigned c, cons
snd_pcm_t * playbackSetup() {
snd_pcm_hw_params_t *hw_params;
static snd_pcm_t *pb_handle;
int err;

if ((err = snd_pcm_open(&pb_handle, hwpb.name, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
fprintf(stderr, "[ERROR:] cannot open audio device %s (%s)\n", hwpb.name, snd_strerror(err));
Expand Down
23 changes: 22 additions & 1 deletion src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@
#include <pthread.h>
// #include <sys/time.h>

// Alsa handlers
snd_pcm_t *cHandle; // capture handler
snd_pcm_t *pbHandle; // playback handler

// Variables
short bufRead[CHANNELS * M]; // buffer for capturing
short bufWrite[CHANNELS * M]; // buffer for playback
int readData, writeData; // number of samples captured

struct BufferSem inBufferSem, outBufferSem; // to synch tasks

unsigned short exitLoop = 0;

/*
#ifdef MEASURE_LATENCY
struct Latency m_latency;
#endif
*/
//struct timeval start, end;

void initAlsa(const char *dev_name[], const unsigned fq, const unsigned c, const unsigned f) {
Expand Down Expand Up @@ -105,9 +118,11 @@ void *captureThread(void *arg) {
while (1) {
sem_wait(&inBufferSem.priv_w);

/*
#ifdef MEASURE_LATENCY
gettimeofday(&m_latency.start, NULL);
#endif
*/

readData = capture(cHandle, bufRead, M);
inBuffer_post_write(&inBufferSem);
Expand All @@ -121,9 +136,11 @@ void *captureThread(void *arg) {

void *playbackThread(void *arg) {

/*
#ifdef MEASURE_LATENCY
initLatencyBuffer(&m_latency);
#endif
*/

outBuffer_post_read(&outBufferSem);

Expand All @@ -132,17 +149,21 @@ void *playbackThread(void *arg) {
sem_wait(outBufferSem.priv_r);
playback(pbHandle, bufWrite, writeData);

/*
#ifdef MEASURE_LATENCY
gettimeofday(&m_latency.end, NULL);
#endif
*/

outBuffer_post_read(&outBufferSem);

/*
#ifdef MEASURE_LATENCY
computeLatency(&m_latency);
logLatency(&m_latency, (float)m_latency.micros/writeData);
#endif

*/

if (exitLoop) break;
}
pthread_exit(NULL);
Expand Down