Commit Graph

898 Commits

Author SHA1 Message Date
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
casey langen
5f7f2ac0e0 Fixed bug in Player::Destroy() that could try to detach an already
detached thread, leading to a crash.
2016-12-23 16:09:48 -08:00
casey langen
167d7aeb1c Added missing CrossfadeTransport and Crossfader source files. 2016-12-23 12:57:24 -08:00
casey langen
25e752892c - Fixed a bug in Player mixpoint dispatch
- Fixed MessageQueue::WaitAndDispatch() time arithmetic
2016-12-23 12:56:24 -08:00
casey langen
5cd3a8de10 Properly implemented play/pause semantics in output plugins (only WaveOut
was doing it properly!)
2016-12-23 12:53:57 -08:00
casey langen
a6372b3c92 A bunch of changes, some of which are still untested:
1. Added IDecoder::GetDuration() methods. Implemented it for all decoders.
2. Modified NomadDecoder to properly resolve duration for mp3 files that
do not have valid Xing headers (borrowed TagLib code)
3. Added IStream::GetDuration(), IPlayer::GetDuration(), and
ITransport::GetDuration()
4. Stubbed out a CrossfaderTransport (untested, unimplemented)
5. Added the concept of "MixPoints" to Player, so clients can be notified
when playback reaches certain points. (untested)
6. Started fleshing out a Crossfader implementation that uses a background
thread and a MessageQueue (untested)
7. Modified TransportWindow to pull the decoder's duration, then fallback
to the library duration if unavailable.
8. Added IDataStream::Seekable(), implemented in LocalFileStream.
2016-12-23 01:36:49 -08:00
Casey Langen
4b53439d68 Fixed macos compile. 2016-12-21 16:48:27 -08:00
casey langen
25fa580bde - Moved MessageQueue and friends into the core so it can be reused for
other things like timers and processing threads
- Cleaned up Player's listener interface a bit, and removed some more
  complexity from GaplessTransport
