summaryrefslogtreecommitdiffstats
path: root/audio/mixer.c
Commit message (Collapse)AuthorAgeFilesLines
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* mixer: fix volume initialization with --af=volumewm42015-12-111-0/+2
| | | | | | | | A manually added af_volume could lead to muted audio when switching to a new file. af_volume keeps the last volume set by AF_CONTROL_SET_VOLUME to return it with AF_CONTROL_GET_VOLUME, but the initial value is 0. So the mixer volume was forced to 0 when unintializing the filter chain and reading back the previously set volume.
* mixer: minor simplificationwm42015-12-111-4/+7
| | | | (Why is this code so complex?)
* audio: fix restoring volumeshdown2015-07-271-1/+1
| | | | | Was broken by 68bbab0e42e141896545f1f6e9699bcad2d685f8, which changed the number of fields to scan, but not the expected return value.
* Various spelling fixesMarcin Kurczewski2015-06-181-1/+1
| | | | Signed-off-by: wm4 <wm4@nowhere>
* audio: change range of volume option/propertywm42015-05-221-15/+14
| | | | | | | | | Now --volume takes an absolute volume, meaning it doesn't depend on --softvol-max. 0 is still silence, and 100 now always means unchanged volume. The OSD and the "volume" property are changed accordingly. Also raise the minimum value of --softvol-max. A value below 100 makes no sense and breaks the OSD.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* audio: change a detail about filter insertionwm42015-04-071-2/+2
| | | | | | | | | | The af_add() function has a problem: if the inserted filter returns AF_DETACH during init, the function will have a dangling pointer. Until now this was avoided by making sure none of the used filters actually return AF_DETACH, but it's getting infeasible. Solve this by requiring passing an unique label to af_add(), which is then used instead of the pointer.
* mixer: per-app volume and private volume conflictwm42015-04-011-1/+3
| | | | | | Per-app volume would change the volume across all instances of the same application, while a private volume control (HAS_PER_APP_VOLUME) obviously should influence only one instance/audio stream only.
* mixer: handle prevention of unneeded af_volume insertion differentlywm42015-04-011-2/+3
| | | | Just so that this special-case is out of the common volume path.
* mixer: cleanup volume logic slightlywm42015-04-011-12/+11
|
* mixer: add more debug outputwm42015-04-011-3/+16
| | | | For remote-debugging volume rstore problems.
* mixer: fix how volume is restored with per-app system mixerswm42015-03-241-3/+6
| | | | | | | | | | This broke with PulseAudio: when changing some audio filters (like for playback speed), mixer_reinit_audio() was called - and it overwrote the volume with whatever mpv thought the volume was before. If the volume was changed externally before and while mpv was running, this would reset the volume to the old value. Fixes #1335.
* mixer: don't show softvol neutral marker on OSD if not using softvolwm42014-11-271-2/+2
| | | | Also fix the comment on the softvol field.
* mixer: always restore volume (even with pulse), don't unmutewm42014-09-201-6/+8
| | | | | | | | | | | | | | | | | | Be less clever, and restore the volume state even with AOs like pulse, which have per-application audio. Before this commit we didn't do this, because the volume is global (even if per-application), so the volume will persist between invocations. But to me it looks like always restoring is less tricky and makes for easier to understand semantics. Also, don't always unmute on exit. Unmuting was done even with ao_pulse, and interfered with user expectations (see #1107). This might annoy some users, because mpv will change the volume all the time. We will see. Fixes #1107.
* audio/out: remove old thingswm42014-09-061-2/+2
| | | | | | | | Remove the unnecessary indirection through ao fields. Also fix the inverted result of AOCONTROL_HAS_TEMP_VOLUME. Hopefully the change is equivalent. But actually, it looks like the old code did it wrong.
* player: show "neutral" position markers for OSD barswm42014-06-081-0/+6
| | | | This commit implements them for volume and some video properties.
* mixer: make code more readablewm42014-05-111-7/+3
| | | | | You wouldn't have guessed that the bottom-most "level[i] = 0.f;" line was actually required. It even confused cppcheck.
* mixer: don't restore volume with different --softvol-max settingswm42014-05-061-8/+11
| | | | | | | | | | | Changing --softvol-max and then resuming would change the volume level on resume to something different than the original volume. This is because the user volume setting is always between 0-100, and 100 corresponds to --softvol-max gain. Avoid that changing -softvol-max and resuming an older file could lead to a too loud volume level by refusing to restore if --softvol-max changed.
* audio/out: feed AOs from a separate threadwm42014-03-091-3/+3
| | | | | | | | | | | | | | | | | | This has 2 goals: - Ensure that AOs have always enough data, even if the device buffers are very small. - Reduce complexity in some AOs, which do their own buffering. One disadvantage is that performance is slightly reduced due to more copying. Implementation-wise, we don't change ao.c much, and instead "redirect" the driver's callback to an API wrapper in push.c. Additionally, we add code for dealing with AOs that have a pull API. These AOs usually do their own buffering (jack, coreaudio, portaudio), and adding a thread is basically a waste. The code in pull.c manages a ringbuffer, and allows callback-based AOs to read data directly.
* audio/out: make ao struct opaquewm42014-03-091-5/+7
| | | | | | We want to move the AO to its own thread. There's no technical reason for making the ao struct opaque to do this. But it helps us sleep at night, because we can control access to shared state better.
* command: use the step size for "add volume" commandswm42014-02-271-12/+2
| | | | | | | | | | | | The step argument for "add volume <step>" was ignored until now. Fix it. There is one problem: by defualt, "add volume" should use the value set with --volstep. This value is 3 by default. Since the default volue for the step argument is always 1 (and we don't really want to make the generic code more complicated by introducing custom step sizes), we simply multiply the step argument with --volstep to keep it compatible. The --volstep option should probably be just removed in the future.
* mixer: mp_msg conversionswm42013-12-211-11/+10
|
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-1/+1
|
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-5/+5
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* mixer: remove comment about af_pan doing downmixingwm42013-12-071-3/+1
| | | | We don't do that anymore.
* audio/filter: remove unneeded AF_CONTROLs, convert to enumwm42013-11-181-18/+7
| | | | | | | | The AF control commands used an elaborate and unnecessary organization for the command constants. Get rid of all that and convert the definitions to a simple enum. Also remove the control commands that were not really needed, because they were not used outside of the filters that implemented them.
* af_volume: use only one volume setting for all channelswm42013-11-091-12/+8
| | | | | | | | In theory, af_volume could use separate volume levels for each channel. But this was never used anywhere. MPlayer implemented something similar before (svn r36498), but kept the old path for some reason.
* audio/out: remove useless info struct and redundant fieldswm42013-10-231-1/+1
|
* command: don't allow changing volume if no audio initializedwm42013-10-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Changing volume when audio is disabled was a feature request (github issue #215), and was introduced with commit 327a779. But trying to fix github issue #280 (volume is not correct in no-audio mode, and if audio is re-enabled, the volume set in no-audio mode isn't set), I concluded that it's not worth the trouble and the current implementation is questionable all around. (For example, you can't change the real volume in no-audio mode, even if the AO is open - this could happen with gapless audio.) It's hard to get right, and the current mixer code is already hilariously overcomplicated. (Virtually all of mixer.c is an amalgamation of various obscure corner cases.) So just remove this feature again. Note that "options/volume" and "options/mute" still can be used in idle mode to adjust the volume used next time, though these properties can't be used during playback and thus not in audio-only mode. Querying the volume still "works" in audio-only mode, though it can return bogus values.
* af: merge af_reinit() and fix_output_format()wm42013-09-201-1/+0
| | | | | | | | | | | | | | | | Calling them separately doesn't really make sense, and all existing calls to them usually combined them. One subtitle difference was that af_init() didn't wipe the filter chain if initialization of the chain itself failed, but that didn't really make sense anyway. Also remove af_init() from the code for setting balance in mixer.c. The mixer should be in the initialized state only if audio is fully initialized, so the af_init() call made no sense. Note that the filter "editing" code in command.c doesn't really do a nice job of handling errors in case recreating an _old_ (known to work) filter chain unexpectedly fails, and this obscure/rare case might be differently handled after this change.
* mixer: make struct opaquewm42013-09-201-12/+36
| | | | Also remove stray include statements from ao_alsa and ao_oss.
* mixer: restore volume with playback resumewm42013-09-201-1/+29
| | | | | | | | | Note that this is intentionally never done if the AO or softvolume is different, or if the current volume control method is thought to control system wide volume (such as ALSA) or otherwise user controllable (such as PulseAudio). The intention is to keep things robust and to avoid messing with the user's audio settings as far as possible, while still providing the ability to resume volume if it makes sense.
* mixer: don't unmute audio when raising volumewm42013-09-191-2/+0
| | | | This is rather strange behavior, away with it.
* mixer: refactor, fix some aspects of --volume handlingwm42013-09-191-62/+114
| | | | | | | | | | | | | | | | | | | | Refactor how mixer.c does volume/mute restoration and initialization. Move to handling of --volume and --mute to mixer.c. Simplify the implementation of these and hopefully fix bugs/strange behavior related to using them as file-local options (this uses a somewhat dirty trick: the option values are reverted to "auto" after initialization). Put most code related to initialization and volume restoring in probe_softvol() and restore_volume(). Having this code all in one place is less confusing. Instead of trying to detect whether to use softvol at runtime, detect it at initialization time using AOCONTROL_GET_VOLUME (same with mute, AOCONTROL_GET_MUTE). This implies we expect SET_VOLUME/SET_MUTE to work if the GET variants work. Hopefully this is always the case. This is also preparation for being able to change volume/mute settings if audio is disabled, and for allowing restoring value with playback resume.
* mixer, af_volume: use linear values instead of dBwm42013-09-191-17/+12
| | | | | | | Softvol always used a linear multiplier for volume control. This was converted to dB, and then back to linear in af_volume. Remove this non- sense. We still try to keep the command line argument to af_volume in dB, though.
* mixer: minor refactoringwm42013-09-191-21/+23
| | | | | Let struct mixer access access MPOpts to simplify some things. Rename some variables and functions. There should be no functional changes.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-1/+1
| | | | Followup commit. Fixes all the files references.
* audio/filter: use new option APIwm42013-07-221-2/+2
| | | | | | | | | | | | | Make the VF/VO/AO option parser available to audio filters. No audio filter uses this yet, but it's still a quite intrusive change. In particular, the commands for manipulating filters at runtime completely change. We delete the old code, and use the same infrastructure as for video filters. (This forces complete reinitialization of the filter chain, which hopefully isn't a problem for any use cases. The old code forced reinitialization too, but it could potentially allow a filter to cache things; e.g. consider loaded ladspa plugins and such.)
* audio/out: switch to channel mapwm42013-05-121-1/+1
| | | | | | This actually breaks audio for 5/6/8 channels. There's no reordering done yet. The actual reordering will be done inside of af_lavrresample and has to be made part of the format negotiation.
* mplayer: keep volume persistent, even when using --volumewm42013-04-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider: mpv --volume 10 file1.mkv file2.mkv Before this commit, the volume was reset to 10 when playing file2.mkv. This was inconsistent to most other options. E.g. --brightness is a rather similar case. In general, settings should never be reset when playing the next file, unless the option was explicitly marked file-local. This commit corrects the behavior of the --volume and --mute options. File local --volume still works as expected: mpv --{ --volume 10 file1.mkv file2.mkv --} This sets the volume always to 10 on playback start. Move the m_config_leave_file_local() call down so that the mixer code in uninit_player() can set the option volume and mute variables without overwriting the global option values. Another subtle issue is that we don't want to set volume if there's no need to, which is why the user_set_volume/mute fields are introduced. This is important because setting the volume might change the system volume depending on other options.
* mixer: prefer AO softvol control over volume filterwm42013-02-061-0/+1
| | | | | | | | | | | | | | | This partially reverts earlier decisions, when I thought it would always be better to prefer the audio volume filter over the AO's, because the AO's relies on the underlying audio-API, which could be broken or exhibit unusual behavior (like it happened with ao_dsound). However, since the audio buffer can be quite large (500 ms), and we don't attempt to flush & refilter the audio on volume changes, always prefer AO volume control (as long as the AO mixer doesn't control the system mixer). Also document what the mixer.c related AO fields mean (hopefully not too brief).
* mixer: keep fractional part of volume settingUoti Urpala2013-01-131-2/+2
| | | | | | | | mixer_setvolume() accepts float values for volume, but used the integer function av_clip() to limit range, losing the fractional part as a side effect. Change the code to use av_clipf() instead. For most uses this shouldn't make any real difference; actual AO volume settings may not have that much precision anyway.
* mixer: fix lowering hw volume while mutedUoti Urpala2012-11-141-1/+1
| | | | | | | Lowering volume while muted did not work correctly with audio outputs that support native mute setting separate from volume (ao_alsa and ao_pulse), because the AO-level volume was not set while muted but was still being read back. Fix by setting the AO volume in this case.
* Rename directories, move files (step 2 of 2)wm42012-11-121-3/+3
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-0/+292
Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.