From: han.lu@intel.com
To: tiwai@suse.de, liam.r.girdwood@linux.intel.com,
bernard.gautier@intel.com, edward.c.popescu@intel.com,
alsa-devel@alsa-project.org
Cc: "Lu, Han" <han.lu@intel.com>
Subject: [PATCH 1/3] alsabat: add default device name for playback and capture
Date: Tue, 15 Mar 2016 11:18:52 +0800 [thread overview]
Message-ID: <b76276db854bdcf15562f897eeb1d0cbad7921ec.1458011641.git.han.lu@intel.com> (raw)
In-Reply-To: <cover.1458011641.git.han.lu@intel.com>
In-Reply-To: <cover.1458011641.git.han.lu@intel.com>
From: "Lu, Han" <han.lu@intel.com>
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>
diff --git a/bat/alsa.c b/bat/alsa.c
index 5eaa25b..5775748 100644
--- a/bat/alsa.c
+++ b/bat/alsa.c
@@ -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) {
diff --git a/bat/bat.c b/bat/bat.c
index ddb60b7..9c637f2 100644
--- 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;
diff --git a/bat/common.h b/bat/common.h
index 7346d9f..5417c0e 100644
--- a/bat/common.h
+++ b/bat/common.h
@@ -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)
--
2.5.0
next prev parent reply other threads:[~2016-03-15 3:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 3:18 [PATCH 0/3] *** new features for alsabat *** han.lu
2016-03-15 3:18 ` han.lu [this message]
2016-03-15 3:18 ` [PATCH 2/3] alsabat: add standalone mode han.lu
2016-03-15 3:18 ` [PATCH 3/3] alsabat: add bash test script han.lu
2016-03-15 9:02 ` [PATCH 0/3] *** new features for alsabat *** Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b76276db854bdcf15562f897eeb1d0cbad7921ec.1458011641.git.han.lu@intel.com \
--to=han.lu@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bernard.gautier@intel.com \
--cc=edward.c.popescu@intel.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).