Open sound device for capture or playback only, if full duplex is not required

This commit is contained in:
Andreas Eversberg
2024-03-15 16:30:04 +01:00
parent ce58b765f5
commit b613123291
17 changed files with 125 additions and 81 deletions

View File

@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0); audio = sound_open(SOUND_DIR_PLAY, dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!audio) { if (!audio) {
LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n"); LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n");
goto exit; goto exit;

View File

@@ -1397,7 +1397,7 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer,
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
datenklo->audio = sound_open(audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->buffer_size, 1.0, 1.0, 4000.0, 2.0); datenklo->audio = sound_open(SOUND_DIR_DUPLEX, audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!datenklo->audio) { if (!datenklo->audio) {
LOGP(DDATENKLO, LOGL_ERROR, "No sound device!\n"); LOGP(DDATENKLO, LOGL_ERROR, "No sound device!\n");
return -EIO; return -EIO;

View File

@@ -413,13 +413,19 @@ static int get_char()
int soundif_open(const char *audiodev, int samplerate, int buffer_size) int soundif_open(const char *audiodev, int samplerate, int buffer_size)
{ {
enum sound_direction direction = SOUND_DIR_DUPLEX;
if (!audiodev || !audiodev[0]) { if (!audiodev || !audiodev[0]) {
LOGP(DDSP, LOGL_ERROR, "No audio device given!\n"); LOGP(DDSP, LOGL_ERROR, "No audio device given!\n");
return -EINVAL; return -EINVAL;
} }
/* open audiodev */ /* open audiodev */
soundif = sound_open(audiodev, NULL, NULL, NULL, (double_amplitude) ? 2 : 1, 0.0, samplerate, buffer_size, 1.0, 1.0, 0.0, 2.0); if (tx && !rx)
direction = SOUND_DIR_PLAY;
if (rx && !tx)
direction = SOUND_DIR_REC;
soundif = sound_open(direction, audiodev, NULL, NULL, NULL, (double_amplitude) ? 2 : 1, 0.0, samplerate, buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!soundif) { if (!soundif) {
LOGP(DDSP, LOGL_ERROR, "Failed to open sound device!\n"); LOGP(DDSP, LOGL_ERROR, "Failed to open sound device!\n");
return -EIO; return -EIO;
@@ -451,6 +457,7 @@ void soundif_work(int buffer_size)
int rc; int rc;
int i; int i;
if (tx) {
/* encode and write */ /* encode and write */
count = sound_get_tosend(soundif, buffer_size); count = sound_get_tosend(soundif, buffer_size);
if (count < 0) { if (count < 0) {
@@ -469,7 +476,9 @@ void soundif_work(int buffer_size)
return; return;
} }
} }
}
if (rx) {
/* read */ /* read */
count = sound_read(soundif, samples, buffer_size, 1, rf_level_db); count = sound_read(soundif, samples, buffer_size, 1, rf_level_db);
if (count < 0) { if (count < 0) {
@@ -479,6 +488,7 @@ void soundif_work(int buffer_size)
/* decode */ /* decode */
dcf77_decode(dcf77, samples[0], count); dcf77_decode(dcf77, samples[0], count);
}
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@@ -307,7 +307,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, dsp_buffer, 1.0, 1.0, 4000.0, 2.0); audio = sound_open(SOUND_DIR_PLAY, dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, dsp_buffer, 1.0, 1.0, 4000.0, 2.0);
if (!audio) { if (!audio) {
LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n"); LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n");
goto exit; goto exit;

View File

@@ -282,7 +282,7 @@ void jitter_save(jitter_t *jb, jitter_frame_t *jf)
offset_timestamp = jf->timestamp - jb->window_timestamp; offset_timestamp = jf->timestamp - jb->window_timestamp;
#ifdef HEAVY_DEBUG #ifdef HEAVY_DEBUG
LOGP(DJITTER, LOGL_DEBUG, "%sFrame has offset of %.0fms in jitter buffer.\n", jb->name, (double)offset_timestamp * jb->sample_duration * 1000.0); LOGP(DJITTER, LOGL_DEBUG, "%s Frame has offset of %.0fms in jitter buffer.\n", jb->name, (double)offset_timestamp * jb->sample_duration * 1000.0);
#endif #endif
/* measure delay */ /* measure delay */
@@ -348,7 +348,7 @@ int32_t jitter_offset(jitter_t *jb)
jb->unlocked = true; jb->unlocked = true;
/* get timestamp of chunk that is not in the past */ /* get timestamp of chunk that is not in the past */
while ((jf = jb->frame_list)) { for (jf = jb->frame_list; jf; jf = jf->next) {
offset_timestamp = jf->timestamp - jb->window_timestamp; offset_timestamp = jf->timestamp - jb->window_timestamp;
if (offset_timestamp >= 0) if (offset_timestamp >= 0)
break; break;
@@ -446,6 +446,9 @@ copy_chunk:
tocopy = jb->spl_len - jb->spl_pos; tocopy = jb->spl_len - jb->spl_pos;
if (tocopy > len) if (tocopy > len)
tocopy = len; tocopy = len;
#ifdef HEAVY_DEBUG
LOGP(DJITTER, LOGL_DEBUG, "%s loading %d samples: from valid sample buffer.\n", jb->name, tocopy);
#endif
/* advance jitter buffer */ /* advance jitter buffer */
jitter_advance(jb, tocopy); jitter_advance(jb, tocopy);
memcpy(spl, jb->spl_buf + jb->spl_pos * sample_size, tocopy * sample_size); memcpy(spl, jb->spl_buf + jb->spl_pos * sample_size, tocopy * sample_size);
@@ -469,6 +472,9 @@ copy_chunk:
/* only process as much samples as need */ /* only process as much samples as need */
if (offset > len) if (offset > len)
offset = len; offset = len;
#ifdef HEAVY_DEBUG
LOGP(DJITTER, LOGL_DEBUG, "%s concealing %d samples: from invalid sample buffer.\n", jb->name, offset);
#endif
/* advance jitter buffer */ /* advance jitter buffer */
jitter_advance(jb, offset); jitter_advance(jb, offset);
/* if there is no buffer, allocate 20ms, filled with 0 */ /* if there is no buffer, allocate 20ms, filled with 0 */
@@ -501,6 +507,9 @@ copy_chunk:
jitter_reset(jb); jitter_reset(jb);
return; return;
} }
#ifdef HEAVY_DEBUG
LOGP(DJITTER, LOGL_DEBUG, "%s loading new frame to sample buffer.\n", jb->name);
#endif
/* get data from frame */ /* get data from frame */
jitter_frame_get(jf, &decoder, &decoder_priv, &payload, &payload_len, NULL, NULL, NULL, NULL); jitter_frame_get(jf, &decoder, &decoder_priv, &payload, &payload_len, NULL, NULL, NULL, NULL);
/* free previous buffer */ /* free previous buffer */

View File

@@ -404,7 +404,7 @@ int console_open_audio(int __attribute__((unused)) buffer_size, double __attribu
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* open sound device for call control */ /* open sound device for call control */
/* use factor 1.4 of speech level for complete range of sound card */ /* use factor 1.4 of speech level for complete range of sound card */
console.sound = sound_open(console.audiodev, NULL, NULL, NULL, 1, 0.0, console.samplerate, buffer_size, interval, 1.4, 4000.0, 2.0); console.sound = sound_open(SOUND_DIR_DUPLEX, console.audiodev, NULL, NULL, NULL, 1, 0.0, console.samplerate, buffer_size, interval, 1.4, 4000.0, 2.0);
if (!console.sound) { if (!console.sound) {
LOGP(DSENDER, LOGL_ERROR, "No sound device!\n"); LOGP(DSENDER, LOGL_ERROR, "No sound device!\n");
return -EIO; return -EIO;

View File

@@ -235,7 +235,7 @@ int sender_open_audio(int buffer_size, double interval)
} }
/* open device */ /* open device */
master->audio = master->audio_open(master->device, tx_f, rx_f, am, channels, paging_frequency, master->samplerate, buffer_size, interval, (master->max_deviation) ?: 1.0, master->max_modulation, master->modulation_index); master->audio = master->audio_open(SOUND_DIR_DUPLEX, master->device, tx_f, rx_f, am, channels, paging_frequency, master->samplerate, buffer_size, interval, (master->max_deviation) ?: 1.0, master->max_modulation, master->modulation_index);
if (!master->audio) { if (!master->audio) {
LOGP(DSENDER, LOGL_ERROR, "No device for transceiver!\n"); LOGP(DSENDER, LOGL_ERROR, "No device for transceiver!\n");
return -EIO; return -EIO;

View File

@@ -44,7 +44,7 @@ typedef struct sender {
/* audio */ /* audio */
void *audio; void *audio;
char device[64]; /* audio device name (alsa or sdr) */ char device[64]; /* audio device name (alsa or sdr) */
void *(*audio_open)(const char *, double *, double *, int *, int, double, int, int, double, double, double, double); void *(*audio_open)(int, const char *, double *, double *, int *, int, double, int, int, double, double, double, double);
int (*audio_start)(void *); int (*audio_start)(void *);
void (*audio_close)(void *); void (*audio_close)(void *);
int (*audio_write)(void *, sample_t **, uint8_t **, int, enum paging_signal *, int *, int); int (*audio_write)(void *, sample_t **, uint8_t **, int, enum paging_signal *, int *, int);

View File

@@ -137,7 +137,7 @@ static void show_spectrum(const char *direction, double halfbandwidth, double ce
LOGP(DSDR, LOGL_INFO, "Frequency P = %.4f MHz (Paging Frequency)\n", paging_frequency / 1e6); LOGP(DSDR, LOGL_INFO, "Frequency P = %.4f MHz (Paging Frequency)\n", paging_frequency / 1e6);
} }
void *sdr_open(const char __attribute__((__unused__)) *device, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index) void *sdr_open(int __attribute__((__unused__)) direction, const char __attribute__((__unused__)) *device, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index)
{ {
sdr_t *sdr; sdr_t *sdr;
int threads = 1, oversample = 1; /* always use threads */ int threads = 1, oversample = 1; /* always use threads */

View File

@@ -2,7 +2,7 @@
enum paging_signal; enum paging_signal;
int sdr_start(void *inst); int sdr_start(void *inst);
void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index); void *sdr_open(int direction, const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index);
void sdr_close(void *inst); void sdr_close(void *inst);
int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels); int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels);
int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db); int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db);

View File

@@ -1,7 +1,13 @@
enum paging_signal; enum paging_signal;
void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index); enum sound_direction {
SOUND_DIR_PLAY,
SOUND_DIR_REC,
SOUND_DIR_DUPLEX,
};
void *sound_open(int direction, const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index);
int sound_start(void *inst); int sound_start(void *inst);
void sound_close(void *inst); void sound_close(void *inst);
int sound_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels); int sound_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels);

View File

@@ -32,6 +32,7 @@
static int KEEP_FRAMES=8; /* minimum frames not to read, to prevent reading from buffer before data has been received (seems to be a bug in ALSA) */ static int KEEP_FRAMES=8; /* minimum frames not to read, to prevent reading from buffer before data has been received (seems to be a bug in ALSA) */
typedef struct sound { typedef struct sound {
enum sound_direction direction;
snd_pcm_t *phandle, *chandle; snd_pcm_t *phandle, *chandle;
int pchannels, cchannels; int pchannels, cchannels;
int channels; /* required number of channels */ int channels; /* required number of channels */
@@ -125,17 +126,22 @@ error:
static int dev_open(sound_t *sound) static int dev_open(sound_t *sound)
{ {
int rc, rc_rec, rc_play; int rc, rc_rec = 0, rc_play = 0;
if (sound->direction == SOUND_DIR_PLAY || sound->direction == SOUND_DIR_DUPLEX) {
rc_play = snd_pcm_open(&sound->phandle, sound->paudiodev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); rc_play = snd_pcm_open(&sound->phandle, sound->paudiodev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
rc_rec = snd_pcm_open(&sound->chandle, sound->caudiodev, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
if (rc_play < 0) if (rc_play < 0)
LOGP(DSOUND, LOGL_ERROR, "Failed to open '%s' for playback! (%s) Please select a device that supports playing audio.\n", sound->paudiodev, snd_strerror(rc_play)); LOGP(DSOUND, LOGL_ERROR, "Failed to open '%s' for playback! (%s) Please select a device that supports playing audio.\n", sound->paudiodev, snd_strerror(rc_play));
}
if (sound->direction == SOUND_DIR_REC || sound->direction == SOUND_DIR_DUPLEX) {
rc_rec = snd_pcm_open(&sound->chandle, sound->caudiodev, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
if (rc_rec < 0) if (rc_rec < 0)
LOGP(DSOUND, LOGL_ERROR, "Failed to open '%s' for capture! (%s) Please select a device that supports capturing audio.\n", sound->caudiodev, snd_strerror(rc_rec)); LOGP(DSOUND, LOGL_ERROR, "Failed to open '%s' for capture! (%s) Please select a device that supports capturing audio.\n", sound->caudiodev, snd_strerror(rc_rec));
}
if (rc_play < 0 || rc_rec < 0) if (rc_play < 0 || rc_rec < 0)
return (rc_play < 0) ? rc_play : rc_rec; return (rc_play < 0) ? rc_play : rc_rec;
if (sound->direction == SOUND_DIR_PLAY || sound->direction == SOUND_DIR_DUPLEX) {
rc = set_hw_params(sound->phandle, sound->samplerate, &sound->pchannels); rc = set_hw_params(sound->phandle, sound->samplerate, &sound->pchannels);
if (rc < 0) { if (rc < 0) {
LOGP(DSOUND, LOGL_ERROR, "Failed to set playback hw params\n"); LOGP(DSOUND, LOGL_ERROR, "Failed to set playback hw params\n");
@@ -147,6 +153,14 @@ static int dev_open(sound_t *sound)
} }
LOGP(DSOUND, LOGL_DEBUG, "Playback with %d channels.\n", sound->pchannels); LOGP(DSOUND, LOGL_DEBUG, "Playback with %d channels.\n", sound->pchannels);
rc = snd_pcm_prepare(sound->phandle);
if (rc < 0) {
LOGP(DSOUND, LOGL_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(rc));
return rc;
}
}
if (sound->direction == SOUND_DIR_REC || sound->direction == SOUND_DIR_DUPLEX) {
rc = set_hw_params(sound->chandle, sound->samplerate, &sound->cchannels); rc = set_hw_params(sound->chandle, sound->samplerate, &sound->cchannels);
if (rc < 0) { if (rc < 0) {
LOGP(DSOUND, LOGL_ERROR, "Failed to set capture hw params\n"); LOGP(DSOUND, LOGL_ERROR, "Failed to set capture hw params\n");
@@ -158,17 +172,12 @@ static int dev_open(sound_t *sound)
} }
LOGP(DSOUND, LOGL_DEBUG, "Capture with %d channels.\n", sound->cchannels); LOGP(DSOUND, LOGL_DEBUG, "Capture with %d channels.\n", sound->cchannels);
rc = snd_pcm_prepare(sound->phandle);
if (rc < 0) {
LOGP(DSOUND, LOGL_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(rc));
return rc;
}
rc = snd_pcm_prepare(sound->chandle); rc = snd_pcm_prepare(sound->chandle);
if (rc < 0) { if (rc < 0) {
LOGP(DSOUND, LOGL_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(rc)); LOGP(DSOUND, LOGL_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(rc));
return rc; return rc;
} }
}
return 0; return 0;
} }
@@ -181,7 +190,7 @@ static void dev_close(sound_t *sound)
snd_pcm_close(sound->chandle); snd_pcm_close(sound->chandle);
} }
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int __attribute__((unused)) *am, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) buffer_size, double __attribute__((unused)) interval, double max_deviation, double __attribute__((unused)) max_modulation, double __attribute__((unused)) modulation_index) void *sound_open(int direction, const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int __attribute__((unused)) *am, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) buffer_size, double __attribute__((unused)) interval, double max_deviation, double __attribute__((unused)) max_modulation, double __attribute__((unused)) modulation_index)
{ {
sound_t *sound; sound_t *sound;
const char *env; const char *env;
@@ -206,6 +215,7 @@ void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_freque
} else { } else {
sound->caudiodev = sound->paudiodev; sound->caudiodev = sound->paudiodev;
} }
sound->direction = direction;
sound->channels = channels; sound->channels = channels;
sound->samplerate = samplerate; sound->samplerate = samplerate;
sound->spl_deviation = max_deviation / 32767.0; sound->spl_deviation = max_deviation / 32767.0;
@@ -249,6 +259,9 @@ int sound_start(void *inst)
sound_t *sound = (sound_t *)inst; sound_t *sound = (sound_t *)inst;
int16_t buff[2]; int16_t buff[2];
if (sound->direction != SOUND_DIR_REC && sound->direction != SOUND_DIR_DUPLEX)
return -EINVAL;
/* trigger capturing */ /* trigger capturing */
snd_pcm_readi(sound->chandle, buff, 1); snd_pcm_readi(sound->chandle, buff, 1);
@@ -319,6 +332,9 @@ int sound_write(void *inst, sample_t **samples, uint8_t __attribute__((unused))
int rc; int rc;
int i, ii; int i, ii;
if (sound->direction != SOUND_DIR_PLAY && sound->direction != SOUND_DIR_DUPLEX)
return -EINVAL;
if (sound->pchannels == 2) { if (sound->pchannels == 2) {
/* two channels */ /* two channels */
#ifdef HAVE_MOBILE #ifdef HAVE_MOBILE
@@ -404,6 +420,9 @@ int sound_read(void *inst, sample_t **samples, int num, int channels, double *rf
int in, rc; int in, rc;
int i, ii; int i, ii;
if (sound->direction != SOUND_DIR_REC && sound->direction != SOUND_DIR_DUPLEX)
return -EINVAL;
/* get samples in rx buffer */ /* get samples in rx buffer */
in = snd_pcm_avail(sound->chandle); in = snd_pcm_avail(sound->chandle);
/* if not more than KEEP_FRAMES frames available, try next time */ /* if not more than KEEP_FRAMES frames available, try next time */
@@ -501,6 +520,9 @@ int sound_get_tosend(void *inst, int buffer_size)
snd_pcm_sframes_t delay; snd_pcm_sframes_t delay;
int tosend; int tosend;
if (sound->direction != SOUND_DIR_PLAY && sound->direction != SOUND_DIR_DUPLEX)
return -EINVAL;
rc = snd_pcm_delay(sound->phandle, &delay); rc = snd_pcm_delay(sound->phandle, &delay);
if (rc < 0) { if (rc < 0) {
if (rc == -32) if (rc == -32)

View File

@@ -268,7 +268,7 @@ inval_number:
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* open audio device */ /* open audio device */
sound = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 0.0, 2.0); sound = sound_open(SOUND_DIR_PLAY, dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!sound) { if (!sound) {
rc = -EIO; rc = -EIO;
LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n"); LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n");

View File

@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0); audio = sound_open(SOUND_DIR_PLAY, dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!audio) { if (!audio) {
LOGP(DDSP, LOGL_ERROR, "No sound device!\n"); LOGP(DDSP, LOGL_ERROR, "No sound device!\n");
goto exit; goto exit;

View File

@@ -396,7 +396,7 @@ int main(int argc, char *argv[])
tx_frequencies[0] = frequency; tx_frequencies[0] = frequency;
rx_frequencies[0] = frequency; rx_frequencies[0] = frequency;
am[0] = 0; am[0] = 0;
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 0, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0); sdr = sdr_open(0, NULL, tx_frequencies, rx_frequencies, am, 0, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0);
if (!sdr) if (!sdr)
goto error; goto error;
sdr_start(sdr); sdr_start(sdr);

View File

@@ -100,7 +100,7 @@ int radio_init(radio_t *radio, int buffer_size, int samplerate, double frequency
/* open audio device */ /* open audio device */
radio->tx_audio_samplerate = 48000; radio->tx_audio_samplerate = 48000;
radio->tx_audio_channels = (stereo) ? 2 : 1; radio->tx_audio_channels = (stereo) ? 2 : 1;
radio->tx_sound = sound_open(tx_audiodev, NULL, NULL, NULL, radio->tx_audio_channels, 0.0, radio->tx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0); radio->tx_sound = sound_open(SOUND_DIR_PLAY, tx_audiodev, NULL, NULL, NULL, radio->tx_audio_channels, 0.0, radio->tx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!radio->tx_sound) { if (!radio->tx_sound) {
rc = -EIO; rc = -EIO;
LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n"); LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n");
@@ -164,10 +164,7 @@ int radio_init(radio_t *radio, int buffer_size, int samplerate, double frequency
radio->rx_audio_samplerate = 48000; radio->rx_audio_samplerate = 48000;
radio->rx_audio_channels = (stereo) ? 2 : 1; radio->rx_audio_channels = (stereo) ? 2 : 1;
/* check if we use same device */ /* check if we use same device */
if (radio->tx_sound && !strcmp(tx_audiodev, rx_audiodev)) radio->rx_sound = sound_open(SOUND_DIR_REC, rx_audiodev, NULL, NULL, NULL, radio->rx_audio_channels, 0.0, radio->rx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0);
radio->rx_sound = radio->tx_sound;
else
radio->rx_sound = sound_open(rx_audiodev, NULL, NULL, NULL, radio->rx_audio_channels, 0.0, radio->rx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!radio->rx_sound) { if (!radio->rx_sound) {
rc = -EIO; rc = -EIO;
LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n"); LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n");

View File

@@ -342,7 +342,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
tx_frequencies[0] = frequency; tx_frequencies[0] = frequency;
rx_frequencies[0] = frequency; rx_frequencies[0] = frequency;
am[0] = 0; am[0] = 0;
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 0, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0); sdr = sdr_open(0, NULL, tx_frequencies, rx_frequencies, am, 0, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0);
if (!sdr) if (!sdr)
goto error; goto error;
sdr_start(sdr); sdr_start(sdr);