Mercurial > audlegacy-plugins
comparison src/madplug/decoder.c @ 2214:9a869d4bb0d3
make use of AUDDBG() for debug print out.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 06 Dec 2007 23:25:24 +0900 |
parents | 2f2ffbc2d04d |
children | d25cd7e7eddb |
comparison
equal
deleted
inserted
replaced
2213:137187e7a379 | 2214:9a869d4bb0d3 |
---|---|
194 if(info->fileinfo_request == TRUE) { | 194 if(info->fileinfo_request == TRUE) { |
195 aud_tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1); | 195 aud_tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1); |
196 info->fileinfo_request = FALSE; | 196 info->fileinfo_request = FALSE; |
197 } | 197 } |
198 | 198 |
199 #ifdef DEBUG | 199 AUDDBG("f: scan_file"); |
200 g_message("f: scan_file"); | 200 AUDDBG("scan_file frames = %d", info->frames); |
201 g_message("scan_file frames = %d", info->frames); | |
202 #endif /* DEBUG */ | |
203 | 201 |
204 while (1) { | 202 while (1) { |
205 remainder = stream.bufend - stream.next_frame; | 203 remainder = stream.bufend - stream.next_frame; |
206 | 204 |
207 /* | 205 /* |
214 memcpy(buffer, stream.this_frame, remainder); | 212 memcpy(buffer, stream.this_frame, remainder); |
215 len = input_get_data(info, buffer + remainder, | 213 len = input_get_data(info, buffer + remainder, |
216 BUFFER_SIZE - remainder); | 214 BUFFER_SIZE - remainder); |
217 | 215 |
218 if (len <= 0) { | 216 if (len <= 0) { |
219 #ifdef DEBUG | 217 AUDDBG("scan_file: len <= 0 len = %d", len); |
220 g_message("scan_file: len <= 0 len = %d", len); | |
221 #endif | |
222 break; | 218 break; |
223 } | 219 } |
224 | 220 |
225 mad_stream_buffer(&stream, buffer, len + remainder); | 221 mad_stream_buffer(&stream, buffer, len + remainder); |
226 | 222 |
228 if (mad_header_decode(&header, &stream) == -1) { | 224 if (mad_header_decode(&header, &stream) == -1) { |
229 if (stream.error == MAD_ERROR_BUFLEN) { | 225 if (stream.error == MAD_ERROR_BUFLEN) { |
230 break; | 226 break; |
231 } | 227 } |
232 if (!MAD_RECOVERABLE(stream.error)) { | 228 if (!MAD_RECOVERABLE(stream.error)) { |
233 #ifdef DEBUG | 229 AUDDBG("(fatal) error decoding header %d: %s", |
234 g_message("(fatal) error decoding header %d: %s", | |
235 info->frames, mad_stream_errorstr(&stream)); | 230 info->frames, mad_stream_errorstr(&stream)); |
236 g_message("remainder = %d", remainder); | 231 AUDDBG("remainder = %d", remainder); |
237 g_message("len = %d", len); | 232 AUDDBG("len = %d", len); |
238 #endif /* DEBUG */ | |
239 break; | 233 break; |
240 } | 234 } |
241 if (stream.error == MAD_ERROR_LOSTSYNC) { | 235 if (stream.error == MAD_ERROR_LOSTSYNC) { |
242 /* ignore LOSTSYNC due to ID3 tags */ | 236 /* ignore LOSTSYNC due to ID3 tags */ |
243 tagsize = id3_tag_query(stream.this_frame, | 237 tagsize = id3_tag_query(stream.this_frame, |
244 stream.bufend - | 238 stream.bufend - |
245 stream.this_frame); | 239 stream.this_frame); |
246 if (tagsize > 0) { | 240 if (tagsize > 0) { |
247 #ifdef DEBUG | 241 AUDDBG("skipping id3_tag: %d", tagsize); |
248 g_message("skipping id3_tag: %d", tagsize); | |
249 #endif /* DEBUG */ | |
250 mad_stream_skip(&stream, tagsize); | 242 mad_stream_skip(&stream, tagsize); |
251 continue; | 243 continue; |
252 } | 244 } |
253 } | 245 } |
254 #ifdef DEBUG | 246 |
255 g_message("(recovered) error decoding header %d: %s", | 247 AUDDBG("(recovered) error decoding header %d: %s", |
256 info->frames, mad_stream_errorstr(&stream)); | 248 info->frames, mad_stream_errorstr(&stream)); |
257 g_message("remainder = %d", remainder); | 249 AUDDBG("remainder = %d", remainder); |
258 g_message("len = %d", len); | 250 AUDDBG("len = %d", len); |
259 #endif /* DEBUG */ | 251 |
260 continue; | 252 continue; |
261 } | 253 } |
262 info->frames++; | 254 info->frames++; |
263 | 255 |
264 #ifdef DEBUG | |
265 #ifdef DEBUG_INTENSIVELY | 256 #ifdef DEBUG_INTENSIVELY |
266 g_message("header bitrate = %ld", header.bitrate); | 257 AUDDBG("header bitrate = %ld", header.bitrate); |
267 g_message("duration = %ul", | 258 AUDDBG("duration = %ul", |
268 mad_timer_count(header.duration, | 259 mad_timer_count(header.duration, |
269 MAD_UNITS_MILLISECONDS)); | 260 MAD_UNITS_MILLISECONDS)); |
270 g_message("size = %d", stream.next_frame - stream.this_frame); | 261 AUDDBG("size = %d", stream.next_frame - stream.this_frame); |
271 #endif | |
272 #endif | 262 #endif |
273 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) | 263 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) |
274 mad_timer_add(&info->duration, header.duration); | 264 mad_timer_add(&info->duration, header.duration); |
275 else { | 265 else { |
276 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL); | 266 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL); |
288 info->mode = header.mode; | 278 info->mode = header.mode; |
289 | 279 |
290 if (audmad_config.use_xing) { | 280 if (audmad_config.use_xing) { |
291 frame.header = header; | 281 frame.header = header; |
292 if (mad_frame_decode(&frame, &stream) == -1) { | 282 if (mad_frame_decode(&frame, &stream) == -1) { |
293 #ifdef DEBUG | 283 AUDDBG("xing frame decode failed"); |
294 g_message("xing frame decode failed"); | |
295 #endif | |
296 goto no_xing; | 284 goto no_xing; |
297 } | 285 } |
298 if (xing_parse(&info->xing, stream.anc_ptr, stream.anc_bitlen) == 0) { | 286 if (xing_parse(&info->xing, stream.anc_ptr, stream.anc_bitlen) == 0) { |
299 #ifdef DEBUG | 287 AUDDBG("xing header found "); |
300 g_message("xing header found "); | |
301 #endif /* DEBUG */ | |
302 has_xing = TRUE; | 288 has_xing = TRUE; |
303 info->vbr = TRUE; /* otherwise xing header would have been 'Info' */ | 289 info->vbr = TRUE; /* otherwise xing header would have been 'Info' */ |
304 | 290 |
305 #ifdef DEBUG | 291 AUDDBG("xing: bytes = %ld frames = %ld", info->xing.bytes, info->xing.frames); |
306 g_message("xing: bytes = %ld frames = %ld", info->xing.bytes, info->xing.frames); | 292 |
307 #endif | |
308 /* we have enough info to calculate bitrate and duration */ | 293 /* we have enough info to calculate bitrate and duration */ |
309 if(info->xing.bytes && info->xing.frames) { | 294 if(info->xing.bytes && info->xing.frames) { |
310 xing_bitrate = 8 * (double)info->xing.bytes * 38 / (double)info->xing.frames; //38fps in MPEG1. | 295 xing_bitrate = 8 * (double)info->xing.bytes * 38 / (double)info->xing.frames; //38fps in MPEG1. |
311 #ifdef DEBUG | 296 #ifdef AUD_DEBUG |
312 { | 297 { |
313 gint tmp = (gint)(info->xing.bytes * 8 / xing_bitrate); | 298 gint tmp = (gint)(info->xing.bytes * 8 / xing_bitrate); |
314 g_message("xing: bitrate = %4.1f kbps", xing_bitrate / 1000); | 299 AUDDBG("xing: bitrate = %4.1f kbps", xing_bitrate / 1000); |
315 g_message("xing: duration = %d:%02d", tmp / 60, tmp % 60); | 300 AUDDBG("xing: duration = %d:%02d", tmp / 60, tmp % 60); |
316 } | 301 } |
317 #endif | 302 #endif |
318 } | 303 } |
319 continue; | 304 continue; |
320 } | 305 } |
321 #ifdef DEBUG | 306 #ifdef AUD_DEBUG |
322 else { | 307 else { |
323 g_message("no usable xing header"); | 308 AUDDBG("no usable xing header"); |
324 continue; | 309 continue; |
325 } | 310 } |
326 | |
327 #endif | 311 #endif |
328 } /* xing */ | 312 } /* xing */ |
329 | 313 |
330 } | 314 } |
331 else { | 315 else { |
345 g_warning("number of channels varies!!"); | 329 g_warning("number of channels varies!!"); |
346 } | 330 } |
347 no_xing: | 331 no_xing: |
348 if (fast && info->frames >= N_AVERAGE_FRAMES) { | 332 if (fast && info->frames >= N_AVERAGE_FRAMES) { |
349 float frame_size = ((double) data_used) / N_AVERAGE_FRAMES; | 333 float frame_size = ((double) data_used) / N_AVERAGE_FRAMES; |
350 #ifdef DEBUG | 334 |
351 g_message("bitrate = %ld samplerate = %d", header.bitrate, header.samplerate); | 335 AUDDBG("bitrate = %ld samplerate = %d", header.bitrate, header.samplerate); |
352 g_message("data_used = %d info->frames = %d info->size = %d tagsize = %d frame_size = %lf", | 336 AUDDBG("data_used = %d info->frames = %d info->size = %d tagsize = %d frame_size = %lf", |
353 data_used, info->frames, info->size, tagsize, frame_size); | 337 data_used, info->frames, info->size, tagsize, frame_size); |
354 #endif | 338 |
355 if(info->size != 0) | 339 if(info->size != 0) |
356 info->frames = (info->size - tagsize) / frame_size; | 340 info->frames = (info->size - tagsize) / frame_size; |
357 #ifdef DEBUG | 341 |
358 g_message("info->frames = %d", info->frames); | 342 AUDDBG("info->frames = %d", info->frames); |
359 #endif | 343 |
360 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) { | 344 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) { |
361 if(xing_bitrate > 0.0) { | 345 if(xing_bitrate > 0.0) { |
362 /* calc duration with xing info */ | 346 /* calc duration with xing info */ |
363 double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate; | 347 double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate; |
364 info->duration.seconds = (guint)(tmp / 1000); | 348 info->duration.seconds = (guint)(tmp / 1000); |
374 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL); | 358 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL); |
375 | 359 |
376 info->duration.seconds = length / 1000; | 360 info->duration.seconds = length / 1000; |
377 info->duration.fraction = length % 1000; | 361 info->duration.fraction = length % 1000; |
378 } | 362 } |
379 #ifdef DEBUG | 363 #ifdef AUD_DEBUG |
380 g_message("using fast playtime calculation"); | 364 AUDDBG("using fast playtime calculation"); |
381 g_message("data used = %d [tagsize=%d framesize=%f]", | 365 AUDDBG("data used = %d [tagsize=%d framesize=%f]", |
382 data_used, tagsize, frame_size); | 366 data_used, tagsize, frame_size); |
383 g_message("frames = %d, frequency = %d, channels = %d", | 367 AUDDBG("frames = %d, frequency = %d, channels = %d", |
384 info->frames, info->freq, info->channels); | 368 info->frames, info->freq, info->channels); |
385 long millis = mad_timer_count(info->duration, | 369 long millis = mad_timer_count(info->duration, |
386 MAD_UNITS_MILLISECONDS); | 370 MAD_UNITS_MILLISECONDS); |
387 g_message("duration = %ld:%02ld", millis / 1000 / 60, (millis / 1000) % 60); | 371 AUDDBG("duration = %ld:%02ld", millis / 1000 / 60, (millis / 1000) % 60); |
388 #endif /* DEBUG */ | 372 #endif /* DEBUG */ |
389 break; | 373 break; |
390 } | 374 } |
391 } /* while */ | 375 } /* while */ |
392 if (stream.error != MAD_ERROR_BUFLEN) | 376 if (stream.error != MAD_ERROR_BUFLEN) |
406 mad_frame_finish(&frame); | 390 mad_frame_finish(&frame); |
407 mad_header_finish(&header); | 391 mad_header_finish(&header); |
408 mad_stream_finish(&stream); | 392 mad_stream_finish(&stream); |
409 xing_finish(&info->xing); | 393 xing_finish(&info->xing); |
410 | 394 |
411 #ifdef DEBUG | 395 AUDDBG("scan_file: info->frames = %d", info->frames); |
412 g_message("scan_file: info->frames = %d", info->frames); | 396 AUDDBG("e: scan_file"); |
413 g_message("e: scan_file"); | 397 |
414 #endif /* DEBUG */ | |
415 return (info->frames != 0 || info->remote == TRUE); | 398 return (info->frames != 0 || info->remote == TRUE); |
416 } | 399 } |
417 | 400 |
418 /* sanity check for audio open parameters */ | 401 /* sanity check for audio open parameters */ |
419 static gboolean check_audio_param(struct mad_info_t *info) | 402 static gboolean check_audio_param(struct mad_info_t *info) |
443 struct mad_synth synth; | 426 struct mad_synth synth; |
444 | 427 |
445 /* track info is passed in as thread argument */ | 428 /* track info is passed in as thread argument */ |
446 struct mad_info_t *info = (struct mad_info_t *) arg; | 429 struct mad_info_t *info = (struct mad_info_t *) arg; |
447 | 430 |
448 #ifdef DEBUG | 431 AUDDBG("f: decode"); |
449 g_message("f: decode"); | |
450 #endif /* DEBUG */ | |
451 | 432 |
452 /* init mad stuff */ | 433 /* init mad stuff */ |
453 mad_frame_init(&frame); | 434 mad_frame_init(&frame); |
454 mad_stream_init(&stream); | 435 mad_stream_init(&stream); |
455 mad_stream_options(&stream, MAD_OPTION_IGNORECRC); | 436 mad_stream_options(&stream, MAD_OPTION_IGNORECRC); |
456 mad_synth_init(&synth); | 437 mad_synth_init(&synth); |
457 | 438 |
458 if(!info->playback){ | 439 if(!info->playback){ |
459 #ifdef DEBUG | 440 AUDDBG("decode: playback == NULL"); |
460 g_message("decode: playback == NULL"); | |
461 #endif | |
462 return NULL; | 441 return NULL; |
463 } | 442 } |
464 | 443 |
465 #ifdef DEBUG | 444 AUDDBG("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); |
466 g_message("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); | |
467 #endif | |
468 | 445 |
469 if(check_audio_param(info) == FALSE) | 446 if(check_audio_param(info) == FALSE) |
470 return NULL; | 447 return NULL; |
471 | 448 |
472 if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) { | 449 if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) { |
487 | 464 |
488 tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS), | 465 tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS), |
489 info->playback->set_params(info->playback, info->title, | 466 info->playback->set_params(info->playback, info->title, |
490 (tlen == 0 || info->size <= 0) ? -1 : tlen, | 467 (tlen == 0 || info->size <= 0) ? -1 : tlen, |
491 info->bitrate, info->freq, info->channels); | 468 info->bitrate, info->freq, info->channels); |
492 #ifdef DEBUG | 469 |
493 g_message("decode: tlen = %d", tlen); | 470 AUDDBG("decode: tlen = %d", tlen); |
494 #endif | |
495 | 471 |
496 /* main loop */ | 472 /* main loop */ |
497 do { | 473 do { |
498 if (!info->playback->playing) { | 474 if (!info->playback->playing) { |
499 #ifdef DEBUG | 475 AUDDBG("decode: stop signaled"); |
500 g_message("decode: stop signaled"); | |
501 #endif /* DEBUG */ | |
502 break; | 476 break; |
503 } | 477 } |
504 if (seek_skip) | 478 if (seek_skip) |
505 remainder = 0; | 479 remainder = 0; |
506 else { | 480 else { |
511 BUFFER_SIZE - remainder); | 485 BUFFER_SIZE - remainder); |
512 | 486 |
513 input_process_remote_metadata(info); | 487 input_process_remote_metadata(info); |
514 | 488 |
515 if (len <= 0) { | 489 if (len <= 0) { |
516 #ifdef DEBUG | 490 AUDDBG("finished decoding"); |
517 g_message("finished decoding"); | |
518 #endif /* DEBUG */ | |
519 break; | 491 break; |
520 } | 492 } |
521 len += remainder; | 493 len += remainder; |
522 if (len < MAD_BUFFER_GUARD) { | 494 if (len < MAD_BUFFER_GUARD) { |
523 int i; | 495 int i; |
527 } | 499 } |
528 | 500 |
529 mad_stream_buffer(&stream, buffer, len); | 501 mad_stream_buffer(&stream, buffer, len); |
530 | 502 |
531 if (seek_skip) { | 503 if (seek_skip) { |
532 #ifdef DEBUG | 504 |
533 g_message("skipping: %d", seek_skip); | 505 AUDDBG("skipping: %d", seek_skip); |
534 #endif | 506 |
535 int skip = 2; | 507 int skip = 2; |
536 do { | 508 do { |
537 if (mad_frame_decode(&frame, &stream) == 0) { | 509 if (mad_frame_decode(&frame, &stream) == 0) { |
538 mad_timer_add(&info->pos, frame.header.duration); | 510 mad_timer_add(&info->pos, frame.header.duration); |
539 if (--skip == 0) | 511 if (--skip == 0) |
551 seek_skip = FALSE; | 523 seek_skip = FALSE; |
552 } | 524 } |
553 | 525 |
554 while (info->playback->playing) { | 526 while (info->playback->playing) { |
555 if (info->seek != -1 && info->size > 0) { | 527 if (info->seek != -1 && info->size > 0) { |
556 #ifdef DEBUG | 528 |
557 g_message("seeking: %ld", info->seek); | 529 AUDDBG("seeking: %ld", info->seek); |
558 #endif | 530 |
559 int new_position; | 531 int new_position; |
560 gulong milliseconds = | 532 gulong milliseconds = |
561 mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS); | 533 mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS); |
562 if (info->seek >= milliseconds) | 534 if (info->seek >= milliseconds) |
563 info->seek = milliseconds; | 535 info->seek = milliseconds; |
566 new_position = | 538 new_position = |
567 ((double) info->seek / (double) milliseconds) * info->size; | 539 ((double) info->seek / (double) milliseconds) * info->size; |
568 | 540 |
569 if(new_position < 0) | 541 if(new_position < 0) |
570 new_position = 0; | 542 new_position = 0; |
571 #ifdef DEBUG | 543 |
572 g_message("seeking to: %d bytes", new_position); | 544 AUDDBG("seeking to: %d bytes", new_position); |
573 #endif | 545 |
574 if (aud_vfs_fseek(info->infile, new_position, SEEK_SET) == -1) | 546 if (aud_vfs_fseek(info->infile, new_position, SEEK_SET) == -1) |
575 audmad_error("failed to seek to: %d", new_position); | 547 audmad_error("failed to seek to: %d", new_position); |
576 mad_frame_mute(&frame); | 548 mad_frame_mute(&frame); |
577 mad_synth_mute(&synth); | 549 mad_synth_mute(&synth); |
578 stream.error = MAD_ERROR_BUFLEN; | 550 stream.error = MAD_ERROR_BUFLEN; |
595 if (tagsize > 0) { | 567 if (tagsize > 0) { |
596 mad_stream_skip(&stream, tagsize); | 568 mad_stream_skip(&stream, tagsize); |
597 continue; | 569 continue; |
598 } | 570 } |
599 } | 571 } |
600 #ifdef DEBUG | 572 |
601 g_message("(recovered) error decoding header %d: %s", | 573 AUDDBG("(recovered) error decoding header %d: %s", |
602 info->current_frame, | 574 info->current_frame, |
603 mad_stream_errorstr(&stream)); | 575 mad_stream_errorstr(&stream)); |
604 #endif /* DEBUG */ | 576 |
605 continue; | 577 continue; |
606 } | 578 } |
607 | 579 |
608 info->bitrate = frame.header.bitrate; | 580 info->bitrate = frame.header.bitrate; |
609 | 581 |
610 if (!audmad_config.show_avg_vbr_bitrate && info->vbr && (iteration % 40 == 0)) { | 582 if (!audmad_config.show_avg_vbr_bitrate && info->vbr && (iteration % 40 == 0)) { |
611 #ifdef DEBUG | 583 |
612 #ifdef DEBUG_INTENSIVELY | 584 #ifdef DEBUG_INTENSIVELY |
613 g_message("decode vbr tlen = %d", tlen); | 585 AUDDBG("decode vbr tlen = %d", tlen); |
614 #endif | |
615 #endif | 586 #endif |
616 info->playback->set_params(info->playback, info->title, | 587 info->playback->set_params(info->playback, info->title, |
617 (tlen == 0 || info->size <= 0) ? -1 : tlen, | 588 (tlen == 0 || info->size <= 0) ? -1 : tlen, |
618 info->bitrate, info->freq, info->channels); | 589 info->bitrate, info->freq, info->channels); |
619 } | 590 } |
620 iteration++; | 591 iteration++; |
621 | 592 |
622 if (mad_frame_decode(&frame, &stream) == -1) { | 593 if (mad_frame_decode(&frame, &stream) == -1) { |
623 if (!MAD_RECOVERABLE(stream.error)) | 594 if (!MAD_RECOVERABLE(stream.error)) |
624 break; | 595 break; |
625 #ifdef DEBUG | 596 |
626 g_message("(recovered) error decoding frame %d: %s", | 597 AUDDBG("(recovered) error decoding frame %d: %s", |
627 info->current_frame, | 598 info->current_frame, |
628 mad_stream_errorstr(&stream)); | 599 mad_stream_errorstr(&stream)); |
629 #endif /* DEBUG */ | 600 |
630 } | 601 } |
631 | 602 |
632 info->current_frame++; | 603 info->current_frame++; |
633 | 604 |
634 if (info->freq != frame.header.samplerate | 605 if (info->freq != frame.header.samplerate |
635 || info->channels != | 606 || info->channels != |
636 (guint) MAD_NCHANNELS(&frame.header)) { | 607 (guint) MAD_NCHANNELS(&frame.header)) { |
637 #ifdef DEBUG | 608 |
638 g_message("change in audio type detected"); | 609 AUDDBG("change in audio type detected"); |
639 g_message("old: frequency = %d, channels = %d", info->freq, | 610 AUDDBG("old: frequency = %d, channels = %d", info->freq, |
640 info->channels); | 611 info->channels); |
641 g_message("new: frequency = %d, channels = %d", | 612 AUDDBG("new: frequency = %d, channels = %d", |
642 frame.header.samplerate, | 613 frame.header.samplerate, |
643 (guint) MAD_NCHANNELS(&frame.header)); | 614 (guint) MAD_NCHANNELS(&frame.header)); |
644 #endif /* DEBUG */ | 615 |
645 info->freq = frame.header.samplerate; | 616 info->freq = frame.header.samplerate; |
646 info->channels = MAD_NCHANNELS(&frame.header); | 617 info->channels = MAD_NCHANNELS(&frame.header); |
647 | 618 |
648 if(audmad_config.force_reopen_audio && check_audio_param(info)) { | 619 if(audmad_config.force_reopen_audio && check_audio_param(info)) { |
649 gint current_time = info->playback->output->output_time(); | 620 gint current_time = info->playback->output->output_time(); |
650 #ifdef DEBUG | 621 |
651 g_message("re-opening audio due to change in audio type"); | 622 AUDDBG("re-opening audio due to change in audio type"); |
652 #endif | 623 |
653 info->playback->output->close_audio(); | 624 info->playback->output->close_audio(); |
654 if (!info->playback->output->open_audio(info->fmt, info->freq, | 625 if (!info->playback->output->open_audio(info->fmt, info->freq, |
655 info->channels)) { | 626 info->channels)) { |
656 g_mutex_lock(pb_mutex); | 627 g_mutex_lock(pb_mutex); |
657 info->playback->error = TRUE; | 628 info->playback->error = TRUE; |
686 GTimeVal sleeptime; | 657 GTimeVal sleeptime; |
687 | 658 |
688 info->playback->output->buffer_free(); | 659 info->playback->output->buffer_free(); |
689 info->playback->output->buffer_free(); | 660 info->playback->output->buffer_free(); |
690 while (info->playback->output->buffer_playing()) { | 661 while (info->playback->output->buffer_playing()) { |
691 #ifdef DEBUG | 662 |
692 g_message("f: buffer_playing=%d", | 663 AUDDBG("f: buffer_playing=%d", info->playback->output->buffer_playing()); |
693 info->playback->output->buffer_playing()); | 664 |
694 #endif | |
695 g_get_current_time(&sleeptime); | 665 g_get_current_time(&sleeptime); |
696 g_time_val_add(&sleeptime, 500000); | 666 g_time_val_add(&sleeptime, 500000); |
697 | 667 |
698 g_mutex_lock(mad_mutex); | 668 g_mutex_lock(mad_mutex); |
699 g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime); | 669 g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime); |
702 break; | 672 break; |
703 } | 673 } |
704 | 674 |
705 } | 675 } |
706 } | 676 } |
707 #ifdef DEBUG | 677 |
708 g_message("e: decode"); | 678 AUDDBG("e: decode"); |
709 #endif /* DEBUG */ | |
710 | 679 |
711 aud_tuple_free(info->tuple); | 680 aud_tuple_free(info->tuple); |
712 info->tuple = NULL; | 681 info->tuple = NULL; |
713 | 682 |
714 info->playback->output->close_audio(); | 683 info->playback->output->close_audio(); |