Index: mplayer.c =================================================================== RCS file: /cvsroot/mplayer/main/mplayer.c,v retrieving revision 1.872 diff -u -r1.872 mplayer.c --- mplayer.c 19 Sep 2005 16:33:38 -0000 1.872 +++ mplayer.c 30 Sep 2005 13:25:11 -0000 @@ -1045,6 +1045,7 @@ int osd_show_percentage = 0; int osd_show_tv_channel = 25; int osd_show_ontop = 0; +int osd_show_audioid = 0; //LAva Extended int osd_show_rootwin = 0; int osd_show_framedropping = 0; int osd_show_status = 0; @@ -2332,7 +2333,114 @@ float aq_sleep_time=0; /*========================== PLAY AUDIO ============================*/ +/*LAVA Extended */ +if(sh_audio){ + //================== Init AUDIO (codec) ========================== + if (sh_audio->inited==-2) { + sh_audio->inited=0; + + // Go through the codec.conf and find the best codec... + current_module="init_audio_codec"; + mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n"); + + if(!init_best_audio_codec(sh_audio,audio_codec_list,audio_fm_list)){ + sh_audio=d_audio->sh=NULL; // failed to init :( + } else { + inited_flags|=INITED_ACODEC; + } + mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n"); + if(sh_audio){ + //const ao_info_t *info=audio_out->info; + current_module="af_preinit"; + ao_data.samplerate=force_srate?force_srate:sh_audio->samplerate*playback_speed; + ao_data.channels=audio_output_channels?audio_output_channels:sh_audio->channels; + ao_data.format=audio_output_format?audio_output_format:sh_audio->sample_format; + #if 1 + if(!preinit_audio_filters(sh_audio, + // input: + (int)(sh_audio->samplerate*playback_speed), + sh_audio->channels, sh_audio->sample_format, + // output: + &ao_data.samplerate, &ao_data.channels, &ao_data.format)){ + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError); + } + #endif + current_module="ao2_init"; + if(!(audio_out=init_best_audio_out(audio_driver_list, + 0, // plugin flag + force_srate?force_srate:ao_data.samplerate, + audio_output_channels?audio_output_channels:ao_data.channels, + audio_output_format?audio_output_format:ao_data.format,0))){ + // FAILED: + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); + uninit_player(INITED_ACODEC); // close codec + sh_audio=d_audio->sh=NULL; // -> nosound + } else { + // SUCCESS: + inited_flags|=INITED_AO; + mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s (%d bps)\n", + audio_out->info->short_name, + ao_data.samplerate, ao_data.channels, + af_fmt2str_short(ao_data.format), + af_fmt2bits(ao_data.format)/8 ); + mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n", + audio_out->info->name, audio_out->info->author); + if(strlen(audio_out->info->comment) > 0) + mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", audio_out->info->comment); + + // init audio filters: + #if 1 + current_module="af_init"; + if(!build_afilter_chain(sh_audio, &ao_data)) { + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter); + // mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format! -> NOSOUND\n"); + // uninit_player(INITED_ACODEC|INITED_AO); // close codec & ao + // sh_audio=d_audio->sh=NULL; // -> nosound + } + #endif + } + mixer.audio_out = audio_out; + mixer.volstep = volstep; + } + + current_module="av_init"; + + if(sh_video) sh_video->timer=0; + if(sh_audio) sh_audio->delay=-audio_delay; + + if(!sh_audio){ + mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); + mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks.\n",d_audio->packs); + ds_free_packs(d_audio); // free buffered chunks + d_audio->id=-2; // do not read audio chunks + //uninit_player(INITED_AO); // close device + } else { + if(demux_seek(demuxer,-1,0)){ + if(demux_seek(demuxer,0.8,0)) { + /* FIXME there should be real seeking for vobsub */ + if(sh_video) sh_video->pts=d_video->pts; + if (vo_vobsub) + vobsub_seek(vo_vobsub,sh_video->pts); + fflush(stdout); + if(sh_video){ + current_module="seek_video_reset"; + resync_video_stream(sh_video); + if(vo_config_count) video_out->control(VOCTRL_RESET,NULL); + } + + if(sh_audio){ + current_module="seek_audio_reset"; + audio_out->reset(); // stop audio, throwing away buffered data + } + } + d_audio=demuxer->audio; + osd_show_audioid=25; + } + } + } +} +/* LAva END */ while(sh_audio){ unsigned int t; double tt; @@ -3703,9 +3811,25 @@ mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos); } break; case MP_CMD_SWITCH_AUDIO : { + //LAva Extended Begin + if (sh_audio->inited!=-2) { + + sh_audio_t *sh_audio_tmp=NULL; + int v = demuxer_switch_audio(demuxer, cmd->args[0].v.i); if (identify) mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", v); + + sh_audio_tmp=demuxer->audio->sh; + if (sh_audio_tmp->inited==-2) { + mp_msg(MSGT_GLOBAL,MSGL_INFO,"SWITCH - AVI AUDIO Stream ... \n"); + audio_id = demuxer->audio->id; + uninit_player(INITED_ACODEC); + uninit_player(INITED_AO); + sh_audio=demuxer->audio->sh; + } + } + //LAva Extended End } break; case MP_CMD_RUN : { #ifndef __MINGW32__ @@ -4198,7 +4322,14 @@ } else if (osd_show_speed) { snprintf(osd_text_tmp, 63, "Speed: x %6.2f", playback_speed); osd_show_speed--; - } else if (osd_show_ontop) { + } else +//LAva Extended Begin + if (osd_show_audioid>0) { + snprintf(osd_text_tmp, 63, "Audiostream: %d",d_audio->id); + osd_show_audioid--; + } else +//LAva Extended End + if (osd_show_ontop) { snprintf(osd_text_tmp, 63, "Stay on top: %sabled", vo_ontop?"en":"dis"); osd_show_ontop--; } else if (osd_show_rootwin) { Index: libmpdemux/demux_avi.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v retrieving revision 1.67 diff -u -r1.67 demux_avi.c --- libmpdemux/demux_avi.c 13 Sep 2005 18:12:48 -0000 1.67 +++ libmpdemux/demux_avi.c 30 Sep 2005 13:25:23 -0000 @@ -834,6 +834,7 @@ demux_stream_t *d_video=demuxer->video; /* sh_audio_t *sh_audio=d_audio->sh;*/ sh_video_t *sh_video=d_video->sh; + sh_audio_t* sh; //LAva Extended @@ -851,7 +852,65 @@ *((int *)arg)=(int)(priv->video_pack_no*100/priv->numberofframes); if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS; return DEMUXER_CTRL_OK; - +//LAva Extended + case DEMUXER_CTRL_SWITCH_AUDIO: + { + sh_audio_t *sh_audio=NULL; + int stream_id=demuxer->audio->id; + int stream_id_old=stream_id; +// free_demuxer_stream(demuxer->audio); + + if(stream_id>=0 && demuxer->a_streams[stream_id+1]){ + stream_id+=1; + } else if (stream_id>=0 && demuxer->a_streams[1]) { + stream_id=1; + } else { + stream_id=-2; + } + + //mp_msg(MSGT_GLOBAL,MSGL_INFO,"Auto-selected AVI audio ID = %d\n",stream_id); + if (stream_id!=-2 && stream_id_old!=stream_id) { + avi_priv_t *priv = demuxer->priv; + + priv->audio_block_no=0; + priv->audio_block_size=0; + + free_demuxer_stream(demuxer->audio); + demux_stream_t *d_audio = new_demuxer_stream(demuxer,stream_id); + + demuxer->audio->sh=NULL; + if(!demuxer->audio->sh){ + sh=demuxer->a_streams[stream_id]; + if(sh->wf){ + priv->audio_block_size=sh->wf->nBlockAlign; + if(!priv->audio_block_size){ + if(sh->format==1) + priv->audio_block_size=sh->wf->nChannels*(sh->wf->wBitsPerSample/8); + else + priv->audio_block_size=1; // hope the best... + } else { + if(sh->audio.dwSampleSize==1 && sh->audio.dwScale==1 && + (sh->wf->nBlockAlign==1152 || sh->wf->nBlockAlign==576)){ + priv->audio_block_size=1; + } + } + } else { + priv->audio_block_size=sh->audio.dwSampleSize; + } + sh->format=sh->wf->wFormatTag; + sh_audio=sh; + } + priv->pts_corrected=0; + demuxer->priv=priv; + sh_audio->inited=-2; + sh_audio->ds=d_audio; + d_audio->sh=sh_audio; + demuxer->audio=d_audio; + ds_fill_buffer(demuxer->audio); + } + return DEMUXER_CTRL_OK; + } +//LAva End default: return DEMUXER_CTRL_NOTIMPL; }