2016-12-21 16:41:44 -08:00
casey langen
1a00c83c7b Added MessageQueue::WaitAndDispatch(), which should be usable for
timer-like functionality.
2016-12-21 00:02:20 -08:00
casey langen
3aa4871e62 MessageQueue itself is no longer a singleton. However, Window has a static
instance.
2016-12-20 22:54:13 -08:00
casey langen
b832b96688 Simplified GaplessTransport -- we no longer need to keep around the weird
list of active players -- only the one that's actually active and the next
one.
2016-12-20 22:27:13 -08:00
casey langen
95fc9c725b Ensure the state flag in DirectSoundOut.h is an atomic. 2016-12-19 22:57:50 -08:00
casey langen
00bcb09a94 Version bump. 2016-12-19 22:52:37 -08:00
casey langen
928a74e4d5 OK, hopefully really fixed the volume -> attenuation conversion. Used VLC
as a reference implementation.
2016-12-19 16:24:20 -08:00
casey langen
cd15ece9f0 Fixed volume -> attenuation conversion in DirectSoundOut. 2016-12-18 19:40:11 -08:00
casey langen
d27b911ede - Added DirectSoundOut plugin for Windows
- Updated WasapiOut to pre-calculate the stream latency
2016-12-18 17:15:00 -08:00
Casey Langen
487f47a88c Version bump. 2016-12-14 07:47:09 -08:00
casey langen
dff09255a7 Fixed Linux compile. 2016-12-13 21:26:32 -08:00
casey langen
e299c2a98e Basic math is hard. Fixed scaling PCM_16 -> FLOAT_32 2016-12-13 21:10:47 -08:00
Casey Langen
4f0d98b850 Fixed OSX compile. 2016-12-13 20:40:48 -08:00
casey langen
5bae38bf65 Added a decoder for the (no)mad mpeg library. Gapless playback for a wider
variety of mp3 files!
2016-12-13 19:55:30 -08:00
casey langen
99f87237da Upgraded mpg123 to 1.23.8 for Win32 build. Now built from source and
doesn't require libgcc_s_sjlj-1 or the external libmpg123-0.dll.
2016-12-12 23:15:04 -08:00
casey langen
bdd8679865 Introduced an ID cache in the IndexerTrack to reduce DB churn when
indexing large amounts of files. This should improve indexing speed
at the expense of temporarily increased memory usage.
2016-12-11 21:48:35 -08:00
casey langen
2b7ad11c40 Version bump. 2016-12-10 00:07:36 -08:00
casey langen
b428b2d7d1 Fixed the GdiVis project to not put intermediates into the output
directory.
2016-12-10 00:07:19 -08:00
casey langen
ddacf4dc69 Make sure when we change main layouts we bring them to the top so all
views appear properly.
2016-12-10 00:06:47 -08:00
casey langen
be9284e4ef Fixed a really old bug in ListWindow where you could scroll past the last
item if items in the viewport were of heterogenous size.
2016-12-08 20:25:17 -08:00
casey langen
b3b423f931 Not feeling the new list title style. Reverted. 2016-12-08 00:08:25 -08:00
casey langen
3cceef8d93 Dangerous low-level change #3
Dramatically reduce unnecessary redraws by introducing a dirty bit to the
Window instances. Also changed the order in which some windowing
operations are performed.
2016-12-07 22:11:06 -08:00
casey langen
0a76f0f4f9 Tweaked the look and feel of the new header in BrowseLayout. 2016-12-07 16:38:40 -08:00
casey langen
ec2632431a - One more PDCurses update -- I think I added some bad binaries last
night.
- A couple bug fixes with Window::Move and Window::SetSize
2016-12-07 14:24:41 -08:00
casey langen
85c101ca54 Make settings layout more compact. 2016-12-07 07:08:25 -08:00
casey langen
4a374d7615 Modified behavior of Window to destroy panels when hiding, instead of
calling hide_panel(). This seems to fix some PDCurses-specific crashes.
2016-12-07 07:06:58 -08:00
casey langen
7c34140d2b Updated Win32a curses build. 2016-12-07 01:14:28 -08:00
casey langen
d472b56ca3 Another dangerous low-level change: updated the way LayoutBase::Layout()
works to be similar to Window::Redraw(). The default implementation now
does bounds checking and calls through to OnLayout() instead. Doing this
ensures we don't spend time laying out views that are not visible. Also
removed a bunch of extraneous Layout() calls.
2016-12-07 00:26:06 -08:00
casey langen
95f383221c Super dangerous low-level changes to cursespp to fix some fundamental
issues:

- Added OnRedraw() template method that should be used instead of Redraw()
  for the normal case. Redraw() will do some visibility and bounds
  checking on behalf of the caller.
- Added IWindow::OnParentVisibilityChanged() that is used by sub-views to
  know when their parent changes. This is so Windows can hide themselves
  while retaining their internal visibility flags.
- A couple bounds checking and corner case fixes in Window.

In the end this gives us:

- Fewer unnecessary redraws (in theory)
- The ability to set sub-view visibility indepdent of parent view, without
  the need to call Layout::AddWindow and Layout::RemoveWindow
