diff options
-rw-r--r-- | DOCS/man/en/options.rst | 4 | ||||
-rw-r--r-- | audio/out/ao.c | 3 | ||||
-rw-r--r-- | audio/out/ao.h | 8 | ||||
-rw-r--r-- | audio/out/ao_alsa.c | 16 | ||||
-rw-r--r-- | audio/out/ao_coreaudio.c | 6 | ||||
-rw-r--r-- | audio/out/ao_dsound.c | 14 | ||||
-rw-r--r-- | audio/out/ao_jack.c | 8 | ||||
-rw-r--r-- | audio/out/ao_lavc.c | 10 | ||||
-rw-r--r-- | audio/out/ao_null.c | 16 | ||||
-rw-r--r-- | audio/out/ao_openal.c | 2 | ||||
-rw-r--r-- | audio/out/ao_oss.c | 47 | ||||
-rw-r--r-- | audio/out/ao_pcm.c | 3 | ||||
-rw-r--r-- | audio/out/ao_sdl.c | 4 | ||||
-rw-r--r-- | core/mplayer.c | 1 | ||||
-rw-r--r-- | core/options.c | 3 | ||||
-rw-r--r-- | core/options.h | 1 |
16 files changed, 64 insertions, 82 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 2d50da0045..34efa3c4bd 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1,7 +1,3 @@ ---abs=<value> - (``--ao=oss`` only) (OBSOLETE) - Override audio driver/card buffer size detection. - --ad=<[+|-]family1:(*|decoder1),[+|-]family2:(*|decoder2),...[-]> Specify a priority list of audio decoders to be used, according to their family and decoder name. Entries like ``family:*`` prioritize all decoders diff --git a/audio/out/ao.c b/audio/out/ao.c index 9cfa383972..7abb33f89f 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -107,8 +107,7 @@ void list_audio_out(void) struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input) { struct ao *r = talloc(NULL, struct ao); - *r = (struct ao){.outburst = 512, .buffersize = -1, - .opts = opts, .input_ctx = input }; + *r = (struct ao){.opts = opts, .input_ctx = input }; return r; } diff --git a/audio/out/ao.h b/audio/out/ao.h index 0e004572a6..146c35f823 100644 --- a/audio/out/ao.h +++ b/audio/out/ao.h @@ -89,13 +89,11 @@ struct ao { int samplerate; struct mp_chmap channels; int format; - int bps; // bytes per second - int outburst; - int buffersize; - double pts; + int bps; // bytes per second + double pts; // some mplayer.c state (why is this here?) struct bstr buffer; int buffer_playable_size; - bool probing; + bool probing; // if true, don't fail loudly on init bool initialized; bool untimed; bool no_persistent_volume; // the AO does the equivalent of af_volume diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 6dd04d2967..bbd4603d18 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -57,6 +57,8 @@ struct priv { int can_pause; snd_pcm_sframes_t prepause_frames; float delay_before_pause; + int buffersize; + int outburst; }; #define BUFFER_TIME 500000 // 0.5 s @@ -579,15 +581,15 @@ static int init(struct ao *ao, char *params) err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize); CHECK_ALSA_ERROR("Unable to get buffersize"); - ao->buffersize = bufsize * p->bytes_per_sample; + p->buffersize = bufsize * p->bytes_per_sample; mp_msg(MSGT_AO, MSGL_V, "alsa-init: got buffersize=%i\n", - ao->buffersize); + p->buffersize); err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL); CHECK_ALSA_ERROR("Unable to get period size"); mp_msg(MSGT_AO, MSGL_V, "alsa-init: got period size %li\n", chunk_size); - ao->outburst = chunk_size * p->bytes_per_sample; + p->outburst = chunk_size * p->bytes_per_sample; /* setting software parameters */ err = snd_pcm_sw_params_current(p->alsa, alsa_swparams); @@ -621,7 +623,7 @@ static int init(struct ao *ao, char *params) mp_msg(MSGT_AO, MSGL_V, "alsa: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", ao->samplerate, ao->channels.num, (int)p->bytes_per_sample, - ao->buffersize, snd_pcm_format_description(p->alsa_fmt)); + p->buffersize, snd_pcm_format_description(p->alsa_fmt)); return 0; @@ -733,7 +735,7 @@ static int play(struct ao *ao, void *data, int len, int flags) int num_frames; snd_pcm_sframes_t res = 0; if (!(flags & AOPLAY_FINAL_CHUNK)) - len = len / ao->outburst * ao->outburst; + len = len / p->outburst * p->outburst; num_frames = len / p->bytes_per_sample; //mp_msg(MSGT_AO,MSGL_ERR,"alsa-play: frames=%i, len=%i\n",num_frames,len); @@ -789,8 +791,8 @@ static int get_space(struct ao *ao) CHECK_ALSA_ERROR("cannot get pcm status"); unsigned space = snd_pcm_status_get_avail(status) * p->bytes_per_sample; - if (space > ao->buffersize) // Buffer underrun? - space = ao->buffersize; + if (space > p->buffersize) // Buffer underrun? + space = p->buffersize; return space; alsa_error: diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index ea9e431535..38c7c7fc29 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -626,9 +626,7 @@ static int init(struct ao *ao, char *params) goto err_out2; ao->bps = ao->samplerate * inDesc.mBytesPerFrame; - ao->buffersize = ao->bps; p->buffer = mp_ring_new(p, get_ring_size(ao)); - ao->outburst = maxFrames; print_buffer(p->buffer); @@ -861,11 +859,7 @@ static int OpenSPDIF(struct ao *ao) (p->stream_format.mBytesPerPacket / p->stream_format.mFramesPerPacket); - /* For ac3/dts, just use packet size 6144 bytes as chunk size. */ - int chunk_size = p->stream_format.mBytesPerPacket; - ao->buffersize = ao->bps; p->buffer = mp_ring_new(p, get_ring_size(ao)); - ao->outburst = chunk_size; print_buffer(p->buffer); diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c index 5b49a67d16..bb410183eb 100644 --- a/audio/out/ao_dsound.c +++ b/audio/out/ao_dsound.c @@ -94,6 +94,8 @@ struct priv { int audio_volume; int device_index; + + int outburst; ///play in multiple of chunks of this size }; static float get_delay(struct ao *ao); @@ -438,13 +440,12 @@ static int init(struct ao *ao, char *params) ao->samplerate = rate; ao->format = format; ao->bps = ao->channels.num * rate * (af_fmt2bits(format) >> 3); - if (ao->buffersize == -1) - ao->buffersize = ao->bps; // space for 1 sec + int buffersize = ao->bps; // space for 1 sec mp_msg(MSGT_AO, MSGL_V, "ao_dsound: Samplerate:%iHz Channels:%i Format:%s\n", rate, ao->channels.num, af_fmt2str_short(format)); mp_msg(MSGT_AO, MSGL_V, "ao_dsound: Buffersize:%d bytes (%d msec)\n", - ao->buffersize, ao->buffersize / ao->bps * 1000); + buffersize, buffersize / ao->bps * 1000); //fill waveformatex ZeroMemory(&wformat, sizeof(WAVEFORMATEXTENSIBLE)); @@ -488,12 +489,12 @@ static int init(struct ao *ao, char *params) wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec * wformat.Format.nBlockAlign; - dsbdesc.dwBufferBytes = ao->buffersize; + dsbdesc.dwBufferBytes = buffersize; dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat; p->buffer_size = dsbdesc.dwBufferBytes; p->write_offset = 0; p->min_free_space = wformat.Format.nBlockAlign; - ao->outburst = wformat.Format.nBlockAlign * 512; + p->outburst = wformat.Format.nBlockAlign * 512; // create primary buffer and set its format @@ -633,7 +634,6 @@ static int get_space(struct ao *ao) \brief play 'len' bytes of 'data' \param data pointer to the data to play \param len size in bytes of the data buffer, gets rounded down to outburst*n - NOTE: outburst stuff might be outdated/deprecated \param flags currently unused \return number of played bytes */ @@ -644,7 +644,7 @@ static int play(struct ao *ao, void *data, int len, int flags) len = space; if (!(flags & AOPLAY_FINAL_CHUNK)) - len = (len / ao->outburst) * ao->outburst; + len = (len / p->outburst) * p->outburst; return write_buffer(ao, data, len); } diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c index ff5c37a818..c677f4555d 100644 --- a/audio/out/ao_jack.c +++ b/audio/out/ao_jack.c @@ -51,6 +51,7 @@ struct priv { jack_port_t * ports[MAX_CHANS]; int num_ports; // Number of used ports == number of channels jack_client_t *client; + int outburst; float jack_latency; int estimate; volatile int paused; @@ -280,9 +281,8 @@ static int init(struct ao *ao, char *params) ao->format = AF_FORMAT_FLOAT_NE; int unitsize = ao->channels.num * sizeof(float); - ao->outburst = CHUNK_SIZE / unitsize * unitsize; - ao->buffersize = NUM_CHUNKS * ao->outburst; - p->ring = mp_ring_new(p, ao->buffersize); + p->outburst = CHUNK_SIZE / unitsize * unitsize; + p->ring = mp_ring_new(p, NUM_CHUNKS * p->outburst); free(matching_ports); free(port_name); free(client_name); @@ -365,7 +365,7 @@ static int play(struct ao *ao, void *data, int len, int flags) { struct priv *p = ao->priv; if (!(flags & AOPLAY_FINAL_CHUNK)) - len -= len % ao->outburst; + len -= len % p->outburst; p->underrun = 0; return mp_ring_write(p->ring, data, len); } diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index d2ae5e1e53..4fe709ce9a 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -281,10 +281,6 @@ out_takefirst: encode_lavc_getoffset(ao->encode_lavc_ctx, ac->stream); ac->offset_left = ac->offset; - //fill_ao_data: - ao->outburst = - ac->aframesize * ac->sample_size * ao->channels.num * ac->framecount; - ao->buffersize = ao->outburst * 2; ao->untimed = true; ao->priv = ac; @@ -354,7 +350,9 @@ static void uninit(struct ao *ao, bool cut_audio) // return: how many bytes can be played without blocking static int get_space(struct ao *ao) { - return ao->outburst; + struct priv *ac = ao->priv; + + return ac->aframesize * ac->sample_size * ao->channels.num * ac->framecount; } // must get exactly ac->aframesize amount of data @@ -487,7 +485,7 @@ static int encode(struct ao *ao, double apts, void *data) } // plays 'len' bytes of 'data' -// it should round it down to outburst*n +// it should round it down to frame sizes // return: number of bytes played static int play(struct ao *ao, void *data, int len, int flags) { diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c index f3c60913b5..dde2102daa 100644 --- a/audio/out/ao_null.c +++ b/audio/out/ao_null.c @@ -31,6 +31,8 @@ struct priv { double last_time; float buffered_bytes; + int buffersize; + int outburst; }; static void drain(struct ao *ao) @@ -55,9 +57,9 @@ static int init(struct ao *ao, char *params) return -1; int samplesize = af_fmt2bits(ao->format) / 8; - ao->outburst = 256 * ao->channels.num * samplesize; + priv->outburst = 256 * ao->channels.num * samplesize; // A "buffer" for about 0.2 seconds of audio - ao->buffersize = (int)(ao->samplerate * 0.2 / 256 + 1) * ao->outburst; + priv->buffersize = (int)(ao->samplerate * 0.2 / 256 + 1) * priv->outburst; priv->last_time = mp_time_sec(); return 0; @@ -92,18 +94,18 @@ static int get_space(struct ao *ao) struct priv *priv = ao->priv; drain(ao); - return ao->buffersize - priv->buffered_bytes; + return priv->buffersize - priv->buffered_bytes; } static int play(struct ao *ao, void *data, int len, int flags) { struct priv *priv = ao->priv; - int maxbursts = (ao->buffersize - priv->buffered_bytes) / ao->outburst; - int playbursts = len / ao->outburst; + int maxbursts = (priv->buffersize - priv->buffered_bytes) / priv->outburst; + int playbursts = len / priv->outburst; int bursts = playbursts > maxbursts ? maxbursts : playbursts; - priv->buffered_bytes += bursts * ao->outburst; - return bursts * ao->outburst; + priv->buffered_bytes += bursts * priv->outburst; + return bursts * priv->outburst; } static float get_delay(struct ao *ao) diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c index 60f4dd7c99..44f26c9cf1 100644 --- a/audio/out/ao_openal.c +++ b/audio/out/ao_openal.c @@ -188,8 +188,6 @@ static int init(struct ao *ao, char *params) if (alcGetError(dev) == ALC_NO_ERROR && freq) ao->samplerate = freq; ao->format = AF_FORMAT_S16_NE; - ao->buffersize = CHUNK_SIZE * NUM_BUF; - ao->outburst = ao->channels.num * CHUNK_SIZE; tmpbuf = malloc(CHUNK_SIZE); free(device); return 0; diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index d5125ffcd7..fa590f7965 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -58,6 +58,8 @@ struct priv { int oss_mixer_channel; audio_buf_info zz; int audio_delay_method; + int buffersize; + int outburst; }; static int format_table[][2] = { @@ -206,6 +208,8 @@ static int init(struct ao *ao, char *params) .oss_mixer_device = mdev ? mdev : PATH_DEV_MIXER, .oss_mixer_channel = SOUND_MIXER_PCM, .audio_delay_method = 2, + .buffersize = -1, + .outburst = 512, }; ao->priv = p; @@ -363,29 +367,28 @@ ac3_retry: "support SNDCTL_DSP_GETOSPACE\n"); if (ioctl(p->audio_fd, SNDCTL_DSP_GETBLKSIZE, &r) == -1) mp_msg(MSGT_AO, MSGL_V, "audio_setup: %d bytes/frag (config.h)\n", - ao->outburst); + p->outburst); else { - ao->outburst = r; + p->outburst = r; mp_msg(MSGT_AO, MSGL_V, "audio_setup: %d bytes/frag (GETBLKSIZE)\n", - ao->outburst); + p->outburst); } } else { mp_msg(MSGT_AO, MSGL_V, "audio_setup: frags: %3d/%d (%d bytes/frag) free: %6d\n", p->zz.fragments, p->zz.fragstotal, p->zz.fragsize, p->zz.bytes); - if (ao->buffersize == -1) - ao->buffersize = p->zz.bytes; - ao->outburst = p->zz.fragsize; + p->buffersize = p->zz.bytes; + p->outburst = p->zz.fragsize; } - if (ao->buffersize == -1) { + if (p->buffersize == -1) { // Measuring buffer size: void *data; - ao->buffersize = 0; + p->buffersize = 0; #ifdef HAVE_AUDIO_SELECT - data = malloc(ao->outburst); - memset(data, 0, ao->outburst); - while (ao->buffersize < 0x40000) { + data = malloc(p->outburst); + memset(data, 0, p->outburst); + while (p->buffersize < 0x40000) { fd_set rfds; struct timeval tv; FD_ZERO(&rfds); @@ -394,11 +397,11 @@ ac3_retry: tv.tv_usec = 0; if (!select(p->audio_fd + 1, NULL, &rfds, NULL, &tv)) break; - write(p->audio_fd, data, ao->outburst); - ao->buffersize += ao->outburst; + write(p->audio_fd, data, p->outburst); + p->buffersize += p->outburst; } free(data); - if (ao->buffersize == 0) { + if (p->buffersize == 0) { mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS]\n *** Your audio driver " "DOES NOT support select() ***\n Recompile mpv with " "#undef HAVE_AUDIO_SELECT in config.h !\n\n"); @@ -408,7 +411,7 @@ ac3_retry: } ao->bps = ao->channels.num * (af_fmt2bits(ao->format) / 8); - ao->outburst -= ao->outburst % ao->bps; // round down + p->outburst -= p->outburst % ao->bps; // round down ao->bps *= ao->samplerate; return 0; @@ -479,7 +482,7 @@ static void reset(struct ao *ao) static int get_space(struct ao *ao) { struct priv *p = ao->priv; - int playsize = ao->outburst; + int playsize = p->outburst; #ifdef SNDCTL_DSP_GETOSPACE if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &p->zz) != -1) { @@ -503,7 +506,7 @@ static int get_space(struct ao *ao) } #endif - return ao->outburst; + return p->outburst; } // stop playing, keep buffers (for pause) @@ -522,9 +525,9 @@ static int play(struct ao *ao, void *data, int len, int flags) struct priv *p = ao->priv; if (len == 0) return len; - if (len > ao->outburst || !(flags & AOPLAY_FINAL_CHUNK)) { - len /= ao->outburst; - len *= ao->outburst; + if (len > p->outburst || !(flags & AOPLAY_FINAL_CHUNK)) { + len /= p->outburst; + len *= p->outburst; } len = write(p->audio_fd, data, len); return len; @@ -560,12 +563,12 @@ static float get_delay(struct ao *ao) if (p->audio_delay_method == 1) { // SNDCTL_DSP_GETOSPACE if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &p->zz) != -1) { - return ((float)(ao->buffersize - + return ((float)(p->buffersize - p->zz.bytes)) / (float)ao->bps; } p->audio_delay_method = 0; // fallback if not supported } - return ((float)ao->buffersize) / (float)ao->bps; + return ((float)p->buffersize) / (float)ao->bps; } const struct ao_driver audio_out_oss = { diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index 903e89bc8b..7cceaad1cb 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -151,7 +151,6 @@ static int init(struct ao *ao, char *params) if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) return -1; - ao->outburst = 65536; ao->bps = ao->channels.num * ao->samplerate * (af_fmt2bits(ao->format) / 8); mp_tmsg(MSGT_AO, MSGL_INFO, "[AO PCM] File: %s (%s)\n" @@ -207,7 +206,7 @@ static void uninit(struct ao *ao, bool cut_audio) static int get_space(struct ao *ao) { - return ao->outburst; + return 65536; } static int play(struct ao *ao, void *data, int len, int flags) diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c index 572266c4a8..ee95e77d44 100644 --- a/audio/out/ao_sdl.c +++ b/audio/out/ao_sdl.c @@ -248,9 +248,7 @@ static int init(struct ao *ao, char *params) } ao->samplerate = obtained.freq; - ao->buffersize = obtained.size * bufcnt; - ao->outburst = obtained.size; - priv->buffer = av_fifo_alloc(ao->buffersize); + priv->buffer = av_fifo_alloc(obtained.size * bufcnt); priv->buffer_mutex = SDL_CreateMutex(); if (!priv->buffer_mutex) { mp_msg(MSGT_AO, MSGL_ERR, "[sdl] SDL_CreateMutex failed\n"); diff --git a/core/mplayer.c b/core/mplayer.c index b6d2923818..d38363b9ce 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -1706,7 +1706,6 @@ void reinit_audio_chain(struct MPContext *mpctx) goto init_error; } if (!ao->initialized) { - ao->buffersize = opts->ao_buffersize; ao->encode_lavc_ctx = mpctx->encode_lavc_ctx; mp_chmap_remove_useless_channels(&ao->channels, &opts->audio_output_channels); diff --git a/core/options.c b/core/options.c index f73fcf7bb2..d3dd9d19c8 100644 --- a/core/options.c +++ b/core/options.c @@ -543,8 +543,6 @@ const m_option_t mp_opts[] = { {"no", 0}, {"yes", 1}, {"", 1})), OPT_FLAG("gapless-audio", gapless_audio, 0), - // override audio buffer size (used only by -ao oss/win32, obsolete) - OPT_INT("abs", ao_buffersize, 0), // set screen dimensions (when not detectable or virtual!=visible) OPT_INTRANGE("screenw", vo.screenwidth, CONF_GLOBAL, 0, 4096), @@ -734,7 +732,6 @@ const struct MPOpts mp_default_opts = { .mixer_init_volume = -1, .mixer_init_mute = -1, .volstep = 3, - .ao_buffersize = -1, .vo = { .video_driver_list = NULL, .cursor_autohide_delay = 1000, diff --git a/core/options.h b/core/options.h index f598cf267f..f925990a6c 100644 --- a/core/options.h +++ b/core/options.h @@ -57,7 +57,6 @@ typedef struct MPOpts { int volstep; float softvol_max; int gapless_audio; - int ao_buffersize; mp_vo_opts vo; |