Max Kellermann
5907656bbb
output/wasapi: stop the IAudioClient while paused
...
Instead of generating silence, do nothing, don't waste CPU time.
2021-03-10 17:48:49 +01:00
Max Kellermann
2ac2bd26f8
output/wasapi: combine two if
statements to one switch
2021-03-10 17:45:54 +01:00
Max Kellermann
a2be91aea5
output/wasapi: add method WasapiOutputThread::InterruptWaiter()
2021-03-10 17:42:26 +01:00
Max Kellermann
579428172e
output/wasapi: remove the broken Delay() calculation code
...
This code is complicated - and broken: the producer thread is not
allowed to call consumer methods. Also the code is not necessary
because this plugin implements Interrupt().
2021-03-10 17:39:07 +01:00
Max Kellermann
3e484637f9
output/wasapi: rename OpenDevice() to ChooseDevice()
...
OpenDevice was a confusing name because it does not actually open a
device.
2021-03-10 17:34:10 +01:00
Max Kellermann
3e93c392d7
output/wasapi: make enumerator
a local variable
2021-03-10 17:23:41 +01:00
Max Kellermann
0a97e68aa9
output/wasapi: start after the buffer has been filled
...
Postpone the Start() call until there is something to be played.
2021-03-08 23:03:25 +01:00
Max Kellermann
69783a44c8
output/wasapi: move Start()/Stop() calls to WasapiOutputThread::Work()
2021-03-08 22:58:20 +01:00
Max Kellermann
d72263d28d
win32/HResult: support AUDCLNT_E_NOT_{INITIALIZED,STOPPED}
2021-03-08 22:57:44 +01:00
Max Kellermann
24a205a1aa
win32/HResult: try to use FormatMessage()
2021-03-08 22:54:46 +01:00
Max Kellermann
3a948515ce
output/wasapi: check for exceptions after Wait()
...
This finishes problems which occur early in the WasapiOutputThread;
previously, the error was ignored and the output blocked forever
without doing anything (and without reporting the error).
2021-03-08 22:46:40 +01:00
Max Kellermann
9ade93983c
output/wasapi: rename method WaitDataPoped() to Wait()
2021-03-08 22:44:49 +01:00
Max Kellermann
6931ce9558
output/wasapi: make the Thread a field, not a base class
2021-03-08 22:30:19 +01:00
Max Kellermann
d6fb07a3e4
output/wasapi: start the WasapiOutputThread in its constructor
2021-03-08 22:29:33 +01:00
Max Kellermann
01d3c2705e
output/wasapi: Finish() calls Join()
2021-03-08 22:28:36 +01:00
Max Kellermann
29346dc9c5
output/wasapi: remove the thread management code from DoDisable()
...
This is duplicate; this has already been done in Close().
2021-03-08 22:27:46 +01:00
Max Kellermann
798e68ef62
output/wasapi: don't clear the exception in CheckException()
...
This is pointless; the method cannot be called again anyway.
2021-03-08 22:18:48 +01:00
Max Kellermann
79397db5b4
output/wasapi: remove the "thrown" field
...
It is pointless to let WasapiOutputThread wait for the
CheckException() call.
2021-03-08 22:17:45 +01:00
Max Kellermann
9256190a9b
output/wasapi: move catch block to the Work() function level
...
If an exception has been caught, the method cannot continue playback,
therefore it doesn't make sense to have the "catch" block inside the
"while" block (and not break the loop after catching an exception).
2021-03-08 22:15:36 +01:00
Max Kellermann
3a0dbb0a67
output/wasapi: make WasapiOutputThread::is_exclusive const
2021-03-08 22:09:23 +01:00
Max Kellermann
3d6c9d1b88
output/wasapi: catch all exception
2021-03-08 22:06:29 +01:00
Max Kellermann
5823e79fe7
output/wasapi: remove broken Drain() implementation
...
The current Drain() implementation does what Cancel() should do; it
does not wait for completion, but instead discards the buffer.
2021-03-08 21:41:34 +01:00
Max Kellermann
5f656dffda
output/wasapi: implement Cancel()
2021-03-08 19:58:15 +01:00
Max Kellermann
34d4d9157a
output/wasapi: add inline
2021-03-08 19:57:40 +01:00
Max Kellermann
22c329cdb4
output/wasapi: convert pointer to reference
2021-03-08 19:56:56 +01:00
Max Kellermann
980ef82216
output/wasapi: move SetEventHandle() call to thread constructor
2021-03-08 17:52:44 +01:00
Max Kellermann
84a06a72df
output/wasapi: fix coding style
2021-03-08 17:52:43 +01:00
Max Kellermann
4833d0891d
output/wasapi: eliminate kErrorId
2021-03-08 17:47:07 +01:00
Max Kellermann
cd53ca22c6
output/wasapi: remove unused function SafeTry()
2021-03-08 17:43:36 +01:00
Max Kellermann
d61341c0e3
io/FileDescriptor: add method SetBinaryMode()
2021-03-08 17:25:36 +01:00
Max Kellermann
ec76583c33
win32/Com: add COINIT_DISABLE_OLE1DDE
...
MSDN documentation suggests always passing this flag to reduce
overhead for an "obsolete technology".
2021-03-08 14:03:33 +01:00
Max Kellermann
927f1e03a3
win32/Com: make COINIT_APARTMENTTHREADED the default constructor
2021-03-08 14:02:49 +01:00
Max Kellermann
f2c679cfec
win32/Com: remove the unused COINIT_MULTITHREADED constructor
2021-03-08 14:02:49 +01:00
Max Kellermann
6a75c48dba
win32/HResult: add MakeHResultError()
...
None of the current FormatHResultError() callers need the format string.
2021-03-08 13:46:36 +01:00
Max Kellermann
48bdd09f64
win32/ComWorker: fold class COMWorkerThread into class COMWorker
2021-03-07 18:22:59 +01:00
Max Kellermann
cf108c389f
win32/ComWorker: remove parameter passing from Async()
...
Parameters should better be captured. This removes some complexity
from Async().
2021-03-07 18:20:59 +01:00
Max Kellermann
90d97053a8
win32/ComWorker: make COMWorker a real class, no static members
2021-03-06 20:46:29 +01:00
Shen-Ta Hsieh
e1fe9ebcd6
output/wasapi: Add dop support for WASAPI
...
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1102
2021-03-05 19:40:32 +01:00
Max Kellermann
93016ac6ab
output/wasapi: check AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED
...
Stop early, don't try more formats if it is clear that we have no
chance.
2021-03-05 19:33:38 +01:00
Max Kellermann
fc20a1f10a
output/wasapi: EnumerateDevices() logs, no std::vector
2021-03-05 19:27:52 +01:00
Max Kellermann
a4257e51d5
output/wasapi: reimplement SearchDevice() without EnumerateDevices()
2021-03-05 19:25:42 +01:00
Max Kellermann
2f2b3f1cdc
output/wasapi: SearchDevice() returns IMMDevice
2021-03-05 19:25:42 +01:00
Max Kellermann
2ff6a9ad2b
output/wasapi: GetDevice() returns IMMDevice
2021-03-05 19:25:42 +01:00
Max Kellermann
17d4873b60
output/wasapi: use default device only if none was configured
2021-03-05 19:25:42 +01:00
Max Kellermann
8b41c4f384
output/wasapi: release the COMWorker if OpenDevice() fails
...
Fixes assertion failure in the Thread destructor.
2021-03-05 19:25:42 +01:00
Max Kellermann
17f7098e27
output/wasapi: SafeTry() catches all exceptions
...
Fixes crash due to std::stoul() throwing std::invalid_argument.
2021-03-05 19:12:22 +01:00
Max Kellermann
9ff790b7bb
output/wasapi: move COM utilities to separate headers
2021-03-05 18:33:31 +01:00
Max Kellermann
ebc1fe2821
win32/ComPtr: operator*() returns reference
2021-03-05 17:39:48 +01:00
Max Kellermann
e6a81bb95c
output/wasapi: split the header
...
Reduce header dependencies.
2021-03-05 16:43:44 +01:00
Max Kellermann
9521c1ad58
output/wasapi: use forward declarations in the header
2021-03-05 16:42:38 +01:00
Max Kellermann
6d65cc48d7
output/wasapi: use [[gnu::pure]]
2021-03-05 16:42:15 +01:00
Max Kellermann
681956a963
output/wasapi: include cleanup
2021-03-05 16:42:14 +01:00
Max Kellermann
052f64d648
output/wasapi: include config.h for ENABLE_DSD
2021-03-05 16:35:21 +01:00
Max Kellermann
afe621c25c
output/wasapi: move to separate directory
2021-03-05 16:28:36 +01:00
Max Kellermann
637cf8a039
win32/WinEvent: add default value to Wait()
2021-03-05 16:05:32 +01:00
Max Kellermann
2011a6e2ee
win32/WinEvent: un-inline the constructor
...
Reduce header dependencies.
2021-03-05 16:01:23 +01:00
Max Kellermann
d54830de12
thread/WindowsFuture: include cleanup
2021-03-05 13:50:16 +01:00
Max Kellermann
a7e7312cca
win32/HResult: un-inline HResultCategory::message()
2021-03-05 13:40:40 +01:00
Max Kellermann
6b83fc6b57
win32/HResult: un-inline FormatHResultError()
...
Reduce header dependencies.
2021-03-05 13:40:38 +01:00
Max Kellermann
74f9e07151
win32/HResult: include cleanup
2021-03-05 13:40:37 +01:00
Max Kellermann
82a61ab3be
win32/meson.build: fix syntax error
2021-03-05 13:40:34 +01:00
Max Kellermann
54c1794cee
win32: build static library
...
Fixes linker failure on test/run_output.exe
2021-03-05 13:32:58 +01:00
Max Kellermann
932756efce
win32/ComWorker: fix the FormatHResultError() return type
...
Casting to std::runtime_error loses information (and prevents RVO).
2021-03-05 13:17:40 +01:00
Max Kellermann
7838265482
win32/ComWorker: remove debug log messages
2021-03-05 13:16:09 +01:00
Max Kellermann
b14b0e5634
win32/ComWorker: reorder includes
2021-03-05 13:15:45 +01:00
Max Kellermann
4d2d0e7bb8
win32/ComWorker: include cleanup
2021-03-05 13:15:21 +01:00
Rosen Penev
44378b7dbe
use structured binding declarations
...
Shorter.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-03-04 20:28:02 +01:00
Shen-Ta Hsieh
da642b2890
src/output: add algorithm for finding usable AudioFormat
...
* Use PcmExport for 24bit packed output
2021-03-04 18:53:58 +01:00
Shen-Ta Hsieh
6f77af20d0
src/output: Set fallback setting for DSD
2021-03-04 18:50:56 +01:00
Shen-Ta Hsieh
010f65a1d6
src/output: Add Interrupt interface
2021-03-04 18:50:09 +01:00
Shen-Ta Hsieh
c46f97454a
src/output: Reopen device on error
2021-03-04 18:49:28 +01:00
Shen-Ta Hsieh
844dbd2ec5
src/output: Use WinEvent for as a condition_variable without lock
2021-03-04 18:46:26 +01:00
Shen-Ta Hsieh
db7caa2dac
src/output: Move event and spsc_queue into thread object
2021-03-04 18:45:56 +01:00
Shen-Ta Hsieh
2974737746
src/win32: Add ComWorker to run all COM function on same thread
2021-03-04 18:43:43 +01:00
Shen-Ta Hsieh
b1d7567226
win32: Add ComWorker to run all COM function on same thread
2021-03-04 18:43:16 +01:00
Max Kellermann
5103eb3039
meson.build: compile Win32Main.cxx only on Windows
2021-03-04 18:43:00 +01:00
Shen-Ta Hsieh
0cccdcf9b2
src/win32: Add support for COINIT_APARTMENTTHREADED
2021-03-04 18:37:56 +01:00
Shen-Ta Hsieh
22b840c2f1
win32/Com: use if with init-statement
2021-03-04 18:37:35 +01:00
Shen-Ta Hsieh
ed1a995bff
thread: Add Future
implement for mingw32 without pthread
2021-03-04 18:26:46 +01:00
Shen-Ta Hsieh
0f39dc1edb
output/wasapi: use AUDCLNT_BUFFERFLAGS_SILENT for paused output
2021-03-04 18:17:57 +01:00
Max Kellermann
dc9103befe
util/AllocatedString: remove Null(), IsNull()
2021-03-04 18:05:29 +01:00
Max Kellermann
67760f5283
util/AllocatedString: support casting a nulled instance to string_view
2021-03-04 18:05:29 +01:00
Max Kellermann
99405a4c93
util/AllocatedString: add operator=()
2021-03-04 18:05:26 +01:00
Max Kellermann
b833c5d2c7
util/AllocatedString: replace Clone() with copy constructor
2021-03-04 18:04:21 +01:00
Max Kellermann
bca5d79f88
util/AllocatedString: add const_pointer constructor
2021-03-04 18:04:17 +01:00
Max Kellermann
6e1c8edf09
util/AllocatedString: add string_view constructor
...
Replaces the static Duplicate() method.
2021-03-04 18:04:11 +01:00
Max Kellermann
32b7b2e2fa
util/AllocatedString: add default constructor
2021-03-04 18:04:06 +01:00
Max Kellermann
cfb7f8ab84
util/AllocatedString: rename to BasicAllocatedString
...
To make things simpler, AllocatedString is now a non-template class.
2021-03-04 18:03:56 +01:00
Érico Rolim
8d80280ab9
time/ISO8601: don't use glibc extension in strptime.
...
Per the manual for strptime, %F is equivalent %Y-%m-%d, so use that
directly.
2021-03-04 17:49:51 +01:00
Érico Rolim
c95e3dc065
storage/plugins/CurlStorage: don't use glibc extension in
...
ParseTimePoint.
%Z is a glibc extension to strptime, and is a no-op there, due to the
mapping between timezone names and their definition (especially when the
name comes from a different machine) being ambiguous / impossible. Time
in HTTP headers is guaranteed to be UTC.
Passing an unknown format to strptime() implementations that don't
support it will generally cause them to return NULL, which will lead to
ParseTimePoint throwing an exception and ParseTimeStamp using an
unnecessary fallback.
Since the timezone name goes at the end of the string, we don't need to
use %Z to skip it (could be an issue in a different time stamp format),
so simply removing %Z works best.
2021-03-04 17:48:23 +01:00
Max Kellermann
6eba621045
decoder/ffmpeg: fix build problem with FFmpeg 3.4
...
Regression by commit a22d1c88d7
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1097
2021-02-22 13:36:46 +01:00
Max Kellermann
a9ad8fa505
decoder/ffmpeg: move code to IsSeekable(AVFormatContext)
2021-02-22 13:33:25 +01:00
Max Kellermann
80531ef8d8
db/simple: fix ExportedSong move constructor for non-owning sources
...
If the constructor moves from an ExportedSong instance which refers to
somebody else's "Tag" instance, the newly constructed instance will
instead refer to its own empty "tag_buffer" field. This broke
SimpleDatabase::GetSong(), i.e. all songs on the queue restored from
the state file or added using the "addid" command.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1089
2021-02-16 13:52:25 +01:00
Max Kellermann
6b1d264b35
command/queue: better error message for open-ended range with "move"
...
The "move" command doesn't allow open-ended ranges because they don't
make a lot of sense; moving an open-ended range is only possible if
the destination index is before the range, and in that case, the
client should be well aware how many songs there are.
Closes https://github.com/MusicPlayerDaemon/MPD/pull/1057
2021-02-15 20:57:22 +01:00
Max Kellermann
a6c10e9a1c
protocol/ArgParser: check for invalid ranges
...
Catch errors like that early, before invalid ranges get passed to
internal MPD subsystems.
2021-02-15 20:55:30 +01:00
Max Kellermann
19a46064e9
protocol/RangeArg: add methods IsWellFormed(), IsEmpty(), HasAtLeast(), Count()
2021-02-15 20:54:51 +01:00
Max Kellermann
b57eeaa720
protocol/RangeArg: add static method Single()
2021-02-15 20:29:37 +01:00
Max Kellermann
ad059d5804
protocol/RangeArg: add method IsOpenEnded()
2021-02-15 20:29:35 +01:00
Max Kellermann
6e1940e930
protocol/RangeArg: add static method OpenEnded()
2021-02-15 20:29:34 +01:00
Max Kellermann
103194e32d
protocol/RangeArg: add missing noexcept
2021-02-15 19:56:02 +01:00