Commit Graph

996 Commits

Author SHA1 Message Date
casey langen
8c4a4ab248 Similar to some other micro-optimizations, don't keep recreating a new
list of messages to dispatch in MessageQueue -- create it once as a member
variable and reuse.

Also tweaked stream and output buffer sizes.
2016-12-31 20:35:45 -08:00
casey langen
8f51b6c191 Added a little more state to Player to cut down on CPU thrash when dealing
with mixpoints. We now cache the next mixpoint time when the set of
mixpoints changes (or we seek), so we don't always have to iterate over
all of them.

Also, don't re-create the temp MixPointList in Player::OnBufferProcessed
-- there's a bit of overhead involved there. Instead, use a temp member
variable.
2016-12-31 15:19:25 -08:00
casey langen
60e120e1e9 - When asked to play a track in the CrossfadeTransport, first check to see
if it's already available as the next track. It very well may be!
- Small code cleanups.
2016-12-31 11:41:44 -08:00
Casey Langen
d865931fab Fixed *nix compile. 2016-12-30 21:57:48 -08:00
casey langen
7efcf60e1d General repo/build/project cleanup:
- Removed unused md5 and fftw-3 remnants
- Renamed 3rdparty/lib -> 3rdparty/win32_lib to match win32_include
- Removed core/sdk/config.h
- Fixed various compiler warnings
2016-12-30 21:49:50 -08:00
casey langen
f0505363c5 Tweaked the way the CPU load easling logic works in Player. 2016-12-29 18:11:21 -08:00
casey langen
6ac1926611 Version bump -- we're getting close to release. 2016-12-29 16:06:18 -08:00
casey langen
1c68635e4d Moved common CPU easing calculations from DirectSoundOut and WasapiOut and
into Player. This also fixes Visualizer sluggishness.
2016-12-29 16:05:42 -08:00
casey langen
887fd77516 - Ease CPU load in both DirectSoundOut and WasapiOut by being less
aggressive about keeping the internal buffer 100% full. For now, 75%
  full should be sufficient
- Fixed ALL OutputPlay values to be negative -- in some cases output
  plugins were returning a "0" delay which was causing buffers to not get
  properly cleaned up, causing bad memory leaks.
2016-12-28 20:38:49 -08:00
casey langen
15d2ea2c17 A more generic strategy for avoid sleeping in output plugins that may have
lock contention: IOutput::Play() returns an int with a negative number as
an error code, or a positive value as the number of milliseconds to wait
until trying to play the buffer again.
2016-12-28 01:10:03 -08:00
casey langen
ef3fd3c7cc Don't block the UI when switching from Crossfade -> Gapless transport. 2016-12-27 21:02:54 -08:00
casey langen
1be4e3fd70 Added more error handling to PlaybackOverlays -- also, ensure we set the
selected index on the transport and output device overlays.
2016-12-27 19:07:08 -08:00
casey langen
76fbc5e6bd Added ListOverlay::SetSelectedIndex 2016-12-27 19:06:57 -08:00
Casey Langen
a2d95a6698 Improved the transport selection logic to use a ListOverlay and also display an error for invalid outputs. 2016-12-27 17:37:33 -08:00
casey langen
c3653ffa19 Yikes! Fixed a really, really bad first run bug I never noticed because I
never go through the first run process.
2016-12-27 17:33:51 -08:00
casey langen
3641acd7bf Fixed a crash that could happen if the decoder reports the wrong stream length and the crossfade mixpoint doesn't fire. 2016-12-27 16:57:56 -08:00
casey langen
b4b534a87b Fixed a couple state management bugs in Player and CrossfadeTransport. 2016-12-27 10:14:11 -08:00
casey langen
c803d2b671 A small bugfix to restore volume after switching transports. 2016-12-27 01:15:40 -08:00
casey langen
1dbdf73c5c Fixed *nix and macOS compile. 2016-12-27 01:12:01 -08:00
casey langen
153f12326c Added UI to switch between transport types at runtime! Needs to be
converted to a ListOverlay, but it works!
2016-12-27 01:07:29 -08:00
casey langen
9c9b003dab Fixed DirectSoundOut to not stop after draining -- no longer necessary
because Drain() is fixed, and it's actually causing issues with gapless
playback.
2016-12-27 01:07:03 -08:00
casey langen
ca455e108b Jeeze one of these times I'll get this right. 2016-12-26 22:04:32 -08:00
casey langen
d85251a02f - Fixed WasapiOut pause/resume behavior, slightly broken after reducing lock
contention.
- Fixed DirectSoundOut pause/resume behavior
- Fixed CrossfadeTransport to call player->Play() after resuming the
  output. This was causing the player to wait a while for a timeout before
  writing buffers instead of continuing to write them immediately.
2016-12-26 21:57:39 -08:00
casey langen
4fd664b08a - Fixed Crossfader to adjust for time spent actually adjusting the
output's volume

