| 314 | } |
| 315 | |
| 316 | static |
| 317 | int run_sync(struct mad_decoder *decoder) |
| 318 | { |
| 319 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); |
| 320 | void *error_data; |
| 321 | int bad_last_frame = 0; |
| 322 | struct mad_stream *stream; |
| 323 | struct mad_frame *frame; |
| 324 | struct mad_synth *synth; |
| 325 | int result = 0; |
| 326 | stack(__FUNCTION__, __FILE__, __LINE__); |
| 327 | |
| 328 | if (decoder->input_func == 0) |
| 329 | return 0; |
| 330 | |
| 331 | if (decoder->error_func) { |
| 332 | error_func = decoder->error_func; |
| 333 | error_data = decoder->cb_data; |
| 334 | } |
| 335 | else { |
| 336 | error_func = error_default; |
| 337 | error_data = &bad_last_frame; |
| 338 | } |
| 339 | |
| 340 | stream = &decoder->sync->stream; |
| 341 | frame = &decoder->sync->frame; |
| 342 | synth = &decoder->sync->synth; |
| 343 | |
| 344 | mad_stream_init(stream); |
| 345 | mad_frame_init(frame); |
| 346 | mad_synth_init(synth); |
| 347 | |
| 348 | mad_stream_options(stream, decoder->options); |
| 349 | |
| 350 | do { |
| 351 | switch (decoder->input_func(decoder->cb_data, stream)) { |
| 352 | case MAD_FLOW_STOP: |
| 353 | goto done; |
| 354 | case MAD_FLOW_BREAK: |
| 355 | goto fail; |
| 356 | case MAD_FLOW_IGNORE: |
| 357 | continue; |
| 358 | case MAD_FLOW_CONTINUE: |
| 359 | break; |
| 360 | } |
| 361 | |
| 362 | while (1) { |
| 363 | # if defined(USE_ASYNC) |
| 364 | if (decoder->mode == MAD_DECODER_MODE_ASYNC) { |
| 365 | switch (check_message(decoder)) { |
| 366 | case MAD_FLOW_IGNORE: |
| 367 | case MAD_FLOW_CONTINUE: |
| 368 | break; |
| 369 | case MAD_FLOW_BREAK: |
| 370 | goto fail; |
| 371 | case MAD_FLOW_STOP: |
| 372 | goto done; |
| 373 | } |
no test coverage detected