Commented addrbook code in main. Uncommented audio code in main.
This commit is contained in:
parent
630a4f7803
commit
53081df814
52
src/main.c
52
src/main.c
@ -91,8 +91,7 @@ void cleanup(void) {
|
||||
crypt_key_destroy(&ok);
|
||||
crypt_key_destroy(&rk);
|
||||
|
||||
// if (audio_terminate_soundsystem() == -1)
|
||||
// return 1;
|
||||
audio_terminate_soundsystem();
|
||||
}
|
||||
|
||||
void signal_handler(int signo) {
|
||||
@ -122,9 +121,9 @@ int main(int argc, const char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if (audio_init_soundsystem() == -1)
|
||||
// return 1;
|
||||
|
||||
if (audio_init_soundsystem() == -1)
|
||||
return 1;
|
||||
/*
|
||||
FILE *addrbook_file = fopen(opts.addressbook_path, "r");
|
||||
if (addrbook_file != NULL) {
|
||||
addrbook_load(&ab, addrbook_file);
|
||||
@ -143,6 +142,8 @@ int main(int argc, const char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
addrbook_destroy(&ab);
|
||||
*/
|
||||
FILE *pkey_file = fopen(opts.key_pub_path, "r");
|
||||
FILE *skey_file = fopen(opts.key_sec_path, "r");
|
||||
if (pkey_file == NULL || skey_file == NULL) {
|
||||
@ -198,6 +199,7 @@ int main(int argc, const char **argv) {
|
||||
if (signal(SIGSEGV, signal_handler) == SIG_ERR)
|
||||
fprintf(stderr, "Cannot catch SIGSEGV.\n");
|
||||
|
||||
|
||||
(opts.mode == 'c') ?
|
||||
(result = net_client_init(&n, opts.addr, opts.port))
|
||||
: (result = net_server_init(&n, opts.addr , opts.port));
|
||||
@ -216,26 +218,32 @@ int main(int argc, const char **argv) {
|
||||
|
||||
fprintf(stdout, "A connection with %s established!\n", rkph);
|
||||
|
||||
unsigned char aud_buf[AUDIO_BUF_SIZE];
|
||||
memset(aud_buf, 0, AUDIO_BUF_SIZE);
|
||||
unsigned char aud_buf[AUDIO_BUF_SIZE] = {0};
|
||||
unsigned long long aud_buf_len = AUDIO_BUF_SIZE;
|
||||
unsigned char aud_c_buf[CLEN(AUDIO_BUF_SIZE)] = {0};
|
||||
unsigned long long aud_c_buf_len = CLEN(AUDIO_BUF_SIZE);
|
||||
|
||||
// audio_init_default(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER);
|
||||
audio_init_default(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER);
|
||||
|
||||
// (opts.mode == 'c') ?
|
||||
// (audio_stream_input_toggle(&aud))
|
||||
// : (audio_stream_output_toggle(&aud));
|
||||
|
||||
// for (size_t i = 0; i < (20 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) {
|
||||
// if (opts.mode == 'c') {
|
||||
// audio_read(&aud, aud_buf, AUDIO_BUF_SIZE);
|
||||
// } else {
|
||||
// //
|
||||
// }
|
||||
// }
|
||||
(opts.mode == 'c') ?
|
||||
(audio_stream_input_toggle(&aud))
|
||||
: (audio_stream_output_toggle(&aud));
|
||||
|
||||
// (opts.mode == 'c') ?
|
||||
// (audio_stream_input_toggle(&aud))
|
||||
// : (audio_stream_output_toggle(&aud));
|
||||
for (size_t i = 0; i < (10 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) {
|
||||
if (opts.mode == 'c') {
|
||||
audio_read(&aud, aud_buf, AUDIO_BUF_SIZE);
|
||||
crypt_session_encrypt(&s, aud_buf, AUDIO_BUF_SIZE, aud_c_buf, &aud_c_buf_len);
|
||||
net_send(&n, aud_c_buf, aud_c_buf_len);
|
||||
} else {
|
||||
net_recv(&n, &aud_c_buf, aud_c_buf_len);
|
||||
crypt_session_decrypt(&s, aud_c_buf, aud_c_buf_len, aud_buf, &aud_buf_len);
|
||||
audio_write(&aud, aud_buf, aud_buf_len);
|
||||
}
|
||||
}
|
||||
|
||||
(opts.mode == 'c') ?
|
||||
(audio_stream_input_toggle(&aud))
|
||||
: (audio_stream_output_toggle(&aud));
|
||||
|
||||
cleanup:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user