- Reduced lock contention in WasapiOut and DirectSoundOut by caching
  AddRef()'d copies of important interfaces in the ::Play() methods.
2016-12-26 15:22:49 -08:00
casey langen
6bffe8a54d Adjusted Crossfader's number of ticks per second to make smoothing fader on output drivers that do software mixing (like ALSA) 2016-12-26 14:13:10 -08:00
casey langen
a02f94ef0c * Added correct Latency() calculation to AlsaOut
* Changed default Linux output device to PulseAudio
2016-12-26 10:59:56 -08:00
Casey Langen
7dc7cf5062 When crossfading, make sure the output is drained before shutting it down. 2016-12-26 10:03:45 -08:00
casey langen
f618e15abb Fixed a race condition and a dead lock. Also removed a bit of extraneous locking in Player. 2016-12-25 23:37:03 -08:00
casey langen
5f64b205cf Hide the main window immediately on exit in the Win32 build. This allows
us to cross fade the audio out without appearing to be frozen.
2016-12-25 20:44:18 -08:00
Casey Langen
eb175cd66c When using the CrossfadeTransport, fade music out if stopped (or the app is exited). 2016-12-25 19:21:57 -08:00
casey langen
105a72457e Sane implementation of DirectSoundOut::Drain() -- just write silence to
the playback buffer until it's full.
2016-12-25 11:06:23 -08:00
casey langen
df339ab61f Fixes to DirectSoundOut::Drain() and WasapiOut::Drain() -- why do the
Windows APIs make this so difficult??
2016-12-25 01:19:02 -08:00
Casey Langen
32fced8274 Fixed PulseOut and also bumped all output plugin versions. 2016-12-25 00:03:13 -08:00
casey langen
f25fb85c16 Added IOutput::Drain() and implementations for all the output devices.
Call this method at the very end of the Player threadProc, just before
destroying the instance.
2016-12-24 23:56:53 -08:00
casey langen
39086c6145 Fixed bugs in auto-stop when arriving at the end of the playlist. 2016-12-24 22:10:49 -08:00
casey langen
01c9b6cb3b Some more low-level surgery:
1. Player now manages a list of listeners so more than one client can be
notified of events.
2. Crossfader no longer awkwardly receives Player events via the
Transport, it attaches and detaches to the player as appropriate.
3. Renamed Player::PlayerEventListener => Player::EventListener, and added
stubbed implementations for all the listener methods.
2016-12-24 20:53:52 -08:00
Casey Langen
698227cff1 Fixed Player::Detach() logic for CrossfadeTransport. Also simplified a bit of Player instance reset checks in GaplessTransport. 2016-12-24 18:13:56 -08:00
casey langen
ad390fb6f1 Ensure GaplessTransport always detaches from before destroying players. 2016-12-24 17:31:32 -08:00
casey langen
27270e1cf7 Oops, fixed equality check in Player::Detach() 2016-12-24 17:20:32 -08:00
casey langen
ddfe18cbda Added safe listener detach logic to Player and added it to
GaplessTransport.
2016-12-24 17:17:45 -08:00
casey langen
4356397f40 Fixed the CrossfadeTransport to work properly with muted streams -- or
streams that become muted during the fading process.
2016-12-24 14:09:16 -08:00
casey langen
e2ef4dda3f Added MessageQueue::Contains() and modified MessageQueue::Remove() to
return the number of elements removed.
2016-12-24 14:09:16 -08:00
Casey Langen
8ea81ae9a8 More state management fixes in CoreAudioOut.cpp -- it no longer glitches when pausing/resuming/stopping using the CrossfadeTransport. 2016-12-24 13:03:11 -08:00
casey langen
0184f1c8e8 Tweaked CoreAudioOut state flags to be more similar to most of the other
outputs.
2016-12-24 12:49:05 -08:00
casey langen
cfee726c02 * Fixed a memory leak in WasapiOut
* Added a new OnPlayerPrepared() callback method to the Player's listener
interface.

* More work on the crossfader. It kind of works now in some cases. Still a
ways to go...
2016-12-24 01:01:08 -08:00
casey langen
5b5399322f Ensure the Player's listener is zero'd out as part of Player::Destroy().
Also cleaned up a couple small warnings.
2016-12-23 21:38:16 -08:00
Casey Langen
483dfa65cd Fixed Linux compile. 2016-12-23 20:25:49 -08:00
Casey Langen
40e9fc90c3 Fixed macos compile. 2016-12-23 18:58:18 -08:00
casey langen
1f0b306987 More incremental work to support a crossfading transport. 2016-12-23 18:37:07 -08:00
casey langen
06a83344b7 - Fixed DirectSoundOut to fallback to software mixing if necessary
- Fixed WasapiOut to do local stream volume control, instead of session
  (i.e. app-wide) volume control.
2016-12-23 18:36:19 -08:00