summaryrefslogtreecommitdiffstats
path: root/parecord
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-01-27 18:39:08 +0000
committerJoursoir <chat@joursoir.net>2021-01-27 18:39:08 +0000
commit0fb817103e6ec78d1840507e83e43b3a45bee1ea (patch)
treea80ff41eb8348a88778689a4c4e56a300b50d407 /parecord
parentce707a138327ff9ceb8cc954d4d103a17a72bbed (diff)
downloadaudio-tools-0fb817103e6ec78d1840507e83e43b3a45bee1ea.tar.gz
audio-tools-0fb817103e6ec78d1840507e83e43b3a45bee1ea.tar.bz2
audio-tools-0fb817103e6ec78d1840507e83e43b3a45bee1ea.zip
fix incorrect terminology
Diffstat (limited to 'parecord')
-rw-r--r--parecord/audio_types.c14
-rw-r--r--parecord/audio_types.h10
-rw-r--r--parecord/parecord.c30
3 files changed, 28 insertions, 26 deletions
diff --git a/parecord/audio_types.c b/parecord/audio_types.c
index 0dd1b2f..916a5cf 100644
--- a/parecord/audio_types.c
+++ b/parecord/audio_types.c
@@ -2,8 +2,8 @@
#include "audio_types.h"
-static const struct audio_format support_formats[] = {
- {"wav", 44}, // AUDIO_FORMAT_WAVE = 0
+static const struct audio_types_info support_types[] = {
+ {"wav", 44}, // AUDIO_TYPE_WAVE
{NULL, 0}
};
@@ -28,19 +28,19 @@ struct wav_header *init_wav_header(struct wav_header *header,
return header;
}
-int checkAudioFormat(char *source)
+int checkAudioType(char *source)
{
int i;
- for(i = 0; support_formats[i].name != NULL; i++) {
- if(strcmp(source, support_formats[i].name) == 0) {
+ for(i = 0; support_types[i].name != NULL; i++) {
+ if(strcmp(source, support_types[i].name) == 0) {
return i;
}
}
- return AUDIO_FORMAT_NONE;
+ return AUDIO_TYPE_NONE;
}
off_t getOffset(int format)
{
- return support_formats[format].rsv_bytes;
+ return support_types[format].rsv_bytes;
} \ No newline at end of file
diff --git a/parecord/audio_types.h b/parecord/audio_types.h
index 2abd11d..6b6fd12 100644
--- a/parecord/audio_types.h
+++ b/parecord/audio_types.h
@@ -6,10 +6,12 @@
#include "wav_header.h"
-#define AUDIO_FORMAT_NONE -1
-#define AUDIO_FORMAT_WAVE 0
+enum audio_types {
+ AUDIO_TYPE_WAVE,
+ AUDIO_TYPE_NONE = -1
+};
-struct audio_format {
+struct audio_types_info {
const char *name;
off_t rsv_bytes;
};
@@ -17,7 +19,7 @@ struct audio_format {
struct wav_header *init_wav_header(struct wav_header *header,
uint32_t size, uint16_t audioFormat, uint16_t numChannels,
uint32_t sampleRate, uint32_t bitsPerSample);
-int checkAudioFormat(char *source);
+int checkAudioType(char *source);
off_t getOffset(int format);
#endif /* AT_AUDIOTYPES_H */
diff --git a/parecord/parecord.c b/parecord/parecord.c
index 3f7dda1..8c638ba 100644
--- a/parecord/parecord.c
+++ b/parecord/parecord.c
@@ -52,27 +52,27 @@ int main(int argc, char *argv[])
specification.rate = 44100;
int fd_output = STDOUT_FILENO;
- int file_format = AUDIO_FORMAT_NONE, result;
+ int file_type = AUDIO_TYPE_NONE, result;
off_t offset;
const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
- {"format", required_argument, NULL, 'f'},
- {"formats", no_argument, NULL, 'F'},
+ {"file-type", required_argument, NULL, 't'},
+ {"file-types", no_argument, NULL, 'T'},
{NULL, 0, NULL, 0}
};
- while((result = getopt_long(argc, argv, "hf:F", long_options, NULL)) != -1) {
+ while((result = getopt_long(argc, argv, "ht:T", long_options, NULL)) != -1) {
switch(result) {
case 'h': {
// print help
return 0;
}
- case 'f': {
- file_format = checkAudioFormat(optarg);
- if(file_format != AUDIO_FORMAT_NONE) break;
+ case 't': {
+ file_type = checkAudioType(optarg);
+ if(file_type != AUDIO_TYPE_NONE) break;
// else print formats (below)
}
- case 'F': {
+ case 'T': {
// print formats
return 0;
}
@@ -90,8 +90,8 @@ int main(int argc, char *argv[])
}
// reserve bytes for audio header:
- if(file_format != AUDIO_FORMAT_NONE) {
- offset = getOffset(file_format);
+ if(file_type != AUDIO_TYPE_NONE) {
+ offset = getOffset(file_type);
if(lseek(fd_output, offset, SEEK_SET) == -1) {
perror("[Error] lseek() form header");
return 1;
@@ -132,17 +132,17 @@ int main(int argc, char *argv[])
if(connection)
pa_simple_free(connection);
- if(file_format != AUDIO_FORMAT_NONE) {
+ if(file_type != AUDIO_TYPE_NONE) {
if(lseek(fd_output, 0, SEEK_SET) == -1) {
perror("[Error] lseek()");
return 1;
}
}
- switch(file_format)
+ switch(file_type)
{
- case AUDIO_FORMAT_NONE: break;
- case AUDIO_FORMAT_WAVE: {
+ case AUDIO_TYPE_NONE: break;
+ case AUDIO_TYPE_WAVE: {
struct stat s;
if(fstat(fd_output, &s) == -1) {
perror("[Error] fstat");
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
}
struct wav_header *header = malloc(offset);
- init_wav_header(header, s.st_size, 16, 1,
+ init_wav_header(header, s.st_size, 1,
specification.channels, specification.rate, 16);
#ifdef DEBUG