* windows: Set debug options if appropriate.
If building with debug, also build standard libraries with debug. This
ensures that any libraries linking against cubeb won't have mismatched
symbol definitions.
* Properly allow dynamic linking.
* Set global CMAKE_MSVC_RUNTIME_LIBRARY.
This variable will apply to all targets, rather than needing to apply a
per-target setting.
* remove unnecessary whitespace
* Simplify variable expression
Prior to https://github.com/mozilla/cubeb/pull/682,
a device could be default for all of
MULTIMEDIA, NOTIFICATION, and
VOICE.
After that PR, the first two were
mutually exclusive with the third, I
believe unintentionally.
Restore this behavior so that, e.g.,
on devices with only one output device,
querying for the "voice" device returns
that device.
When reinitializating, `cubeb_stream::previous_clock` isn't reset
properly but stream gets reset and restarts `AAudioTimingInfo::output_frame_index`
from zero. Therefore, `aaudio_stream_get_position()` always reports
previous clock rather than actual position until it is surpassed later.
To estimate the position correctly, Save the number of frames sent
to stream before it's reset, and use the value as the basis for
future position estimation.
According to the document,
AAudioStream_requestStop():
"The stream will stop after all of the data currently buffered has been played."
AAudioStream_requestPause():
"Pausing a stream will freeze the data flow but not flush any buffers."
aaudio_stream_get_position() calculates position using elapsed time
since last callback, including the time during stream is stopped.
To interpolate correctly, record the stop time and use it in calculation.
LLVM's libc++ is removing transitive inclusions among std header files in newer C++ versions, so user code must explicitly include needed std header files. In this case, cubeb_opensl.cpp must explicitly include <memory> for `std::unique_ptr` because, starting in C++23, <vector> no longers includes <memory>.
https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
```
libcubeb/src/cubeb_opensl.cpp:140:8: error: no template named 'unique_ptr' in namespace 'std'
140 | std::unique_ptr<cubeb_stream_params> input_params;
| ~~~~~^
```
aaudio_stream_get_position() returns incorrect result because
aaudio_stream_init() recycled destroyed stream where the
timing_info buffers contain stale data.
This can happen when the client side of the AAudio API fails to write
all the data to the server side, after the user callback has returned.
According to the reporter, this can be hit when a debugger is attached.
This fixes#767.
In some cases, weird sample rates can cause AudioUnit output
units to misbehave. Instead, use resampling for non-native rates
to make sure this does not happen.
cubeb-coreaudio-rs has hit a case when running its tests on MacOS 12
where it fails the `assert(destination && source);` in `PodCopy` because
it tried to push 0 samples to an auto_array of length 0, as the internal
auto_array buffer had not been allocated yet.