Commit Graph

27 Commits

Author SHA1 Message Date
Diogo Franco (Kovensky) 04faf9a1cb ao_wasapi: Fix mistaken behavior on uninit
The parameter, when true, tells whether uninit should block for flushing
the buffers, not whether it should quit immediately without flushing.
2013-12-08 19:36:44 -03:00
Diogo Franco (Kovensky) c7064ce5e5 ao_wasapi: handle AOPLAY_FINAL_CHUNK
Used for writing down all samples to the audio driver, even if it's not
a full chunk; needed at EOF on weird files.
2013-12-08 19:36:43 -03:00
Diogo Franco (Kovensky) 8f4380d6d5 ao_wasapi: Reduce the buffer size to a sane value
The previous RING_BUFFER_COUNT value, 64, would have ao_wasapi buffer 64
frames of audio in the ring buffer; a delay of 1280ms, which is clearly
overkill for everything. A value of 8 buffers 8 frames for a total of
160ms.
2013-12-08 19:14:56 -03:00
Diogo Franco (Kovensky) 2329e46229 ao_wasapi: fix audio buffering delay calculation
When get_space was converted to returning samples instead of bytes, a
unit type mismatch in get_delay's calculation returned bogus values. Fix
by converting get_space's value back to bytes.

Fixes playback with ao_wasapi when reaching EOF, or seeking past it.
2013-12-08 19:03:26 -03:00
wm4 380fc765e4 audio/out: prepare for non-interleaved audio
This comes with two internal AO API changes:

1. ao_driver.play now can take non-interleaved audio. For this purpose,
the data pointer is changed to void **data, where data[0] corresponds to
the pointer in the old API. Also, the len argument as well as the return
value are now in samples, not bytes. "Sample" in this context means the
unit of the smallest possible audio frame, i.e. sample_size * channels.

2. ao_driver.get_space now returns samples instead of bytes. (Similar to
the play function.)

Change all AOs to use the new API.

The AO API as exposed to the rest of the player still uses the old API.
It's emulated in ao.c. This is purely to split the commits changing all
AOs and the commits adding actual support for outputting N-I audio.
2013-11-12 23:27:51 +01:00
wm4 bf60281ffb audio/out: reject non-interleaved formats
No AO can handle these, so it would be a problem if they get added
later, and non-interleaved formats get accepted erroneously. Let them
gracefully fall back to other formats.

Most AOs actually would fall back, but to an unrelated formats. This is
covered by this commit too, and if possible they should pick the
interleaved variant if a non-interleaved format is requested.
2013-11-12 23:16:31 +01:00
wm4 91626b1c06 audio: replace af_fmt2str_short -> af_fmt_to_str
Also, remove all af_fmt2str usages.
2013-11-07 22:12:36 +01:00
wm4 d58d4ec93c audio/out: remove useless info struct and redundant fields 2013-10-23 19:30:02 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
Diogo Franco 57ec67a6cc Merge pull request #154 from rossy2401/wasapi-pause
WASAPI stops working after pause
2013-08-05 18:22:46 -07:00
Jonathan Yong 29b0be400c Fix some warnings 2013-07-30 11:05:39 -03:00
James Ross-Gowan 8e1461b9f8 ao_wasapi: don't check the audio feed while paused 2013-07-27 14:28:42 +10:00
wm4 f32a90a839 audio/out: remove options argument from init()
Same as with VOs in the previous commit.
2013-07-22 22:58:09 +02:00
Diogo Franco (Kovensky) 1b2dc3613f ao_wasapi: Fix S/PDIF passthrough init
MSDN tells me to multiply the samplerates by 4 (for setting up the S/PDIF
signal frequency), but doesn't mention that I'm only supposed to do it
on the new, NT6.1+ IEC 61937 structs. Works on my Realtek Digital Output,
but as I can't connect any hardware to it I can't hear the result.

Also, always ask for little-endian AC3. I'm not sure if this is supposed
to be LE or NE, but Windows is LE on all platforms, so we go with LE.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 9fe2772780 ao_wasapi: Log the passthrough format in MSGL_V 2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) a8b4be274c ao_wasapi: Also do passthrough for AF_FORMAT_MPEG2
That's the sample format ad_spdif uses when the source is MP3.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) dcf38e0190 ao_wasapi: Support S/PDIF passthrough
Entirely untested as this troper has no S/PDIF hardware.

Refuses trying any other format if we can't use passthrough, or we would
end up sending white noise at the user.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 58e3d3f207 ao_wasapi: Fix double free on uninit
Caused by incorrect conversion to the m_option API: since we don't allocate
the state ourselves, we also don't free it ourselves.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) c62395dc09 ao_wasapi: Support loading devices by name
Do an strstr match against the device description and, if we have only
a single match, take it. This works as long as the devices in the system
don't change, but it's not supposed to be reliable; if one wants
reliability, one uses the device ID string.

Formatting.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) ad6acddbcf ao_wasapi: Don't search for devices as part of validation
This could turn valid parameters into syntax errors by the mere presence
or abscence of a device (e.g. USB audio devices), so don't do that.

We do validate that, if the parameter is an integer, it is not negative.
We also respond to the "help" parameter, which does the same as the "list"
suboption but exits after listing.

Demote the validation logging to MSGL_DBG2.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) d68fa0531f ao_wasapi: Change function macros to require semicolon after invocation
Add semicolons where they were missing.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 964341b02d ao_wasapi: Use OPT_STRING_VALIDATE for device suboption
Validates by trying to pick the device using the device enumerator and
aborting with out of range on failure.

Refactors find_and_load_device to not use the wasapi_state; it might be
called during validation. Adds missing CoInitialize/CoUninitialize calls.
Remove unused variables (the SAFE_RELEASE macros keep them referenced so
compiler warnings don't help finding them...).

Remove the IMMDeviceEnumerator from the wasapi_state, it's only needed
during initialization and initialization is now well factored enough to
get rid of it.

Try and connect to unplugged devices as well when using the device ID
string.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) d42c3e51b4 ao_wasapi: Fully convert to m_option API 2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 56274c6664 ao_wasapi: Don't leak the default device's ID when listing devices
Also remove unused variable.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 32cb190855 ao_wasapi: Annotate the default device when listing devices 2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) efc3668fbe ao_wasapi: Refactor device listing/loading
Omit "{0.0.0.00000000}." on devices that start with that substring,
re-add when searching for devices by ID.

Log the device ID of the default device.

Log the friendly name of the used device.

Consistently refer to endpoints/devices as devices, as this is more
consistent with mpv terminology.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) d5adaed9d8 ao_wasapi0: Rename to ao_wasapi
Nobody knows what the 0 was for. There's no "WASAPI version 0". Just take
it out.
2013-07-22 02:42:38 +02:00