Revision f8b8c694

View differences:

ffplay.c
167 167
    enum AVSampleFormat audio_src_fmt;
168 168
    AVAudioConvert *reformat_ctx;
169 169

  
170
    int show_audio; /* if true, display audio samples */
170
    enum {
171
        SHOW_MODE_VIDEO = 0, SHOW_MODE_WAVES, SHOW_MODE_RDFT, SHOW_MODE_NB
172
    } show_mode;
171 173
    int16_t sample_array[SAMPLE_ARRAY_SIZE];
172 174
    int sample_array_index;
173 175
    int last_i_start;
......
789 791
    channels = s->audio_st->codec->channels;
790 792
    nb_display_channels = channels;
791 793
    if (!s->paused) {
792
        int data_used= s->show_audio==1 ? s->width : (2*nb_freq);
794
        int data_used= s->show_mode == SHOW_MODE_WAVES ? s->width : (2*nb_freq);
793 795
        n = 2 * channels;
794 796
        delay = audio_write_get_buf_size(s);
795 797
        delay /= n;
......
806 808
            delay = data_used;
807 809

  
808 810
        i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
809
        if(s->show_audio==1){
811
        if (s->show_mode == SHOW_MODE_WAVES) {
810 812
            h= INT_MIN;
811 813
            for(i=0; i<1000; i+=channels){
812 814
                int idx= (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
......
828 830
    }
829 831

  
830 832
    bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
831
    if(s->show_audio==1){
833
    if (s->show_mode == SHOW_MODE_WAVES) {
832 834
        fill_rectangle(screen,
833 835
                       s->xleft, s->ytop, s->width, s->height,
834 836
                       bgcolor);
......
968 970
{
969 971
    if(!screen)
970 972
        video_open(cur_stream);
971
    if (is->audio_st && is->show_audio)
973
    if (is->audio_st && is->show_mode != SHOW_MODE_VIDEO)
972 974
        video_audio_display(is);
973 975
    else if (is->video_st)
974 976
        video_image_display(is);
......
985 987
            is->refresh=1;
986 988
            SDL_PushEvent(&event);
987 989
        }
988
        usleep(is->audio_st && is->show_audio ? rdftspeed*1000 : 5000); //FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly
990
        //FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly
991
        usleep(is->audio_st && is->show_mode != SHOW_MODE_VIDEO ? rdftspeed*1000 : 5000);
989 992
    }
990 993
    return 0;
991 994
}
......
2165 2168
               is->audio_buf_size = 1024;
2166 2169
               memset(is->audio_buf, 0, is->audio_buf_size);
2167 2170
           } else {
2168
               if (is->show_audio)
2171
               if (is->show_mode != SHOW_MODE_VIDEO)
2169 2172
                   update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
2170 2173
               audio_size = synchronize_audio(is, (int16_t *)is->audio_buf, audio_size,
2171 2174
                                              pts);
......
2470 2473
    is->refresh_tid = SDL_CreateThread(refresh_thread, is);
2471 2474
    if(ret<0) {
2472 2475
        if (!display_disable)
2473
            is->show_audio = 2;
2476
            is->show_mode = SHOW_MODE_RDFT;
2474 2477
    }
2475 2478

  
2476 2479
    if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) {
......
2725 2728
{
2726 2729
    if (cur_stream) {
2727 2730
        int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
2728
        cur_stream->show_audio = (cur_stream->show_audio + 1) % 3;
2731
        cur_stream->show_mode = (cur_stream->show_mode + 1) % SHOW_MODE_NB;
2729 2732
        fill_rectangle(screen,
2730 2733
                    cur_stream->xleft, cur_stream->ytop, cur_stream->width, cur_stream->height,
2731 2734
                    bgcolor);

Also available in: Unified diff