summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-10-03 10:43:17 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-10-03 10:43:17 +0200
commit7418ed9af40c8a4715add7a302a59a907413640e (patch)
treebbf4753caea1ab81aecdac5a656d61183b786ed3
parentd6dfd7597f5d1339430400112db61b6e432dcd25 (diff)
New aiorecord/aioplay stub programs.
-rw-r--r--src/aiorecord.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/aiorecord.cc b/src/aiorecord.cc
index cfcc392..76febac 100644
--- a/src/aiorecord.cc
+++ b/src/aiorecord.cc
@@ -58,8 +58,24 @@ static const char usage_str[] =
" -h, --help Print this message and exit.\n"
;
+typedef enum {
+ MODE_UNKNOWN,
+ MODE_RECORD,
+ MODE_PLAY,
+} mode_t;
+
int main(int argc, char *argv[])
{
+ // This program acts as both a recorder and a player depending on which name
+ // it is called by.
+ mode_t mode = MODE_UNKNOWN;
+ char *prog = strrchr(argv[0], '/');
+ if(prog == NULL) prog = argv[0];
+ if(!strcmp(prog, "aiorecord")) mode = MODE_RECORD;
+ if(!strcmp(prog, "aioplay")) mode = MODE_PLAY;
+
+ print("prog: '%s'\n", prog);
+
std::string device = "default";
std::string file = "/dev/stdout";
int samplerate = 48000;
@@ -129,9 +145,19 @@ int main(int argc, char *argv[])
Device dev(device);
- Source *src = dev.getSource(device, samplerate, channels);
- if(!src) {
- printf("Could not find source device: %s\n", device.c_str());
+ switch(mode) {
+ case MODE_RECORD:
+ {
+ Source *src = dev.getSource(device, samplerate, channels);
+ if(!src) {
+ printf("Could not find source device: %s\n", device.c_str());
+ }
+ }
+ break;
+ case MODE_PLAY:
+ default:
+ printf("Unknown mode '%s'.\n", prog);
+ return 1;
}
return 0;