aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2019-10-27 07:03:23 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2019-11-29 15:58:32 +0100
commit23bb88ef6e2bdefd76e61afc4805e3fd92860ea4 (patch)
treebe451e408a46bc95813a1f9e40b1cbe17e2ce642
parent2fde5025afe53841a09fbb0dff242245430f7019 (diff)
Describe if audio device exists, but does not support both directions
-rw-r--r--src/libmobile/sender.c2
-rw-r--r--src/libsound/sound_alsa.c21
2 files changed, 14 insertions, 9 deletions
diff --git a/src/libmobile/sender.c b/src/libmobile/sender.c
index 2d88eaa..fe2951f 100644
--- a/src/libmobile/sender.c
+++ b/src/libmobile/sender.c
@@ -222,7 +222,7 @@ int sender_open_audio(int latspl)
/* open device */
master->audio = master->audio_open(master->audiodev, tx_f, rx_f, channels, paging_frequency, master->samplerate, latspl, master->max_deviation, master->max_modulation);
if (!master->audio) {
- PDEBUG(DSENDER, DEBUG_ERROR, "No audio device!\n");
+ PDEBUG(DSENDER, DEBUG_ERROR, "No device for transceiver!\n");
return -EIO;
}
}
diff --git a/src/libsound/sound_alsa.c b/src/libsound/sound_alsa.c
index 5b5e4eb..dc1dfcd 100644
--- a/src/libsound/sound_alsa.c
+++ b/src/libsound/sound_alsa.c
@@ -134,7 +134,7 @@ static int sound_prepare(sound_t *sound)
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) latspl, double max_deviation, double __attribute__((unused)) max_modulation)
{
sound_t *sound;
- int rc;
+ int rc, rc_rec, rc_play;
if (channels < 1 || channels > 2) {
PDEBUG(DSOUND, DEBUG_ERROR, "Cannot use more than two channels with the same sound card!\n");
@@ -150,15 +150,20 @@ void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_freque
sound->spl_deviation = max_deviation / 32767.0;
sound->paging_phaseshift = 1.0 / ((double)samplerate / 1000.0);
- rc = snd_pcm_open(&sound->phandle, audiodev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
- if (rc < 0) {
- PDEBUG(DSOUND, DEBUG_ERROR, "Failed to open '%s' for playback! (%s)\n", audiodev, snd_strerror(rc));
+ rc_play = snd_pcm_open(&sound->phandle, audiodev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
+ rc_rec = snd_pcm_open(&sound->chandle, audiodev, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
+ if (rc_play < 0 && rc_rec < 0) {
+ PDEBUG(DSOUND, DEBUG_ERROR, "Failed to open '%s'! (%s)\n", audiodev, snd_strerror(rc_play));
+ PDEBUG(DSOUND, DEBUG_ERROR, "Run 'aplay -l' to get a list of available cards and devices.\n");
+ PDEBUG(DSOUND, DEBUG_ERROR, "Then use 'hw:<card>:<device>' for audio device.\n");
goto error;
}
-
- rc = snd_pcm_open(&sound->chandle, audiodev, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
- if (rc < 0) {
- PDEBUG(DSOUND, DEBUG_ERROR, "Failed to open '%s' for capture! (%s)\n", audiodev, snd_strerror(rc));
+ if (rc_play < 0) {
+ PDEBUG(DSOUND, DEBUG_ERROR, "Failed to open '%s' for playback! (%s) Please select a device that supports both direction audio.\n", audiodev, snd_strerror(rc_play));
+ goto error;
+ }
+ if (rc_rec < 0) {
+ PDEBUG(DSOUND, DEBUG_ERROR, "Failed to open '%s' for capture! (%s) Please select a device that supports both direction audio.\n", audiodev, snd_strerror(rc_rec));
goto error;
}