Revision 51b73087 ffplay.c

View differences:

ffplay.c
1693 1693

  
1694 1694
    /* prepare audio output */
1695 1695
    if (enc->codec_type == CODEC_TYPE_AUDIO) {
1696
        wanted_spec.freq = enc->sample_rate;
1697
        wanted_spec.format = AUDIO_S16SYS;
1698
        if(enc->channels > 2) {
1699
            wanted_spec.channels = 2;
1700
            enc->request_channels = 2;
1696
        if (enc->channels > 0) {
1697
            enc->request_channels = FFMIN(2, enc->channels);
1701 1698
        } else {
1702
            wanted_spec.channels = enc->channels;
1703
        }
1704
        wanted_spec.silence = 0;
1705
        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
1706
        wanted_spec.callback = sdl_audio_callback;
1707
        wanted_spec.userdata = is;
1708
        if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
1709
            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
1710
            return -1;
1699
            enc->request_channels = 2;
1711 1700
        }
1712
        is->audio_hw_buf_size = spec.size;
1713 1701
    }
1714 1702

  
1715 1703
    codec = avcodec_find_decoder(enc->codec_id);
......
1728 1716
    if (!codec ||
1729 1717
        avcodec_open(enc, codec) < 0)
1730 1718
        return -1;
1719

  
1720
    /* prepare audio output */
1721
    if (enc->codec_type == CODEC_TYPE_AUDIO) {
1722
        wanted_spec.freq = enc->sample_rate;
1723
        wanted_spec.format = AUDIO_S16SYS;
1724
        wanted_spec.channels = enc->channels;
1725
        wanted_spec.silence = 0;
1726
        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
1727
        wanted_spec.callback = sdl_audio_callback;
1728
        wanted_spec.userdata = is;
1729
        if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
1730
            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
1731
            return -1;
1732
        }
1733
        is->audio_hw_buf_size = spec.size;
1734
    }
1735

  
1731 1736
    if(thread_count>1)
1732 1737
        avcodec_thread_init(enc, thread_count);
1733 1738
    enc->thread_count= thread_count;

Also available in: Unified diff