Browse Source

Add FPRS element by type functions

master
Jeroen Vreeken 4 years ago
parent
commit
ad8c47f018
8 changed files with 33 additions and 14 deletions
  1. +1
    -0
      .gitignore
  2. +2
    -2
      analog_trx.c
  3. +1
    -0
      eth_ar/fprs.h
  4. +11
    -0
      fprs.c
  5. +4
    -0
      fprs_test.c
  6. +2
    -2
      freedv_eth.c
  7. +11
    -9
      sound.c
  8. +1
    -1
      sound.h

+ 1
- 0
.gitignore View File

@ -3,6 +3,7 @@ analog_trx
freedv_eth
fprs2aprs_gate
fprs_test
eth_ar_if
# http://www.gnu.org/software/automake


+ 2
- 2
analog_trx.c View File

@ -333,14 +333,14 @@ static void dequeue_voice(void)
int16_t buffer[nr_samples];
beacon_generate(beacon, buffer);
sound_out(buffer, nr_samples);
sound_out(buffer, nr_samples, true, true);
}
} else {
queue_voice = p->next;
if (beacon)
beacon_generate_add(beacon, p->samples, p->nr_samples);
sound_out(p->samples, p->nr_samples);
sound_out(p->samples, p->nr_samples, true, true);
free(p->samples);
free(p);


+ 1
- 0
eth_ar/fprs.h View File

@ -90,6 +90,7 @@ enum fprs_type {
char *fprs_type2str(enum fprs_type);
uint8_t *fprs_frame_element_by_type(struct fprs_frame *, enum fprs_type);
size_t fprs_element_size(uint8_t *element);
enum fprs_type fprs_element_type(uint8_t *element);


+ 11
- 0
fprs.c View File

@ -108,6 +108,17 @@ uint8_t *fprs_frame_element_get(struct fprs_frame *frame, uint8_t *prev)
return NULL;
}
uint8_t *fprs_frame_element_by_type(struct fprs_frame *frame, enum fprs_type type)
{
uint8_t *e = NULL;
while ((e = fprs_frame_element_get(frame, e))) {
if (fprs_element_type(e) == type)
return e;
}
return NULL;
}
uint8_t *fprs_frame_element_add(struct fprs_frame *frame, enum fprs_type type, size_t size)
{
size_t allocsize = size;


+ 4
- 0
fprs_test.c View File

@ -105,6 +105,10 @@ int test_frame_elements(void)
testelements[elcnt].size, fprs_element_size(el));
return -1;
}
if (fprs_frame_element_by_type(frame, testelements[elcnt].type) != el) {
fprintf(stderr, "by_type does not find element\n");
return -1;
}
int i;
for (i = 0; i < testelements[elcnt].size; i++) {


+ 2
- 2
freedv_eth.c View File

@ -209,7 +209,7 @@ static void data_tx(void)
{
freedv_datatx(freedv, mod_out);
sound_out(mod_out, nom_modem_samples);
sound_out(mod_out, nom_modem_samples, true, true);
}
static void check_tx_add(void)
@ -260,7 +260,7 @@ static void dequeue_voice(void)
} else {
freedv_codectx(freedv, mod_out, data);
sound_out(mod_out, nom_modem_samples);
sound_out(mod_out, nom_modem_samples, true, true);
printf("-");
fflush(NULL);


+ 11
- 9
sound.c View File

@ -38,11 +38,12 @@ static int channels_in = 1;
int written;
int failed;
int sound_out(int16_t *samples, int nr)
int sound_out(int16_t *samples, int nr, bool left, bool right)
{
int r;
int play_nr = nr * ratio_out;
int16_t play_samples[play_nr * channels_out];
int i;
if (src_out) {
float data_in[nr], data_out[play_nr];
@ -64,16 +65,16 @@ int sound_out(int16_t *samples, int nr)
samples = play_samples;
nr = play_nr;
}
if (channels_out != 1) {
int i;
for (i = play_nr; i >= 0; i--) {
/* Output is always multiple channels */
for (i = play_nr; i >= 0; i--) {
if (left)
play_samples[i * 2 + 0] = samples[i];
if (right)
play_samples[i * 2 + 1] = samples[i];
}
samples = play_samples;
}
r = snd_pcm_writei (pcm_handle_tx, samples, nr);
r = snd_pcm_writei (pcm_handle_tx, play_samples, nr);
// printf("alsa: %d\n", r);
if (r < 0) {
failed++;
@ -223,8 +224,9 @@ int sound_param(snd_pcm_t *pcm_handle, bool is_tx, int sw_rate, int hw_rate)
}
printf("rate: %d got rate: %d\n", rate, rrate);
if (snd_pcm_hw_params_set_channels (pcm_handle, hw_params, 1)) {
printf("Could not set channels to 1\n");
if (is_tx || snd_pcm_hw_params_set_channels (pcm_handle, hw_params, 1)) {
if (!is_tx)
printf("Could not set channels to 1\n");
if (snd_pcm_hw_params_set_channels (pcm_handle, hw_params, 2)) {
printf("Could not set channels to 2\n");
} else {


+ 1
- 1
sound.h View File

@ -22,7 +22,7 @@
#include <poll.h>
#include <stdbool.h>
int sound_out(int16_t *samples, int nr);
int sound_out(int16_t *samples, int nr, bool left, bool right);
int sound_silence(void);
int sound_init(char *device, void (*in_cb)(int16_t *samples, int nr), int inr, int rate, int hw_rate);
int sound_poll_count_tx(void);


Loading…
Cancel
Save