summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-02-01 16:14:03 +0000
committerJoursoir <chat@joursoir.net>2021-02-01 16:14:03 +0000
commite47580ccf15a9951ba5f928f3817a02695279a97 (patch)
treedc996a0d96a15b629ba0de1463abc4921df02de6
parentbd71fe8e472671eb938092bb53086523aa06e4b0 (diff)
downloadaudio-tools-e47580ccf15a9951ba5f928f3817a02695279a97.tar.gz
audio-tools-e47580ccf15a9951ba5f928f3817a02695279a97.tar.bz2
audio-tools-e47580ccf15a9951ba5f928f3817a02695279a97.zip
add functional argv --device
-rw-r--r--parecord/parecord.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/parecord/parecord.c b/parecord/parecord.c
index e14cea9..5e8e94e 100644
--- a/parecord/parecord.c
+++ b/parecord/parecord.c
@@ -7,6 +7,7 @@
#include <getopt.h>
#include <errno.h>
#include <sys/stat.h>
+#include <pulse/error.h>
#include <pulse/simple.h>
#include "audio_types.h"
@@ -56,11 +57,12 @@ int main(int argc, char *argv[])
pa_simple *connection;
pa_sample_spec specification;
- int fd_output = STDOUT_FILENO, result;
+ int fd_output = STDOUT_FILENO, result, error;
int file_type = AUDIO_TYPE_NONE;
int record_format = STD_REC_FORMAT;
uint32_t record_rate = STD_REC_RATE;
uint8_t record_channels = STD_REC_CHANNELS;
+ char *device = NULL;
off_t offset;
const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
@@ -85,7 +87,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "\t\tPrint this text.\n");
fprintf(stderr, "\t-d, --device\n");
- fprintf(stderr, "\t\tIn development...\n");
+ fprintf(stderr, "\t\tName of the audio devices to record stream.\n");
fprintf(stderr, "\t-D, --list-devices\n");
fprintf(stderr, "\t\tPrint all recorder audio devices\n");
@@ -110,7 +112,8 @@ int main(int argc, char *argv[])
return 0;
}
case 'd': {
- // ...
+ device = malloc((strlen(optarg)+1) * sizeof(char));
+ strcpy(device, optarg);
break;
}
case 'D': {
@@ -201,14 +204,14 @@ int main(int argc, char *argv[])
connection = pa_simple_new(NULL,
argv[0],
PA_STREAM_RECORD,
- NULL,
+ device,
"record",
&specification,
NULL,
NULL,
- NULL);
+ &error);
if(!connection) {
- fprintf(stderr, "[Error] pa_simple_new() failed\n");
+ fprintf(stderr, "[Error] pa_simple_new(): %s failed\n", pa_strerror(error));
return 1;
}
@@ -281,5 +284,8 @@ int main(int argc, char *argv[])
close(fd_output);
}
+ if(!device)
+ free(device);
+
return 0;
}