mirror of https://gerrit.osmocom.org/gapk
print meaningful error messages if something goes wrong in main/pq
This commit is contained in:
parent
8b01f0ca05
commit
495c694781
31
src/main.c
31
src/main.c
|
@ -440,8 +440,10 @@ make_processing_chain(struct gapk_state *gs)
|
|||
else if (gs->opts.alsa_in)
|
||||
pq_queue_alsa_input(gs->pq, gs->opts.alsa_in, fmt_in->frame_len);
|
||||
#endif
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "Unknown/invalid input\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Decoding to PCM ? */
|
||||
if (need_dec)
|
||||
|
@ -452,8 +454,11 @@ make_processing_chain(struct gapk_state *gs)
|
|||
const struct format_desc *fmt_dec;
|
||||
|
||||
fmt_dec = fmt_get_from_type(codec_in->codec_dec_format_type);
|
||||
if (!fmt_dec)
|
||||
if (!fmt_dec) {
|
||||
fprintf(stderr, "Cannot determine decoder input format for codec %s\n",
|
||||
codec_in->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pq_queue_fmt_convert(gs->pq, fmt_in, 0);
|
||||
pq_queue_fmt_convert(gs->pq, fmt_dec, 1);
|
||||
|
@ -480,8 +485,11 @@ make_processing_chain(struct gapk_state *gs)
|
|||
const struct format_desc *fmt_enc;
|
||||
|
||||
fmt_enc = fmt_get_from_type(codec_out->codec_enc_format_type);
|
||||
if (!fmt_enc)
|
||||
if (!fmt_enc) {
|
||||
fprintf(stderr, "Cannot determine encoder output format for codec %s\n",
|
||||
codec_out->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pq_queue_fmt_convert(gs->pq, fmt_enc, 0);
|
||||
pq_queue_fmt_convert(gs->pq, fmt_out, 1);
|
||||
|
@ -502,8 +510,10 @@ make_processing_chain(struct gapk_state *gs)
|
|||
else if (gs->opts.alsa_out)
|
||||
pq_queue_alsa_output(gs->pq, gs->opts.alsa_out, fmt_out->frame_len);
|
||||
#endif
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "Unknown/invalid output\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -569,23 +579,30 @@ int main(int argc, char *argv[])
|
|||
gs->pq = pq_create();
|
||||
if (!gs->pq) {
|
||||
rv = -ENOMEM;
|
||||
fprintf(stderr, "Error creating processing queue\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Open source / destination files */
|
||||
rv = files_open(gs);
|
||||
if (rv)
|
||||
if (rv) {
|
||||
fprintf(stderr, "Error opening file(s)\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Handle input/output headers */
|
||||
rv = handle_headers(gs);
|
||||
if (rv)
|
||||
if (rv) {
|
||||
fprintf(stderr, "Error handling header(s)\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Make processing chain */
|
||||
rv = make_processing_chain(gs);
|
||||
if (rv)
|
||||
if (rv) {
|
||||
fprintf(stderr, "Error making processing chain\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
signal(SIGINT, &signal_handler);
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n
|
|||
struct pq_item *item;
|
||||
const struct codec_desc *codec = codec_get_from_type(fmt->codec_type);
|
||||
|
||||
if (!codec)
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Cannot determine codec from format %s\n", fmt->name);
|
||||
return -EINVAL;
|
||||
|
||||
item = pq_add_item(pq);
|
||||
|
|
|
@ -72,8 +72,11 @@ pq_add_item(struct pq *pq)
|
|||
{
|
||||
struct pq_item *item;
|
||||
|
||||
if (pq->n_items == MAX_PQ_ITEMS)
|
||||
if (pq->n_items == MAX_PQ_ITEMS) {
|
||||
fprintf(stderr, "Processing Queue cannot handle more than %u items\n",
|
||||
MAX_PQ_ITEMS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = calloc(1, sizeof(struct pq_item));
|
||||
if (!item)
|
||||
|
@ -98,8 +101,11 @@ pq_prepare(struct pq *pq)
|
|||
for (i=0; i<pq->n_items; i++) {
|
||||
struct pq_item *item = pq->items[i];
|
||||
|
||||
if (item->len_in && item->len_in != len_prev)
|
||||
if (item->len_in && item->len_in != len_prev) {
|
||||
fprintf(stderr, "PQ item requires input size %u, but previous output is %u\n",
|
||||
item->len_in, len_prev);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (i < (pq->n_items-1)) {
|
||||
unsigned int buf_size = item->len_out;
|
||||
|
|
Loading…
Reference in New Issue