diff --git a/src/bnetz/dialer.c b/src/bnetz/dialer.c index bfe252d..40783ad 100644 --- a/src/bnetz/dialer.c +++ b/src/bnetz/dialer.c @@ -346,7 +346,7 @@ int main(int argc, char *argv[]) #ifdef HAVE_ALSA /* 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) { LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n"); goto exit; diff --git a/src/datenklo/datenklo.c b/src/datenklo/datenklo.c index e7f86f2..21a789f 100644 --- a/src/datenklo/datenklo.c +++ b/src/datenklo/datenklo.c @@ -1397,7 +1397,7 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer, #ifdef HAVE_ALSA /* 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) { LOGP(DDATENKLO, LOGL_ERROR, "No sound device!\n"); return -EIO; diff --git a/src/dcf77/main.c b/src/dcf77/main.c index f55e317..b99197c 100755 --- a/src/dcf77/main.c +++ b/src/dcf77/main.c @@ -413,13 +413,19 @@ static int get_char() int soundif_open(const char *audiodev, int samplerate, int buffer_size) { + enum sound_direction direction = SOUND_DIR_DUPLEX; + if (!audiodev || !audiodev[0]) { LOGP(DDSP, LOGL_ERROR, "No audio device given!\n"); return -EINVAL; } /* 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) { LOGP(DDSP, LOGL_ERROR, "Failed to open sound device!\n"); return -EIO; @@ -451,34 +457,38 @@ void soundif_work(int buffer_size) int rc; int i; - /* encode and write */ - count = sound_get_tosend(soundif, buffer_size); - if (count < 0) { - LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count); - return; - } - if (count) { - dcf77_encode(dcf77, samples[0], count); - if (double_amplitude) { - for (i = 0; i < count; i++) - samples[1][i] = -samples[0][i]; - } - rc = sound_write(soundif, samples, NULL, count, NULL, NULL, (double_amplitude) ? 2 : 1); - if (rc < 0) { - LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc); + if (tx) { + /* encode and write */ + count = sound_get_tosend(soundif, buffer_size); + if (count < 0) { + LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count); return; } + if (count) { + dcf77_encode(dcf77, samples[0], count); + if (double_amplitude) { + for (i = 0; i < count; i++) + samples[1][i] = -samples[0][i]; + } + rc = sound_write(soundif, samples, NULL, count, NULL, NULL, (double_amplitude) ? 2 : 1); + if (rc < 0) { + LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc); + return; + } + } } - /* read */ - count = sound_read(soundif, samples, buffer_size, 1, rf_level_db); - if (count < 0) { - LOGP(DDSP, LOGL_ERROR, "Failed to read from audio device (rc = %d)!\n", count); - return; - } + if (rx) { + /* read */ + count = sound_read(soundif, samples, buffer_size, 1, rf_level_db); + if (count < 0) { + LOGP(DDSP, LOGL_ERROR, "Failed to read from audio device (rc = %d)!\n", count); + return; + } - /* decode */ - dcf77_decode(dcf77, samples[0], count); + /* decode */ + dcf77_decode(dcf77, samples[0], count); + } } int main(int argc, char *argv[]) diff --git a/src/imts/dialer.c b/src/imts/dialer.c index b00b4b9..6ef6692 100644 --- a/src/imts/dialer.c +++ b/src/imts/dialer.c @@ -307,7 +307,7 @@ int main(int argc, char *argv[]) #ifdef HAVE_ALSA /* 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) { LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n"); goto exit; diff --git a/src/libjitter/jitter.c b/src/libjitter/jitter.c index 6e510d5..1a7b619 100644 --- a/src/libjitter/jitter.c +++ b/src/libjitter/jitter.c @@ -282,7 +282,7 @@ void jitter_save(jitter_t *jb, jitter_frame_t *jf) offset_timestamp = jf->timestamp - jb->window_timestamp; #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 /* measure delay */ @@ -348,7 +348,7 @@ int32_t jitter_offset(jitter_t *jb) jb->unlocked = true; /* 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; if (offset_timestamp >= 0) break; @@ -446,6 +446,9 @@ copy_chunk: tocopy = jb->spl_len - jb->spl_pos; if (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 */ jitter_advance(jb, tocopy); 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 */ if (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 */ jitter_advance(jb, offset); /* if there is no buffer, allocate 20ms, filled with 0 */ @@ -501,6 +507,9 @@ copy_chunk: jitter_reset(jb); return; } +#ifdef HEAVY_DEBUG + LOGP(DJITTER, LOGL_DEBUG, "%s loading new frame to sample buffer.\n", jb->name); +#endif /* get data from frame */ jitter_frame_get(jf, &decoder, &decoder_priv, &payload, &payload_len, NULL, NULL, NULL, NULL); /* free previous buffer */ diff --git a/src/libmobile/console.c b/src/libmobile/console.c index 39cde05..349cd29 100755 --- a/src/libmobile/console.c +++ b/src/libmobile/console.c @@ -404,7 +404,7 @@ int console_open_audio(int __attribute__((unused)) buffer_size, double __attribu #ifdef HAVE_ALSA /* open sound device for call control */ /* 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) { LOGP(DSENDER, LOGL_ERROR, "No sound device!\n"); return -EIO; diff --git a/src/libmobile/sender.c b/src/libmobile/sender.c index 5d12cb3..82873af 100644 --- a/src/libmobile/sender.c +++ b/src/libmobile/sender.c @@ -235,7 +235,7 @@ int sender_open_audio(int buffer_size, double interval) } /* 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) { LOGP(DSENDER, LOGL_ERROR, "No device for transceiver!\n"); return -EIO; diff --git a/src/libmobile/sender.h b/src/libmobile/sender.h index 28dac3d..c7d4ee6 100644 --- a/src/libmobile/sender.h +++ b/src/libmobile/sender.h @@ -44,7 +44,7 @@ typedef struct sender { /* audio */ void *audio; 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 *); void (*audio_close)(void *); int (*audio_write)(void *, sample_t **, uint8_t **, int, enum paging_signal *, int *, int); diff --git a/src/libsdr/sdr.c b/src/libsdr/sdr.c index 50659ed..537fd9b 100644 --- a/src/libsdr/sdr.c +++ b/src/libsdr/sdr.c @@ -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); } -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; int threads = 1, oversample = 1; /* always use threads */ diff --git a/src/libsdr/sdr.h b/src/libsdr/sdr.h index 0455200..a79dd6d 100644 --- a/src/libsdr/sdr.h +++ b/src/libsdr/sdr.h @@ -2,7 +2,7 @@ enum paging_signal; 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); 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); diff --git a/src/libsound/sound.h b/src/libsound/sound.h index 173dfd3..6779503 100644 --- a/src/libsound/sound.h +++ b/src/libsound/sound.h @@ -1,7 +1,13 @@ 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); 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); diff --git a/src/libsound/sound_alsa.c b/src/libsound/sound_alsa.c index fd3dd70..6f2b9bf 100644 --- a/src/libsound/sound_alsa.c +++ b/src/libsound/sound_alsa.c @@ -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) */ typedef struct sound { + enum sound_direction direction; snd_pcm_t *phandle, *chandle; int pchannels, cchannels; int channels; /* required number of channels */ @@ -125,49 +126,57 @@ error: static int dev_open(sound_t *sound) { - int rc, rc_rec, rc_play; + int rc, rc_rec = 0, rc_play = 0; - 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) - 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 (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)); + 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); + 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)); + } + 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) + 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) return (rc_play < 0) ? rc_play : rc_rec; - rc = set_hw_params(sound->phandle, sound->samplerate, &sound->pchannels); - if (rc < 0) { - LOGP(DSOUND, LOGL_ERROR, "Failed to set playback hw params\n"); - return rc; - } - if (sound->pchannels < sound->channels) { - LOGP(DSOUND, LOGL_ERROR, "Sound card only supports %d channel for playback.\n", sound->pchannels); - return rc; - } - LOGP(DSOUND, LOGL_DEBUG, "Playback with %d channels.\n", sound->pchannels); + if (sound->direction == SOUND_DIR_PLAY || sound->direction == SOUND_DIR_DUPLEX) { + rc = set_hw_params(sound->phandle, sound->samplerate, &sound->pchannels); + if (rc < 0) { + LOGP(DSOUND, LOGL_ERROR, "Failed to set playback hw params\n"); + return rc; + } + if (sound->pchannels < sound->channels) { + LOGP(DSOUND, LOGL_ERROR, "Sound card only supports %d channel for playback.\n", sound->pchannels); + return rc; + } + LOGP(DSOUND, LOGL_DEBUG, "Playback with %d channels.\n", sound->pchannels); - rc = set_hw_params(sound->chandle, sound->samplerate, &sound->cchannels); - if (rc < 0) { - LOGP(DSOUND, LOGL_ERROR, "Failed to set capture hw params\n"); - return rc; - } - if (sound->cchannels < sound->channels) { - LOGP(DSOUND, LOGL_ERROR, "Sound card only supports %d channel for capture.\n", sound->cchannels); - return -EIO; - } - 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->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); - 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); + if (rc < 0) { + LOGP(DSOUND, LOGL_ERROR, "Failed to set capture hw params\n"); + return rc; + } + if (sound->cchannels < sound->channels) { + LOGP(DSOUND, LOGL_ERROR, "Sound card only supports %d channel for capture.\n", sound->cchannels); + return -EIO; + } + LOGP(DSOUND, LOGL_DEBUG, "Capture with %d channels.\n", sound->cchannels); + + rc = snd_pcm_prepare(sound->chandle); + if (rc < 0) { + LOGP(DSOUND, LOGL_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(rc)); + return rc; + } } return 0; @@ -181,7 +190,7 @@ static void dev_close(sound_t *sound) 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; const char *env; @@ -206,6 +215,7 @@ void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_freque } else { sound->caudiodev = sound->paudiodev; } + sound->direction = direction; sound->channels = channels; sound->samplerate = samplerate; sound->spl_deviation = max_deviation / 32767.0; @@ -249,6 +259,9 @@ int sound_start(void *inst) sound_t *sound = (sound_t *)inst; int16_t buff[2]; + if (sound->direction != SOUND_DIR_REC && sound->direction != SOUND_DIR_DUPLEX) + return -EINVAL; + /* trigger capturing */ 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 i, ii; + if (sound->direction != SOUND_DIR_PLAY && sound->direction != SOUND_DIR_DUPLEX) + return -EINVAL; + if (sound->pchannels == 2) { /* two channels */ #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 i, ii; + if (sound->direction != SOUND_DIR_REC && sound->direction != SOUND_DIR_DUPLEX) + return -EINVAL; + /* get samples in rx buffer */ in = snd_pcm_avail(sound->chandle); /* 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; int tosend; + if (sound->direction != SOUND_DIR_PLAY && sound->direction != SOUND_DIR_DUPLEX) + return -EINVAL; + rc = snd_pcm_delay(sound->phandle, &delay); if (rc < 0) { if (rc == -32) diff --git a/src/magnetic/main.c b/src/magnetic/main.c index fc757d8..7d06804 100644 --- a/src/magnetic/main.c +++ b/src/magnetic/main.c @@ -268,7 +268,7 @@ inval_number: #ifdef HAVE_ALSA /* 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) { rc = -EIO; LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n"); diff --git a/src/mate/matesimulator.c b/src/mate/matesimulator.c index 9da3afb..a29ed51 100644 --- a/src/mate/matesimulator.c +++ b/src/mate/matesimulator.c @@ -272,7 +272,7 @@ int main(int argc, char *argv[]) #ifdef HAVE_ALSA /* 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) { LOGP(DDSP, LOGL_ERROR, "No sound device!\n"); goto exit; diff --git a/src/radio/main.c b/src/radio/main.c index e00ba9b..b9d5f1f 100644 --- a/src/radio/main.c +++ b/src/radio/main.c @@ -396,7 +396,7 @@ int main(int argc, char *argv[]) tx_frequencies[0] = frequency; rx_frequencies[0] = frequency; 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) goto error; sdr_start(sdr); diff --git a/src/radio/radio.c b/src/radio/radio.c index 5e59432..dcc0b4d 100644 --- a/src/radio/radio.c +++ b/src/radio/radio.c @@ -100,7 +100,7 @@ int radio_init(radio_t *radio, int buffer_size, int samplerate, double frequency /* open audio device */ radio->tx_audio_samplerate = 48000; 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) { rc = -EIO; 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_channels = (stereo) ? 2 : 1; /* check if we use same device */ - if (radio->tx_sound && !strcmp(tx_audiodev, rx_audiodev)) - 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); + 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); if (!radio->rx_sound) { rc = -EIO; LOGP(DRADIO, LOGL_ERROR, "Failed to open sound device!\n"); diff --git a/src/tv/main.c b/src/tv/main.c index 00fd25e..15ad60c 100644 --- a/src/tv/main.c +++ b/src/tv/main.c @@ -342,7 +342,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s tx_frequencies[0] = frequency; rx_frequencies[0] = frequency; 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) goto error; sdr_start(sdr);