diff options
author | XANTRONIX Development | 2022-02-01 14:03:40 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-01 14:03:40 -0500 |
commit | f502d1a5193760c3e16f170af2e07f0a0ba94784 (patch) | |
tree | e00c7e4399ce88e530baf4397d201810a9a8fc68 | |
parent | d512e7c6b2699cfe0c088b36fd8d8c390b2a234f (diff) | |
download | xas-f502d1a5193760c3e16f170af2e07f0a0ba94784.tar.gz xas-f502d1a5193760c3e16f170af2e07f0a0ba94784.tar.bz2 xas-f502d1a5193760c3e16f170af2e07f0a0ba94784.zip |
Rename src/riff.c methods for sake of consistency
-rw-r--r-- | examples/test.c | 6 | ||||
-rw-r--r-- | include/xas/riff.h | 5 | ||||
-rw-r--r-- | src/riff.c | 36 |
3 files changed, 22 insertions, 25 deletions
diff --git a/examples/test.c b/examples/test.c index ec70a8e..24d1d7b 100644 --- a/examples/test.c +++ b/examples/test.c @@ -81,12 +81,12 @@ int main(int argc, char **argv) { usage(argc, argv, "No output file provided"); } - if ((wave = xas_riff_file_new(argv[1], + if ((wave = xas_riff_new_file(argv[1], XAS_AUDIO_STREAM_PCM_16_BIT, sample_rate, XAS_AUDIO_STREAM_STEREO, O_WRONLY | O_CREAT | O_TRUNC)) == NULL) { - goto error_riff_file_new; + goto error_riff_new_file; } if ((synth_l = xas_synth_new(XAS_AUDIO_STREAM_PCM_16_BIT, @@ -160,6 +160,6 @@ error_synth_new_r: error_synth_new_l: xas_audio_stream_destroy(wave); -error_riff_file_new: +error_riff_new_file: return EX_OSERR; } diff --git a/include/xas/riff.h b/include/xas/riff.h index 823a9ae..220eea2 100644 --- a/include/xas/riff.h +++ b/include/xas/riff.h @@ -49,13 +49,12 @@ typedef struct _xas_riff xas_riff; #pragma pack(pop) -xas_audio_stream *xas_riff_file_new(const char *path, +xas_audio_stream *xas_riff_new_file(const char *path, size_t sample_size, size_t sample_rate, size_t channels, int flags); -xas_audio_stream *xas_riff_file_open(const char *path, - int flags); +xas_audio_stream *xas_riff_open_file(const char *path, int flags); #endif /* _XAS_RIFF_H */ @@ -68,7 +68,7 @@ error_io: return -1; } -static xas_riff *file_new(const char *path, +static xas_riff *new_file(const char *path, size_t sample_size, size_t sample_rate, size_t channels, @@ -184,8 +184,7 @@ error_invalid_header_main_id: return -1; } -static xas_riff *file_open(const char *path, - int flags) { +static xas_riff *open_file(const char *path, int flags) { xas_riff *riff; xas_riff_wave_header header; @@ -239,7 +238,7 @@ error_malloc_riff: return NULL; } -static void file_close(xas_riff *riff, xas_audio_stream *stream) { +static void close_file(xas_riff *riff, xas_audio_stream *stream) { if (lseek(riff->fd, 0, SEEK_SET) < 0) { goto error_io; } @@ -297,7 +296,7 @@ error_read: return -1; } -xas_audio_stream *xas_riff_file_new(const char *path, +xas_audio_stream *xas_riff_new_file(const char *path, size_t sample_size, size_t sample_rate, size_t channels, @@ -305,17 +304,17 @@ xas_audio_stream *xas_riff_file_new(const char *path, xas_audio_stream *stream; xas_riff *riff; - if ((riff = file_new(path, + if ((riff = new_file(path, sample_size, sample_rate, channels, flags)) == NULL) { - goto error_file_new; + goto error_new_file; } if (flags & (O_RDWR | O_WRONLY)) { if ((stream = xas_audio_stream_new_sink((xas_audio_drain)audio_drain, - (xas_audio_cleanup)file_close, + (xas_audio_cleanup)close_file, riff, sample_size, sample_rate, @@ -325,7 +324,7 @@ xas_audio_stream *xas_riff_file_new(const char *path, } } else { if ((stream = xas_audio_stream_new_source((xas_audio_fill)audio_fill, - (xas_audio_cleanup)file_close, + (xas_audio_cleanup)close_file, riff, sample_size, sample_rate, @@ -338,24 +337,23 @@ xas_audio_stream *xas_riff_file_new(const char *path, return stream; error_audio_stream_new_sink: - file_close(riff, NULL); + close_file(riff, NULL); -error_file_new: +error_new_file: return NULL; } -xas_audio_stream *xas_riff_file_open(const char *path, - int flags) { +xas_audio_stream *xas_riff_open_file(const char *path, int flags) { xas_audio_stream *stream; xas_riff *riff; - if ((riff = file_open(path, flags)) == NULL) { - goto error_file_open; + if ((riff = open_file(path, flags)) == NULL) { + goto error_open_file; } if (flags & (O_RDWR | O_WRONLY)) { if ((stream = xas_audio_stream_new_sink((xas_audio_drain)audio_drain, - (xas_audio_cleanup)file_close, + (xas_audio_cleanup)close_file, riff, riff->sample_size, riff->sample_rate, @@ -365,7 +363,7 @@ xas_audio_stream *xas_riff_file_open(const char *path, } } else { if ((stream = xas_audio_stream_new_source((xas_audio_fill)audio_fill, - (xas_audio_cleanup)file_close, + (xas_audio_cleanup)close_file, riff, riff->sample_size, riff->sample_rate, @@ -378,8 +376,8 @@ xas_audio_stream *xas_riff_file_open(const char *path, return stream; error_audio_stream_new_sink: - file_close(riff, NULL); + close_file(riff, NULL); -error_file_open: +error_open_file: return NULL; } |