From: François Grondin Date: Thu, 1 Apr 2021 17:28:01 +0000 (-0400) Subject: Revert "RendezVous Team Changes " X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=a5ba683781bb470df9a39a18965e391b1e9a3004;p=yn%2Fyn-odas.git Revert "RendezVous Team Changes " --- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9a64151..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -bin/* -build/* -lib/* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 67084a3..9a2ac3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ set(SRC src/general/format.c src/general/interface.c src/general/link.c - src/general/map.c src/general/mic.c src/general/samplerate.c src/general/soundspeed.c @@ -194,8 +193,6 @@ target_link_libraries(odas ${PC_FFTW3_LIBRARIES} ${PC_ALSA_LIBRARIES} ${PC_LIBCONFIG_LIBRARIES} - pulse - pulse-simple m pthread ) diff --git a/demo/odaslive/objects.c b/demo/odaslive/objects.c index 194cca7..c7fecba 100644 --- a/demo/odaslive/objects.c +++ b/demo/odaslive/objects.c @@ -8,8 +8,6 @@ objs = (objects *) malloc(sizeof(objects)); - map_init(&objs->timestamp_map); - // +----------------------------------------------------------+ // | Construct | // +----------------------------------------------------------+ @@ -20,12 +18,10 @@ // +--------------------------------------------------+ // | Source | - // +--------------------------------------------------+ + // +--------------------------------------------------+ objs->src_hops_mics_object = src_hops_construct(cfgs->src_hops_mics_config, cfgs->msg_hops_mics_raw_config); - - src_hops_set_timestamp_map(objs->src_hops_mics_object, &objs->timestamp_map); // +--------------------------------------------------+ // | Connector | @@ -267,8 +263,6 @@ objs->snk_hops_seps_vol_object = snk_hops_construct(cfgs->snk_hops_seps_vol_config, cfgs->msg_hops_seps_vol_config); - snk_hops_set_timestamp_map(objs->snk_hops_seps_vol_object, &objs->timestamp_map); - objs->snk_hops_pfs_vol_object = snk_hops_construct(cfgs->snk_hops_pfs_vol_config, cfgs->msg_hops_pfs_vol_config); @@ -573,8 +567,6 @@ // | Destroy | // +----------------------------------------------------------+ - map_deinit(&objs->timestamp_map); - // +------------------------------------------------------+ // | Raw | // +------------------------------------------------------+ @@ -828,8 +820,6 @@ objs->nMessages = 100; - map_init(&objs->timestamp_map); - // +----------------------------------------------------------+ // | Construct | // +----------------------------------------------------------+ @@ -844,8 +834,6 @@ objs->asrc_hops_mics_object = asrc_hops_construct(cfgs->src_hops_mics_config, cfgs->msg_hops_mics_raw_config); - - src_hops_set_timestamp_map(objs->asrc_hops_mics_object->src_hops, &objs->timestamp_map); // +--------------------------------------------------+ // | Connector | @@ -1089,8 +1077,6 @@ objs->asnk_hops_seps_vol_object = asnk_hops_construct(cfgs->snk_hops_seps_vol_config, cfgs->msg_hops_seps_vol_config); - snk_hops_set_timestamp_map(objs->asnk_hops_seps_vol_object->snk_hops, &objs->timestamp_map); - objs->asnk_hops_pfs_vol_object = asnk_hops_construct(cfgs->snk_hops_pfs_vol_config, cfgs->msg_hops_pfs_vol_config); @@ -1395,8 +1381,6 @@ // | Destroy | // +----------------------------------------------------------+ - map_deinit(&objs->timestamp_map); - // +------------------------------------------------------+ // | Raw | // +------------------------------------------------------+ diff --git a/demo/odaslive/objects.h b/demo/odaslive/objects.h index b94a5b2..dbb3abf 100644 --- a/demo/odaslive/objects.h +++ b/demo/odaslive/objects.h @@ -60,8 +60,6 @@ con_categories_obj * con_categories_object; snk_categories_obj * snk_categories_object; - map_ull_t timestamp_map; - } objects; typedef struct aobjects { @@ -119,8 +117,6 @@ acon_categories_obj * acon_categories_object; asnk_categories_obj * asnk_categories_object; - map_ull_t timestamp_map; - } aobjects; objects * objects_construct(const configs * cfgs); diff --git a/demo/odaslive/parameters.c b/demo/odaslive/parameters.c index bc4ad32..eb0777a 100644 --- a/demo/odaslive/parameters.c +++ b/demo/odaslive/parameters.c @@ -204,13 +204,6 @@ cfg->interface = interface_construct_soundcard_by_name(tmpStr2); - } - else if (strcmp(tmpStr1, "pulseaudio") == 0) { - - tmpStr2 = parameters_lookup_string(fileConfig, "raw.interface.source"); - - cfg->interface = interface_construct_pulseaudio(tmpStr2); - } else { printf("raw.interface.type: Invalid type\n"); diff --git a/include/odas/general/interface.h b/include/odas/general/interface.h index 58c71fe..349ca1e 100644 --- a/include/odas/general/interface.h +++ b/include/odas/general/interface.h @@ -35,7 +35,6 @@ interface_socket = 3, interface_soundcard = 4, interface_terminal = 5, - interface_pulseaudio = 6 } interface_type; @@ -60,8 +59,6 @@ interface_obj * interface_construct_socket(const char * ip, const unsigned int port); - interface_obj * interface_construct_pulseaudio(const char * sourceName); - interface_obj * interface_construct_soundcard(const unsigned int card, const unsigned int device); interface_obj * interface_construct_soundcard_by_name(char * deviceName); diff --git a/include/odas/general/map.h b/include/odas/general/map.h deleted file mode 100644 index cf923d5..0000000 --- a/include/odas/general/map.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2014 rxi - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef MAP_H -#define MAP_H - -#include - -#define MAP_VERSION "0.1.0" - -struct map_node_t; -typedef struct map_node_t map_node_t; - -typedef struct { - map_node_t **buckets; - unsigned nbuckets, nnodes; -} map_base_t; - -typedef struct { - unsigned bucketidx; - map_node_t *node; -} map_iter_t; - - -#define map_t(T)\ - struct { map_base_t base; T *ref; T tmp; } - - -#define map_init(m)\ - memset(m, 0, sizeof(*(m))) - - -#define map_deinit(m)\ - map_deinit_(&(m)->base) - - -#define map_get(m, key)\ - ( (m)->ref = map_get_(&(m)->base, key) ) - - -#define map_set(m, key, value)\ - ( (m)->tmp = (value),\ - map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp)) ) - - -#define map_remove(m, key)\ - map_remove_(&(m)->base, key) - - -#define map_iter(m)\ - map_iter_() - - -#define map_next(m, iter)\ - map_next_(&(m)->base, iter) - - -void map_deinit_(map_base_t *m); -void *map_get_(map_base_t *m, const char *key); -int map_set_(map_base_t *m, const char *key, void *value, int vsize); -void map_remove_(map_base_t *m, const char *key); -map_iter_t map_iter_(void); -const char *map_next_(map_base_t *m, map_iter_t *iter); - - -typedef map_t(void*) map_void_t; -typedef map_t(char*) map_str_t; -typedef map_t(int) map_int_t; -typedef map_t(char) map_char_t; -typedef map_t(float) map_float_t; -typedef map_t(double) map_double_t; -typedef map_t(unsigned long long) map_ull_t; - -#endif \ No newline at end of file diff --git a/include/odas/sink/snk_hops.h b/include/odas/sink/snk_hops.h index ce918e2..677f225 100644 --- a/include/odas/sink/snk_hops.h +++ b/include/odas/sink/snk_hops.h @@ -32,7 +32,6 @@ #include #include "../general/format.h" - #include "../general/map.h" #include "../general/interface.h" #include "../message/msg_hops.h" #include "../utils/pcm.h" @@ -40,8 +39,6 @@ typedef struct snk_hops_obj { unsigned long long timeStamp; - unsigned long long readTimeStamp; - map_ull_t * timeStampMap; unsigned int hopSize; unsigned int nChannels; @@ -51,10 +48,7 @@ interface_obj * interface; char * buffer; - char * headerBufferPtr; - char * audioBufferPtr; - unsigned int headerSize; - unsigned int audioSize; + unsigned int bufferSize; FILE * fp; @@ -117,8 +111,6 @@ void snk_hops_process_format_undefined(snk_hops_obj * obj); - void snk_hops_set_timestamp_map(snk_hops_obj * obj, map_ull_t * timestamp_map); - snk_hops_cfg * snk_hops_cfg_construct(void); void snk_hops_cfg_destroy(snk_hops_cfg * snk_hops_config); diff --git a/include/odas/source/src_hops.h b/include/odas/source/src_hops.h index 63e5a1a..b0a32b9 100644 --- a/include/odas/source/src_hops.h +++ b/include/odas/source/src_hops.h @@ -27,12 +27,9 @@ #include #include #include - #include - #include #include "../general/format.h" #include "../general/interface.h" - #include "../general/map.h" #include "../message/msg_hops.h" #include "../signal/hop.h" #include "../utils/pcm.h" @@ -40,7 +37,6 @@ typedef struct src_hops_obj { unsigned long long timeStamp; - map_ull_t * timeStampMap; unsigned int hopSize; unsigned int nChannels; @@ -51,9 +47,6 @@ FILE * fp; snd_pcm_t * ch; - pa_simple * pa; - pa_sample_spec ss; - pa_channel_map map; char * buffer; unsigned int bufferSize; @@ -85,24 +78,18 @@ void src_hops_open_interface_soundcard(src_hops_obj * obj); - void src_hops_open_interface_pulseaudio(src_hops_obj * obj); - void src_hops_close(src_hops_obj * obj); void src_hops_close_interface_file(src_hops_obj * obj); void src_hops_close_interface_soundcard(src_hops_obj * obj); - void src_hops_close_interface_pulseaudio(src_hops_obj * obj); - int src_hops_process(src_hops_obj * obj); int src_hops_process_interface_file(src_hops_obj * obj); int src_hops_process_interface_soundcard(src_hops_obj * obj); - int src_hops_process_interface_pulseaudio(src_hops_obj * obj); - void src_hops_process_format_binary_int08(src_hops_obj * obj); void src_hops_process_format_binary_int16(src_hops_obj * obj); @@ -111,8 +98,6 @@ void src_hops_process_format_binary_int32(src_hops_obj * obj); - void src_hops_set_timestamp_map(src_hops_obj * obj, map_ull_t * timestamp_map); - src_hops_cfg * src_hops_cfg_construct(void); void src_hops_cfg_destroy(src_hops_cfg * src_hops_config); diff --git a/src/general/interface.c b/src/general/interface.c index 02e07a5..c01a628 100644 --- a/src/general/interface.c +++ b/src/general/interface.c @@ -213,54 +213,6 @@ } - interface_obj * interface_construct_pulseaudio(const char * sourceName) { - - interface_obj * obj; - - obj = (interface_obj *) malloc(sizeof(interface_obj)); - - // +----------------------------------------------------------+ - // | Type | - // +----------------------------------------------------------+ - - obj->type = interface_pulseaudio; - - // +----------------------------------------------------------+ - // | Blackhole | - // +----------------------------------------------------------+ - - // (Empty) - - // +----------------------------------------------------------+ - // | File | - // +----------------------------------------------------------+ - - obj->fileName = (char *) NULL; - - // +----------------------------------------------------------+ - // | Socket | - // +----------------------------------------------------------+ - - obj->ip = (char *) NULL; - obj->port = 0; - - // +----------------------------------------------------------+ - // | Soundcard | - // +----------------------------------------------------------+ - - obj->deviceName = (char *) malloc(sizeof(char) * (strlen(sourceName)+1)); - strcpy(obj->deviceName, sourceName); - - // +----------------------------------------------------------+ - // | Terminal | - // +----------------------------------------------------------+ - - // (Empty) - - return obj; - - } - interface_obj * interface_construct_soundcard(const unsigned int card, const unsigned int device) { char * deviceName = (char *) malloc(sizeof(char) * 1024); @@ -414,15 +366,6 @@ clone->deviceName = obj->deviceName; } - // +----------------------------------------------------------+ - // | Pulseaudio | - // +----------------------------------------------------------+ - - if (obj->type == interface_pulseaudio) { - clone->deviceName = obj->deviceName; - } - - // +----------------------------------------------------------+ // | Terminal | // +----------------------------------------------------------+ @@ -489,12 +432,6 @@ break; - case interface_pulseaudio: - - printf("type = pulseaudio, devicename = %s\n", obj->deviceName); - - break; - case interface_terminal: printf("type = terminal\n"); diff --git a/src/general/map.c b/src/general/map.c deleted file mode 100644 index 7753bf4..0000000 --- a/src/general/map.c +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright (c) 2014 rxi - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "general/map.h" - -struct map_node_t { - unsigned hash; - void *value; - map_node_t *next; - /* char key[]; */ - /* char value[]; */ -}; - - -static unsigned map_hash(const char *str) { - unsigned hash = 5381; - while (*str) { - hash = ((hash << 5) + hash) ^ *str++; - } - return hash; -} - - -static map_node_t *map_newnode(const char *key, void *value, int vsize) { - map_node_t *node; - int ksize = strlen(key) + 1; - int voffset = ksize + ((sizeof(void*) - ksize) % sizeof(void*)); - node = malloc(sizeof(*node) + voffset + vsize); - if (!node) return NULL; - memcpy(node + 1, key, ksize); - node->hash = map_hash(key); - node->value = ((char*) (node + 1)) + voffset; - memcpy(node->value, value, vsize); - return node; -} - - -static int map_bucketidx(map_base_t *m, unsigned hash) { - /* If the implementation is changed to allow a non-power-of-2 bucket count, - * the line below should be changed to use mod instead of AND */ - return hash & (m->nbuckets - 1); -} - - -static void map_addnode(map_base_t *m, map_node_t *node) { - int n = map_bucketidx(m, node->hash); - node->next = m->buckets[n]; - m->buckets[n] = node; -} - - -static int map_resize(map_base_t *m, int nbuckets) { - map_node_t *nodes, *node, *next; - map_node_t **buckets; - int i; - /* Chain all nodes together */ - nodes = NULL; - i = m->nbuckets; - while (i--) { - node = (m->buckets)[i]; - while (node) { - next = node->next; - node->next = nodes; - nodes = node; - node = next; - } - } - /* Reset buckets */ - buckets = realloc(m->buckets, sizeof(*m->buckets) * nbuckets); - if (buckets != NULL) { - m->buckets = buckets; - m->nbuckets = nbuckets; - } - if (m->buckets) { - memset(m->buckets, 0, sizeof(*m->buckets) * m->nbuckets); - /* Re-add nodes to buckets */ - node = nodes; - while (node) { - next = node->next; - map_addnode(m, node); - node = next; - } - } - /* Return error code if realloc() failed */ - return (buckets == NULL) ? -1 : 0; -} - - -static map_node_t **map_getref(map_base_t *m, const char *key) { - unsigned hash = map_hash(key); - map_node_t **next; - if (m->nbuckets > 0) { - next = &m->buckets[map_bucketidx(m, hash)]; - while (*next) { - if ((*next)->hash == hash && !strcmp((char*) (*next + 1), key)) { - return next; - } - next = &(*next)->next; - } - } - return NULL; -} - - -void map_deinit_(map_base_t *m) { - map_node_t *next, *node; - int i; - i = m->nbuckets; - while (i--) { - node = m->buckets[i]; - while (node) { - next = node->next; - free(node); - node = next; - } - } - free(m->buckets); -} - - -void *map_get_(map_base_t *m, const char *key) { - map_node_t **next = map_getref(m, key); - return next ? (*next)->value : NULL; -} - - -int map_set_(map_base_t *m, const char *key, void *value, int vsize) { - int n, err; - map_node_t **next, *node; - /* Find & replace existing node */ - next = map_getref(m, key); - if (next) { - memcpy((*next)->value, value, vsize); - return 0; - } - /* Add new node */ - node = map_newnode(key, value, vsize); - if (node == NULL) goto fail; - if (m->nnodes >= m->nbuckets) { - n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; - err = map_resize(m, n); - if (err) goto fail; - } - map_addnode(m, node); - m->nnodes++; - return 0; - fail: - if (node) free(node); - return -1; -} - - -void map_remove_(map_base_t *m, const char *key) { - map_node_t *node; - map_node_t **next = map_getref(m, key); - if (next) { - node = *next; - *next = (*next)->next; - free(node); - m->nnodes--; - } -} - - -map_iter_t map_iter_(void) { - map_iter_t iter; - iter.bucketidx = -1; - iter.node = NULL; - return iter; -} - - -const char *map_next_(map_base_t *m, map_iter_t *iter) { - if (iter->node) { - iter->node = iter->node->next; - if (iter->node == NULL) goto nextBucket; - } else { - nextBucket: - do { - if (++iter->bucketidx >= m->nbuckets) { - return NULL; - } - iter->node = m->buckets[iter->bucketidx]; - } while (iter->node == NULL); - } - return (char*) (iter->node + 1); -} \ No newline at end of file diff --git a/src/sink/snk_hops.c b/src/sink/snk_hops.c index c34b0a4..406ad13 100644 --- a/src/sink/snk_hops.c +++ b/src/sink/snk_hops.c @@ -30,8 +30,6 @@ obj = (snk_hops_obj *) malloc(sizeof(snk_hops_obj)); obj->timeStamp = 0; - obj->readTimeStamp = 0; - obj->timeStampMap = NULL; obj->hopSize = msg_hops_config->hopSize; obj->nChannels = msg_hops_config->nChannels; @@ -57,16 +55,9 @@ } - unsigned int headerSize = sizeof(obj->readTimeStamp); - unsigned int audioSize = sizeof(char) * msg_hops_config->nChannels * msg_hops_config->hopSize * 4; - - obj->buffer = (char *) malloc(headerSize + audioSize); - obj->headerBufferPtr = obj->buffer; - obj->audioBufferPtr = obj->buffer + headerSize; - memset(obj->headerBufferPtr, 0x00, headerSize); - memset(obj->audioBufferPtr, 0x00, audioSize); - obj->audioSize = 0; - obj->headerSize = headerSize; + obj->buffer = (char *) malloc(sizeof(char) * msg_hops_config->nChannels * msg_hops_config->hopSize * 4); + memset(obj->buffer, 0x00, sizeof(char) * msg_hops_config->nChannels * msg_hops_config->hopSize * 4); + obj->bufferSize = 0; obj->in = (msg_hops_obj *) NULL; @@ -221,25 +212,6 @@ if (obj->in->timeStamp != 0) { - if (obj->timeStampMap != NULL) - { - const int n = snprintf(NULL, 0, "%llu", obj->in->timeStamp); - char key[n+1]; - int c = snprintf(key, n+1, "%llu", obj->in->timeStamp); - if (key[n] != '\0' || c != n) { - printf("Sink hops: Invalid timestamp \n"); - rtnValue = -1; - } - - unsigned long long* readTimeStamp = map_get(obj->timeStampMap, key); - if (readTimeStamp) { - obj->readTimeStamp = *readTimeStamp; - map_remove(obj->timeStampMap, key); - } else { - printf("Sink hops: timestamp not found \n"); - } - } - switch(obj->format->type) { case format_binary_int08: @@ -331,22 +303,13 @@ void snk_hops_process_interface_file(snk_hops_obj * obj) { - fwrite(obj->audioBufferPtr, sizeof(char), obj->audioSize, obj->fp); + fwrite(obj->buffer, sizeof(char), obj->bufferSize, obj->fp); } void snk_hops_process_interface_socket(snk_hops_obj * obj) { - char* bufferToSend = obj->audioBufferPtr; - unsigned int bytesToSend = obj->audioSize; - - if (obj->readTimeStamp != 0) { - bufferToSend = obj->headerBufferPtr; - bytesToSend = obj->headerSize + obj->audioSize; - memcpy(obj->headerBufferPtr, &obj->readTimeStamp, obj->headerSize); - } - - if (send(obj->sid, bufferToSend, bytesToSend, 0) < 0) { + if (send(obj->sid, obj->buffer, obj->bufferSize, 0) < 0) { printf("Sink hops: Could not send message.\n"); exit(EXIT_FAILURE); } @@ -370,7 +333,7 @@ sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); - memcpy(&(obj->audioBufferPtr[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); nBytesTotal += nBytes; @@ -378,7 +341,7 @@ } - obj->audioSize = nBytesTotal; + obj->bufferSize = nBytesTotal; } @@ -399,7 +362,7 @@ sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); - memcpy(&(obj->audioBufferPtr[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); nBytesTotal += nBytes; @@ -408,7 +371,7 @@ } - obj->audioSize = nBytesTotal; + obj->bufferSize = nBytesTotal; } @@ -429,7 +392,7 @@ sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); - memcpy(&(obj->audioBufferPtr[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); nBytesTotal += nBytes; @@ -437,7 +400,7 @@ } - obj->audioSize = nBytesTotal; + obj->bufferSize = nBytesTotal; } @@ -458,7 +421,7 @@ sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); - memcpy(&(obj->audioBufferPtr[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); nBytesTotal += nBytes; @@ -466,20 +429,15 @@ } - obj->audioSize = nBytesTotal; + obj->bufferSize = nBytesTotal; } void snk_hops_process_format_undefined(snk_hops_obj * obj) { - obj->audioBufferPtr[0] = 0x00; - obj->audioSize = 0; - - } + obj->buffer[0] = 0x00; + obj->bufferSize = 0; - void snk_hops_set_timestamp_map(snk_hops_obj * obj, map_ull_t * timestamp_map) - { - obj->timeStampMap = timestamp_map; } snk_hops_cfg * snk_hops_cfg_construct(void) { diff --git a/src/source/src_hops.c b/src/source/src_hops.c index 4661813..8c2081f 100644 --- a/src/source/src_hops.c +++ b/src/source/src_hops.c @@ -31,7 +31,6 @@ obj = (src_hops_obj *) malloc(sizeof(src_hops_obj)); obj->timeStamp = 0; - obj->timeStampMap = NULL; obj->hopSize = msg_hops_config->hopSize; obj->nChannels = msg_hops_config->nChannels; @@ -49,11 +48,7 @@ ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int08)) || ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int16)) || ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int24)) || - ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int32)) || - ((obj->interface->type == interface_pulseaudio) && (obj->format->type == format_binary_int08)) || - ((obj->interface->type == interface_pulseaudio) && (obj->format->type == format_binary_int16)) || - ((obj->interface->type == interface_pulseaudio) && (obj->format->type == format_binary_int24)) || - ((obj->interface->type == interface_pulseaudio) && (obj->format->type == format_binary_int32)))) { + ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int32)))) { printf("Source hops: Invalid interface and/or format.\n"); exit(EXIT_FAILURE); @@ -116,12 +111,6 @@ break; - case interface_pulseaudio: - - src_hops_open_interface_pulseaudio(obj); - - break; - default: printf("Source hops: Invalid interface type.\n"); @@ -144,107 +133,6 @@ } - void src_hops_open_interface_pulseaudio(src_hops_obj * obj) { - - pa_sample_format_t format; - - switch (obj->format->type) { - - case format_binary_int08: - - format = PA_SAMPLE_U8; - - break; - - case format_binary_int16: - - format = PA_SAMPLE_S16LE; - - break; - - case format_binary_int24: - - format = PA_SAMPLE_S24LE; - - break; - - case format_binary_int32: - - format = PA_SAMPLE_S32LE; - - break; - - default: - - printf("Source hops: Invalid format.\n"); - exit(EXIT_FAILURE); - - break; - - } - - obj->ss.format = format; - obj->ss.rate = obj->fS; - obj->ss.channels = obj->nChannels; - - obj->map.channels = obj->nChannels; - switch(obj->nChannels) - { - case 1: - obj->map.map[0] = PA_CHANNEL_POSITION_MONO; - break; - - case 2: - obj->map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; - obj->map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; - break; - - case 8: - obj->map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; - obj->map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; - obj->map.map[2] = PA_CHANNEL_POSITION_REAR_LEFT; - obj->map.map[3] = PA_CHANNEL_POSITION_REAR_RIGHT; - obj->map.map[4] = PA_CHANNEL_POSITION_FRONT_CENTER; - obj->map.map[5] = PA_CHANNEL_POSITION_LFE; - obj->map.map[6] = PA_CHANNEL_POSITION_SIDE_LEFT; - obj->map.map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; - break; - - case 16: - obj->map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; - obj->map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; - obj->map.map[2] = PA_CHANNEL_POSITION_REAR_LEFT; - obj->map.map[3] = PA_CHANNEL_POSITION_REAR_RIGHT; - obj->map.map[4] = PA_CHANNEL_POSITION_FRONT_CENTER; - obj->map.map[5] = PA_CHANNEL_POSITION_LFE; - obj->map.map[6] = PA_CHANNEL_POSITION_SIDE_LEFT; - obj->map.map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; - obj->map.map[8] = PA_CHANNEL_POSITION_AUX0; - obj->map.map[9] = PA_CHANNEL_POSITION_AUX1; - obj->map.map[10] = PA_CHANNEL_POSITION_AUX2; - obj->map.map[11] = PA_CHANNEL_POSITION_AUX3; - obj->map.map[12] = PA_CHANNEL_POSITION_AUX4; - obj->map.map[13] = PA_CHANNEL_POSITION_AUX5; - obj->map.map[14] = PA_CHANNEL_POSITION_AUX6; - obj->map.map[15] = PA_CHANNEL_POSITION_AUX7; - break; - - default: - - printf("Source hops: Invalid format.\n"); - exit(EXIT_FAILURE); - - break; - } - - int err; - if (!(obj->pa = pa_simple_new(NULL, "Odas", PA_STREAM_RECORD, obj->interface->deviceName, "record", &obj->ss, &obj->map, NULL, &err))) { - printf("Source hops: Cannot open pulseaudio device %s: %s\n", obj->interface->deviceName, pa_strerror(err)); - exit(EXIT_FAILURE); - } - - } - void src_hops_open_interface_soundcard(src_hops_obj * obj) { snd_pcm_hw_params_t * hw_params; @@ -352,12 +240,6 @@ break; - case interface_pulseaudio: - - src_hops_close_interface_pulseaudio(obj); - - break; - default: printf("Source hops: Invalid interface type.\n"); @@ -381,13 +263,6 @@ } - void src_hops_close_interface_pulseaudio(src_hops_obj * obj) { - - if (obj->pa != NULL) - pa_simple_free(obj->pa); - - } - int src_hops_process(src_hops_obj * obj) { int rtnValue; @@ -441,12 +316,6 @@ break; - case interface_pulseaudio: - - rtnValue = src_hops_process_interface_pulseaudio(obj); - - break; - default: printf("Source hops: Invalid interface type.\n"); @@ -506,53 +375,6 @@ } - int src_hops_process_interface_pulseaudio(src_hops_obj * obj) { - - int rtnValue; - int err; - - if (pa_simple_read(obj->pa, obj->buffer, obj->bufferSize, &err) < 0) { - - rtnValue = -1; - - } - else { - - rtnValue = 0; - - } - - struct timeval currentTime; - gettimeofday(¤tTime, NULL); - unsigned long long microseconds = currentTime.tv_sec * (int)1e6 + currentTime.tv_usec; - - // remove pulseaudio latency - pa_usec_t latency; - latency = pa_simple_get_latency(obj->pa, &err); - if (latency == (pa_usec_t) -1) { - printf("Source hops: Could not get pulseaudio latency: %s\n", pa_strerror(err)); - rtnValue = -1; - } - - unsigned long long timestamp = obj->timeStamp + 1; - unsigned long long readTimeStamp = microseconds - latency; - - const int n = snprintf(NULL, 0, "%llu", timestamp); - char key[n+1]; - int c = snprintf(key, n+1, "%llu", timestamp); - if (key[n] != '\0' || c != n) { - printf("Source hops: Invalid timestamp \n"); - rtnValue = -1; - } - - if (obj->timeStampMap != NULL) { - map_set(obj->timeStampMap, key, readTimeStamp); - } - - return rtnValue; - - } - void src_hops_process_format_binary_int08(src_hops_obj * obj) { unsigned int iSample; @@ -661,11 +483,6 @@ } - void src_hops_set_timestamp_map(src_hops_obj * obj, map_ull_t * timestamp_map) - { - obj->timeStampMap = timestamp_map; - } - src_hops_cfg * src_hops_cfg_construct(void) { src_hops_cfg * cfg;