2 * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file afh.c Paraslash's standalone audio format handler tool. */
13 #include "afh.cmdline.h"
18 static struct afh_args_info conf
;
19 /** The list of all status items */
20 const char *status_item_list
[] = {STATUS_ITEM_ARRAY
};
23 INIT_STDERR_LOGGING(conf
.loglevel_arg
)
25 int main(int argc
, char **argv
)
28 void *audio_file_data
;
29 size_t audio_file_size
;
32 afh_cmdline_parser(argc
, argv
, &conf
);
33 HANDLE_VERSION_FLAG("afh", conf
);
35 if (conf
.inputs_num
!= 1)
38 ret
= mmap_full_file(conf
.inputs
[0], O_RDONLY
, &audio_file_data
,
39 &audio_file_size
, NULL
);
42 ret
= compute_afhi(conf
.inputs
[0], audio_file_data
, audio_file_size
, &afhi
);
45 printf("%s: %dkbit/s\n" /* bitrate */
46 "%s: %s\n" /* format */
47 "%s: %dHz\n" /* frequency */
48 "%s: %d\n" /* channels */
49 "%s: %lu\n" /* seconds total */
51 "%s: %lu: %lu\n" /* chunk time */
52 "%s: %lu\n", /* num chunks */
53 status_item_list
[SI_BITRATE
], afhi
.bitrate
,
54 status_item_list
[SI_FORMAT
], audio_format_name(ret
),
55 status_item_list
[SI_FREQUENCY
], afhi
.frequency
,
56 status_item_list
[SI_CHANNELS
], afhi
.channels
,
57 status_item_list
[SI_SECONDS_TOTAL
], afhi
.seconds_total
,
59 status_item_list
[SI_CHUNK_TIME
], (long unsigned)afhi
.chunk_tv
.tv_sec
,
60 (long unsigned)afhi
.chunk_tv
.tv_usec
,
61 status_item_list
[SI_NUM_CHUNKS
], afhi
.chunks_total
64 if (!conf
.chunk_table_given
)
66 printf("chunk_table: ");
67 for (i
= 0; i
<= afhi
.chunks_total
; i
++)
68 printf("%u ", afhi
.chunk_table
[i
]);
73 PARA_ERROR_LOG("%s\n", para_strerror(-ret
));
74 return ret
< 0? EXIT_FAILURE
: EXIT_SUCCESS
;