comparison src/madplug/decoder.c @ 916:a8494c2a87eb trunk

[svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it. - 1. time count will be recorded and restored on reopen. this seems to be right way, but it causes a short stoppage of playback. - 2. introduce a new plugin option "force_reopen_audio". if this is set to FALSE (default), decoder will not reopen output. this is a bit rude, but does not cause any interruption.
author yaz
date Thu, 05 Apr 2007 21:12:59 -0700
parents f0846bdd9de6
children f931c9d744a5
comparison
equal deleted inserted replaced
915:1ccc7a9c7fc2 916:a8494c2a87eb
594 594
595 if (info->freq != frame.header.samplerate 595 if (info->freq != frame.header.samplerate
596 || info->channels != 596 || info->channels !=
597 (guint) MAD_NCHANNELS(&frame.header)) { 597 (guint) MAD_NCHANNELS(&frame.header)) {
598 #ifdef DEBUG 598 #ifdef DEBUG
599 g_message("re-opening audio due to change in audio type"); 599 g_message("change in audio type detected");
600 g_message("old: frequency = %d, channels = %d", info->freq, 600 g_message("old: frequency = %d, channels = %d", info->freq,
601 info->channels); 601 info->channels);
602 g_message("new: frequency = %d, channels = %d", 602 g_message("new: frequency = %d, channels = %d",
603 frame.header.samplerate, 603 frame.header.samplerate,
604 (guint) MAD_NCHANNELS(&frame.header)); 604 (guint) MAD_NCHANNELS(&frame.header));
605 #endif /* DEBUG */ 605 #endif /* DEBUG */
606 info->freq = frame.header.samplerate; 606 info->freq = frame.header.samplerate;
607 info->channels = MAD_NCHANNELS(&frame.header); 607 info->channels = MAD_NCHANNELS(&frame.header);
608 info->playback->output->close_audio(); 608
609 609 if(audmad_config.force_reopen_audio && check_audio_param(info)) {
610 if(check_audio_param(info) == FALSE) 610 gint current_time = info->playback->output->output_time();
611 return NULL; 611 #ifdef DEBUG
612 612 g_message("re-opening audio due to change in audio type");
613 if (!info->playback->output->open_audio(info->fmt, info->freq, 613 #endif
614 info->channels)) { 614 info->playback->output->close_audio();
615 g_mutex_lock(pb_mutex); 615 if (!info->playback->output->open_audio(info->fmt, info->freq,
616 info->playback->error = TRUE; 616 info->channels)) {
617 info->playback->eof = 1; 617 g_mutex_lock(pb_mutex);
618 g_mutex_unlock(pb_mutex); 618 info->playback->error = TRUE;
619 g_message("failed to re-open audio output: %s", 619 info->playback->eof = 1;
620 g_mutex_unlock(pb_mutex);
621 g_message("failed to re-open audio output: %s",
620 info->playback->output->description); 622 info->playback->output->description);
621 return NULL; 623 return NULL;
622 } 624 }
623 } 625 // restore time and advance 0.5sec
626 info->seek = current_time + 500;
627 }
628 }
629
624 if (!info->playback->playing) 630 if (!info->playback->playing)
625 break; 631 break;
626 mad_synth_frame(&synth, &frame); 632 mad_synth_frame(&synth, &frame);
627 mad_stream_sync(&stream); 633 mad_stream_sync(&stream);
628 634