summaryrefslogtreecommitdiff
path: root/apps/codecs/libmad/decoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libmad/decoder.c')
-rw-r--r--apps/codecs/libmad/decoder.c190
1 files changed, 95 insertions, 95 deletions
diff --git a/apps/codecs/libmad/decoder.c b/apps/codecs/libmad/decoder.c
index dfa45aaa34..46f4dfe5f7 100644
--- a/apps/codecs/libmad/decoder.c
+++ b/apps/codecs/libmad/decoder.c
@@ -51,25 +51,25 @@
51# include "decoder.h" 51# include "decoder.h"
52 52
53/* 53/*
54 * NAME: decoder->init() 54 * NAME: decoder->init()
55 * DESCRIPTION: initialize a decoder object with callback routines 55 * DESCRIPTION: initialize a decoder object with callback routines
56 */ 56 */
57void mad_decoder_init(struct mad_decoder *decoder, void *data, 57void mad_decoder_init(struct mad_decoder *decoder, void *data,
58 enum mad_flow (*input_func)(void *, 58 enum mad_flow (*input_func)(void *,
59 struct mad_stream *), 59 struct mad_stream *),
60 enum mad_flow (*header_func)(void *, 60 enum mad_flow (*header_func)(void *,
61 struct mad_header const *), 61 struct mad_header const *),
62 enum mad_flow (*filter_func)(void *, 62 enum mad_flow (*filter_func)(void *,
63 struct mad_stream const *, 63 struct mad_stream const *,
64 struct mad_frame *), 64 struct mad_frame *),
65 enum mad_flow (*output_func)(void *, 65 enum mad_flow (*output_func)(void *,
66 struct mad_header const *, 66 struct mad_header const *,
67 struct mad_pcm *), 67 struct mad_pcm *),
68 enum mad_flow (*error_func)(void *, 68 enum mad_flow (*error_func)(void *,
69 struct mad_stream *, 69 struct mad_stream *,
70 struct mad_frame *), 70 struct mad_frame *),
71 enum mad_flow (*message_func)(void *, 71 enum mad_flow (*message_func)(void *,
72 void *, unsigned int *)) 72 void *, unsigned int *))
73{ 73{
74 decoder->mode = -1; 74 decoder->mode = -1;
75 75
@@ -237,9 +237,9 @@ enum mad_flow receive(int fd, void **message, unsigned int *size)
237 237
238 if (*size > 0) { 238 if (*size > 0) {
239 if (*message == 0) { 239 if (*message == 0) {
240 *message = malloc(*size); 240 *message = malloc(*size);
241 if (*message == 0) 241 if (*message == 0)
242 return MAD_FLOW_BREAK; 242 return MAD_FLOW_BREAK;
243 } 243 }
244 244
245 result = receive_io_blocking(fd, *message, *size); 245 result = receive_io_blocking(fd, *message, *size);
@@ -278,8 +278,8 @@ enum mad_flow check_message(struct mad_decoder *decoder)
278 result = decoder->message_func(decoder->cb_data, message, &size); 278 result = decoder->message_func(decoder->cb_data, message, &size);
279 279
280 if (result == MAD_FLOW_IGNORE || 280 if (result == MAD_FLOW_IGNORE ||
281 result == MAD_FLOW_BREAK) 281 result == MAD_FLOW_BREAK)
282 size = 0; 282 size = 0;
283 } 283 }
284 284
285 if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) 285 if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE)
@@ -295,7 +295,7 @@ enum mad_flow check_message(struct mad_decoder *decoder)
295 295
296static 296static
297enum mad_flow error_default(void *data, struct mad_stream *stream, 297enum mad_flow error_default(void *data, struct mad_stream *stream,
298 struct mad_frame *frame) 298 struct mad_frame *frame)
299{ 299{
300 int *bad_last_frame = data; 300 int *bad_last_frame = data;
301 301
@@ -361,92 +361,92 @@ int run_sync(struct mad_decoder *decoder)
361 while (1) { 361 while (1) {
362# if defined(USE_ASYNC) 362# if defined(USE_ASYNC)
363 if (decoder->mode == MAD_DECODER_MODE_ASYNC) { 363 if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
364 switch (check_message(decoder)) { 364 switch (check_message(decoder)) {
365 case MAD_FLOW_IGNORE: 365 case MAD_FLOW_IGNORE:
366 case MAD_FLOW_CONTINUE: 366 case MAD_FLOW_CONTINUE:
367 break; 367 break;
368 case MAD_FLOW_BREAK: 368 case MAD_FLOW_BREAK:
369 goto fail; 369 goto fail;
370 case MAD_FLOW_STOP: 370 case MAD_FLOW_STOP:
371 goto done; 371 goto done;
372 } 372 }
373 } 373 }
374# endif 374# endif
375 375
376 if (decoder->header_func) { 376 if (decoder->header_func) {
377 if (mad_header_decode(&frame->header, stream) == -1) { 377 if (mad_header_decode(&frame->header, stream) == -1) {
378 if (!MAD_RECOVERABLE(stream->error)) 378 if (!MAD_RECOVERABLE(stream->error))
379 break; 379 break;
380 380
381 switch (error_func(error_data, stream, frame)) { 381 switch (error_func(error_data, stream, frame)) {
382 case MAD_FLOW_STOP: 382 case MAD_FLOW_STOP:
383 goto done; 383 goto done;
384 case MAD_FLOW_BREAK: 384 case MAD_FLOW_BREAK:
385 goto fail; 385 goto fail;
386 case MAD_FLOW_IGNORE: 386 case MAD_FLOW_IGNORE:
387 case MAD_FLOW_CONTINUE: 387 case MAD_FLOW_CONTINUE:
388 default: 388 default:
389 continue; 389 continue;
390 } 390 }
391 } 391 }
392 392
393 switch (decoder->header_func(decoder->cb_data, &frame->header)) { 393 switch (decoder->header_func(decoder->cb_data, &frame->header)) {
394 case MAD_FLOW_STOP: 394 case MAD_FLOW_STOP:
395 goto done; 395 goto done;
396 case MAD_FLOW_BREAK: 396 case MAD_FLOW_BREAK:
397 goto fail; 397 goto fail;
398 case MAD_FLOW_IGNORE: 398 case MAD_FLOW_IGNORE:
399 continue; 399 continue;
400 case MAD_FLOW_CONTINUE: 400 case MAD_FLOW_CONTINUE:
401 break; 401 break;
402 } 402 }
403 } 403 }
404 404
405 if (mad_frame_decode(frame, stream) == -1) { 405 if (mad_frame_decode(frame, stream) == -1) {
406 if (!MAD_RECOVERABLE(stream->error)) 406 if (!MAD_RECOVERABLE(stream->error))
407 break; 407 break;
408 408
409 switch (error_func(error_data, stream, frame)) { 409 switch (error_func(error_data, stream, frame)) {
410 case MAD_FLOW_STOP: 410 case MAD_FLOW_STOP:
411 goto done; 411 goto done;
412 case MAD_FLOW_BREAK: 412 case MAD_FLOW_BREAK:
413 goto fail; 413 goto fail;
414 case MAD_FLOW_IGNORE: 414 case MAD_FLOW_IGNORE:
415 break; 415 break;
416 case MAD_FLOW_CONTINUE: 416 case MAD_FLOW_CONTINUE:
417 default: 417 default:
418 continue; 418 continue;
419 } 419 }
420 } 420 }
421 else 421 else
422 bad_last_frame = 0; 422 bad_last_frame = 0;
423 423
424 if (decoder->filter_func) { 424 if (decoder->filter_func) {
425 switch (decoder->filter_func(decoder->cb_data, stream, frame)) { 425 switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
426 case MAD_FLOW_STOP: 426 case MAD_FLOW_STOP:
427 goto done; 427 goto done;
428 case MAD_FLOW_BREAK: 428 case MAD_FLOW_BREAK:
429 goto fail; 429 goto fail;
430 case MAD_FLOW_IGNORE: 430 case MAD_FLOW_IGNORE:
431 continue; 431 continue;
432 case MAD_FLOW_CONTINUE: 432 case MAD_FLOW_CONTINUE:
433 break; 433 break;
434 } 434 }
435 } 435 }
436 436
437 mad_synth_frame(synth, frame); 437 mad_synth_frame(synth, frame);
438 438
439 if (decoder->output_func) { 439 if (decoder->output_func) {
440 switch (decoder->output_func(decoder->cb_data, 440 switch (decoder->output_func(decoder->cb_data,
441 &frame->header, &synth->pcm)) { 441 &frame->header, &synth->pcm)) {
442 case MAD_FLOW_STOP: 442 case MAD_FLOW_STOP:
443 goto done; 443 goto done;
444 case MAD_FLOW_BREAK: 444 case MAD_FLOW_BREAK:
445 goto fail; 445 goto fail;
446 case MAD_FLOW_IGNORE: 446 case MAD_FLOW_IGNORE:
447 case MAD_FLOW_CONTINUE: 447 case MAD_FLOW_CONTINUE:
448 break; 448 break;
449 } 449 }
450 } 450 }
451 } 451 }
452 } 452 }
@@ -528,7 +528,7 @@ int run_async(struct mad_decoder *decoder)
528# endif 528# endif
529 529
530/* 530/*
531 * NAME: decoder->run() 531 * NAME: decoder->run()
532 * DESCRIPTION: run the decoder thread either synchronously or asynchronously 532 * DESCRIPTION: run the decoder thread either synchronously or asynchronously
533 */ 533 */
534int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) 534int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
@@ -564,11 +564,11 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
564} 564}
565 565
566/* 566/*
567 * NAME: decoder->message() 567 * NAME: decoder->message()
568 * DESCRIPTION: send a message to and receive a reply from the decoder process 568 * DESCRIPTION: send a message to and receive a reply from the decoder process
569 */ 569 */
570int mad_decoder_message(struct mad_decoder *decoder, 570int mad_decoder_message(struct mad_decoder *decoder,
571 void *message, unsigned int *len) 571 void *message, unsigned int *len)
572{ 572{
573# if defined(USE_ASYNC) 573# if defined(USE_ASYNC)
574 if (decoder->mode != MAD_DECODER_MODE_ASYNC || 574 if (decoder->mode != MAD_DECODER_MODE_ASYNC ||