2016-12-06 23:59:03 -08:00
casey langen
fe55c92a12 Added OnRedraw() template method for Window subclasses. Redraw() will
check visibility before requesting a repaint.
2016-12-06 20:33:51 -08:00
casey langen
f56ffb0bcf Added new Redraw() base class method, and renamed Repaint() to
Invalidate(). Also renamed Window::Invalidate to Window::InvalidateScreen
2016-12-06 19:16:26 -08:00
casey langen
68f574235b Fixed search results -> browse category title bug. 2016-12-06 01:00:08 -08:00
casey langen
1017d46016 Improved header layout in settings, and dynamically add heads in
BrowseLayout based on screen size.
2016-12-06 00:44:59 -08:00
casey langen
05b62839b0 Added speaker channel constants. 2016-12-06 00:44:30 -08:00
casey langen
94aef06a7d Hush some unnecessary logging in PulseOut.cpp 2016-12-05 20:23:10 -08:00
casey langen
98c11a9706 Fixed volume initialization in PulseOut 2016-12-05 20:21:26 -08:00
casey langen
da6e635bd3 Fixed compile on Linux and macOS. 2016-12-05 20:20:02 -08:00
casey langen
ae88f6ee31 Added the ability for the user to select their preferred output plugin! 2016-12-05 20:17:58 -08:00
Casey Langen
3e6f66d986 Added a PulseAudio output plugin for Linux. 2016-12-05 17:00:13 -08:00
casey langen
487502fd1f Modified IOutput interface to supply an optional latency. Updated
WasapiOut to send the proper latency.
2016-12-04 23:45:07 -08:00
casey langen
a797d4db9d Added an initial WASAPI output plugin implementation. Down with waveout!
(maybe).
2016-12-04 18:43:26 -08:00
Casey Langen
25506a009d Version bump to 0.5. 2016-12-04 12:35:40 -08:00
casey langen
a3b7a541cc Removed some unused #includes from LocalFileStream. This should also clean
up some compile warnings on non Windows platforms.
2016-12-04 12:16:58 -08:00
casey langen
d8685e314c Fixed #pragma once compile warning. 2016-12-04 11:47:38 -08:00
casey langen
a26fc53353 Ramped the default Stream buffer size from 1024 -> 2048 samples per
channel. This further reduces CPU usage.
2016-12-03 21:30:15 -08:00
casey langen
0e6fbb8e3d - Improved Stream class by preallocating all required buffers using a
single contiguous float array for all samples.
- Fixed WaveOut to reuse WaveOutBuffer instances so we aren't constantly
  reallocating them.
- Removed boost dependency from WaveOut plugin
- Modified Buffer to allow creation with a managed float array
- Removed DynamicStream.h/.cpp
2016-12-03 21:16:48 -08:00
casey langen
0276b0f594 A couple more small ALSA bug fixes. 2016-12-03 17:23:51 -08:00
casey langen
e381a842f8 Tweaked AlsaOut's behavior when adding buffers in the paused state. 2016-12-03 17:10:09 -08:00
casey langen
4600b801b6 Small fix to Player's stream resolution logic -- we should also return a
DynamicStream when the visualizer is hidden.
2016-12-03 15:19:10 -08:00
Casey Langen
896f8459df Fixed a compile warning in PlaybackService.cpp. 2016-12-03 15:12:08 -08:00
casey langen
4c86164f80 Added DynamicStream back to Windows build, and fixed CddaDataStream
plugin. Also cleaned up a memory leak in GdiVis.
2016-12-03 15:08:34 -08:00
casey langen
3bb07daba4 Remember volume and repeat mode across app launches. Been meaning to do
this for a while.
2016-12-03 14:54:16 -08:00
Casey Langen
53429bdf92 Moved some stream decoder and dsp loading logic out of the actual Stream implementation, and into a helper namespace so it can be re-used. Added back DynamicStream to test on Windows. 2016-12-03 14:52:37 -08:00
casey langen
f1ffce5662 Re-enabled time smoothing. 2016-12-02 23:34:45 -08:00
casey langen
4febabe234 Removed debug info from release builds in many of the plugins to reduce
filesize.
2016-12-02 16:30:13 -08:00
casey langen
3657a995a1 Moved Player/Transport interaction to using a simple callback/listener
interface instead of events. Events were causing complications with
multi-threading, and introducing unnecessary runtime complexity.
2016-12-02 15:49:36 -08:00
casey langen
c58607f014 Just kidding about fixing the clang compile -- remove static qualifier to
hopefully fix it for real.
2016-12-02 09:42:18 -08:00
casey langen
94f0fb1653 Declare the playerThreadProc prototype -- this should fix the clang
compile.
2016-12-02 09:40:33 -08:00
casey langen
b2e90b8d72 Cleaned up some unused stuff in GdiVis and removed time smoothing for now. 2016-12-02 09:35:55 -08:00
casey langen
f672446ebf Added a Win32 GDI visualizer. 2016-12-02 01:12:49 -08:00
casey langen
02282e4991 boost -> std for threading. 2016-12-01 22:52:57 -08:00
casey langen
5e48e7cf33 Clean up Player and GaplessTransport interaction. No more goofy defers. 2016-12-01 22:14:58 -08:00