]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsabat: add default device name for playback and capture
authorLu, Han <han.lu@intel.com>
Tue, 15 Mar 2016 03:18:52 +0000 (11:18 +0800)
committerTakashi Iwai <tiwai@suse.de>
Tue, 15 Mar 2016 08:59:09 +0000 (09:59 +0100)
Add default name for the playback and capture devices, in case
they were not set by user through '-D', '-P' or '-C' options.
Previously, if no device be specified, the alsabat will start
a playback thread and a capture thread, and then exit the
threads with error log.
If only one of playback and capture is specified, the alsabat
will work on single line mode as before, where only one thread
(playback or capture) will be started.
The patch was tested on Ubuntu and Chrome OS.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
bat/alsa.c
bat/bat.c
bat/common.h

index 5eaa25b6145632cb32a8457c9b783ac7672f91c8..5775748daf2eb29d7cfe4093641724bf9390c6e9 100644 (file)
@@ -377,12 +377,6 @@ void *playback_alsa(struct bat *bat)
        retval_play = 0;
        memset(&sndpcm, 0, sizeof(sndpcm));
 
-       if (bat->playback.device == NULL) {
-               fprintf(bat->err, _("No PCM device for playback: exit\n"));
-               retval_play = 1;
-               goto exit1;
-       }
-
        err = snd_pcm_open(&sndpcm.handle, bat->playback.device,
                        SND_PCM_STREAM_PLAYBACK, 0);
        if (err != 0) {
@@ -533,12 +527,6 @@ void *record_alsa(struct bat *bat)
        retval_record = 0;
        memset(&sndpcm, 0, sizeof(sndpcm));
 
-       if (bat->capture.device == NULL) {
-               fprintf(bat->err, _("No PCM device for capture: exit\n"));
-               retval_record = 1;
-               goto exit1;
-       }
-
        err = snd_pcm_open(&sndpcm.handle, bat->capture.device,
                        SND_PCM_STREAM_CAPTURE, 0);
        if (err != 0) {
index ddb60b7530090e8f4152ded45db7cf42c228ff8c..9c637f2ac5f657d04af699a71e1a1f5daffa7e7b 100644 (file)
--- a/bat/bat.c
+++ b/bat/bat.c
@@ -473,6 +473,10 @@ static int bat_init(struct bat *bat)
                        return err;
        }
 
+       /* Set default playback and capture devices */
+       if (bat->playback.device == NULL && bat->capture.device == NULL)
+               bat->playback.device = bat->capture.device = DEFAULT_DEV_NAME;
+
        /* Determine capture file */
        if (bat->local) {
                bat->capture.file = bat->playback.file;
index 7346d9fab682b598273d08211aa3b0136b6543d7..5417c0e5092a6d40f552320d67dfe1d7bb579613 100644 (file)
@@ -16,6 +16,7 @@
 #include <alsa/asoundlib.h>
 
 #define TEMP_RECORD_FILE_NAME          "/tmp/bat.wav.XXXXXX"
+#define DEFAULT_DEV_NAME               "default"
 
 #define OPT_BASE                       300
 #define OPT_LOG                                (OPT_BASE + 1)