1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 09:20:16 +01:00
Commit Graph

413 Commits

Author SHA1 Message Date
Paul Licameli
1baf12d7bc Bug1960: position of play head during scrub right to left 2018-09-01 09:56:26 -04:00
James Crook
3f7c639c3f Make the 'wait for fade out' latency dependent.
This gives time for the fading out to clear the sound card, OR if
we would wait around too long, just close down the stream without waiting.
2018-09-01 10:24:50 +01:00
Paul Licameli
d050afb658 Scrubbing calculation now needs clock precision greater than sample rate 2018-08-29 15:01:31 -04:00
James Crook
919571e79f Bug 1950 - Pause mutes and stops head progressing, but does not 'pause' audio.
Logic changed to delay pause by one frame, if there is a need to fade out.
So we calculate whether we are already faded out, and if we are pause, otherwise delay the real pause for one frame.
2018-08-29 19:54:11 +01:00
James Crook
b5f9acefa4 Fix some warnings in AudioIO.cpp 2018-08-29 14:00:57 +01:00
David Bailes
a5e9fb9e34 Bug 1949: WASAPI playback stops before the end of the selection
Problem: When using WASAPI on Windows, the last "latency buffer length" of a selection is not played. This is a fairly nasty bug for those relying on playback when making fine adjustments to the position of the cursor, or the start or end of selection.

During playback the "latency buffer length" has no effect on the actual latency of the playback, but the playback cursor is positioned as if the "latency buffer length" did have an effect, that is, it is positioned by this amount after the audio being played.

So an obvious workaround is for the user to set the latency buffer length to zero when using WASAPI. However they then have to remember to change it if they use another audio host.

Fix: The real problem is presumably a portaudio bug, but this fix just hard codes the workaround given above. For playback, when using WASAPI, set the suggested latency to 0, regardless of user setting.
2018-08-29 13:47:32 +01:00
Paul Licameli
85f13b433f Fix Linux build... uniform initialization not implemented right in g++? 2018-08-28 07:36:39 -04:00
Paul Licameli
eae38b0676 Fix Linux build 2018-08-28 06:20:04 -04:00
Paul Licameli
9aad60d12c Make polling loop period slightly shorter than Audio thread loop...
... but we don't need to make it as precise, using steady_clock.

Do this so that the Audio thread doesn't read the same polling message twice,
halting the scrub.  It's all right that it might miss one of the messages
instead.
2018-08-27 17:02:37 -04:00
Paul Licameli
e4e7a814c8 FillBuffers won't quit too early priming the RingBuffer for scrub 2018-08-27 17:02:36 -04:00
Paul Licameli
ba52753ff7 Scrub options don't need starting time 2018-08-27 17:02:36 -04:00
Paul Licameli
9d17d335b7 Poller thread leaves messages, Audio interprets; a buffer not a queue 2018-08-27 16:53:16 -04:00
Paul Licameli
832bcef3a6 Postpone work from ctor of ScrubState to the first call of Update 2018-08-27 16:53:16 -04:00
Paul Licameli
a62cf53161 Make AudioThread wake-ups as uniformly spaced as we can 2018-08-27 16:53:16 -04:00
Paul Licameli
4e461f8755 Explicit scrub shut-down signal replaces the "nudge" 2018-08-27 16:41:45 -04:00
Paul Licameli
550d514e06 Changes of names and comments relating to scrub, don't mention queue 2018-08-26 10:01:06 -04:00
Paul Licameli
4a98ba03dd Remove ScrubQueue compensation for Producer overflowing...
... which were meant to fix growth in lag between mouse movement and play head
movement.

Recent rewrites to keep RingBuffer more populated during scrub and seek should
make this unnecessary.
2018-08-26 09:59:35 -04:00
Paul Licameli
8badb0a933 Rewrite the insertion of silences into scrub, combining queue entries 2018-08-26 09:12:53 -04:00
Paul Licameli
9727968b94 move some functions 2018-08-25 20:08:10 -04:00
Paul Licameli
69435c9191 Simplify ScrubQueue to involve only two threads...
... Remove Consumer() and fields used only by it; rename Transformer() as
Consumer().

A bit less contention for the scrub queue mutex, then.
2018-08-25 20:08:09 -04:00
Paul Licameli
81a3a7d339 Use the TimeQueue to communicate play head position updates for scrubbing...
... from the Audio thread to the PortAudio thread;  the old
ScrubQueue::Consumer() function keeps only a vestigial purpose to prevent the
scrub queue from blocking.
2018-08-25 20:08:09 -04:00
Paul Licameli
389ab0c8d0 Fewer calls to RingBuffer::Put in case of trailing zeroes...
... so there is only one update per track of the atomics in RingBuffer in each
pass of the loop in FillBuffers, which will be needed to synchronize RingBuffer
and TimeQueue correctly.
2018-08-25 20:08:09 -04:00
Paul Licameli
b2df5e0673 Declare and allocate time value queue 2018-08-25 20:08:08 -04:00
Paul Licameli
67a9823434 split out function AdvancedTrackTime; more caution about termination 2018-08-25 20:08:08 -04:00
Paul Licameli
e91918042a Don't let the ring buffer empty when seeking past end of track...
... just allow a short stutter padded with silence in that case.
2018-08-25 20:08:08 -04:00
Paul Licameli
2806f40ab5 Don't let the RingBuffer run dry when seek-drag is very slow...
... but not stopped.  This may even make the play head back up and re-play a
little bit.
2018-08-25 20:08:08 -04:00
Paul Licameli
5cfbfd364e Set the playback RingBuffer latency appropriately for seeking 2018-08-25 20:08:07 -04:00
Paul Licameli
111d2c8673 Can specify a minimum to maintain in the playback RingBuffer...
... this may be more than the batch size used in ongoing playback.

It is expected that this larger batch size is used only once when priming
the queue before starting play.  But then FillBuffers() may attempt to
refill up to the minimum in case demand is outpacing supply.

Thus the new number defines a "yellow zone" for the queue.
2018-08-25 20:08:07 -04:00
Paul Licameli
06fe9e843e remove some casting 2018-08-25 20:08:07 -04:00
Paul Licameli
45231b8f6a Consume equal amounts from play ring buffers in each callback pass...
... which should be the whole framesPerBuffer normally.

Also rename another function used in producing the samples.
2018-08-25 20:08:07 -04:00
Paul Licameli
8a6351d9cd Guarantee cleanup of partial allocation on all error return paths...
... such as when allocating for capture channels fails after that for
playback succeeds
2018-08-25 20:08:06 -04:00
Paul Licameli
3a94acd631 Remove unnecessary variable 2018-08-25 20:08:06 -04:00
Paul Licameli
03678eccba use mRate not sampleRate 2018-08-25 20:08:06 -04:00
Paul Licameli
575e631d49 line lengths 2018-08-25 20:08:06 -04:00
Paul Licameli
8e151aba8d Split out AudioIO::AllocateBuffers 2018-08-25 20:08:05 -04:00
Paul Licameli
eeb5f1ec20 Revert "Fix the hiccup at the start of scrub or play at speed..."
(It didn't really achieve what that commit comment said)

This reverts commit 26f72b110c.
2018-08-25 19:42:12 -04:00
James Crook
74d0420b96 Bug 1763 - Clicks on starting/stopping playback.
Does not fix the Loop-Play part.
2018-08-25 17:21:18 +01:00
James Crook
b91300caf0 Bug 1947 - Clicky play when dynamically changing number of playing channels
Rather than 'cut' (i.e. drop, not cut as in 'cut preview') channels immediately, we now only do so
if their last gain was already 0.0.  Instead they micro-fade out.  Later when the channels come back,
their last gain will be 0.0, so they will micro-fade in.

A comment explains that the code would be cleaner if we just computed gains, and not whether to
drop channels.
2018-08-25 13:07:45 +01:00
James Crook
0ce83abbfb Bug 1940 - Clicky play when adjusting Pan or Volume TCP controls 2018-08-24 22:30:20 +01:00
Paul Licameli
06b5d2e945 Bug1932 followup: Times, not sample counts, in scrubbing options...
... because the correct rate is not known where options are constructed
2018-08-20 20:44:10 -04:00
James Crook
aaad7dd08d Bug 1932 - Scrubbing (and Play-at-speed) with WASAPI host (MSW only) or very short buffer preference (on Mac also) is very clicketty 2018-08-18 20:35:18 +01:00
Paul Licameli
26f72b110c Fix the hiccup at the start of scrub or play at speed...
... We need to start the polling of mouse state before starting the audio
stream, and not "nudge" AudioThread, so that AudioThread primes the ring
buffer correctly, not inserting some silence.

This requires yields to timer events in AudioIO::StartStream.
2018-08-16 21:21:44 -04:00
Steve Daulton
11da92d668 Allow capture retries if time since Rescan() < 10s
The time since Rescan() of recording device is the important factor,
not the "newness" of the project.
2018-08-13 00:33:38 +01:00
Steve Daulton
835abd9be3 bug 1885 Linux: Allow retries when opening capture
On launch, Audacity scanning the sound system causes Pulse to grab
exclusive control of the audio device, causing the device to be
unavailable until Pulse times out and releases it.

If an attempt is made to start recording from the hardware device (hw:)
immediately after launch, PortAudio will time out before the device is
released. In this case we need to retry opening the capture stream.

(This also applies to monitoring).
2018-08-12 19:14:56 +01:00
Steve Daulton
1d22ca5789 Improve error message when capture stream fails
Rather than just guessing at the cause of the error, include the actual
error string from PortAudio.
2018-08-12 19:14:56 +01:00
Paul Licameli
3886113b91 More efficiency in TrackTimeUpdate 2018-08-11 20:37:23 -04:00
Paul Licameli
ce1ce688ff Try to clarify real time / track time distinction in comments...
... Rather than the confusing old terminology of "warped" time, meaning the
real time after accounting for time track, though that persists mostly in the
names of variables now mostly used only within PlaybackSchedule.

"Track" time refers to a position in a wave track, as indexed by the time
ruler.

"Real" time is indexed by the other scale of numbers drawn in the time track,
which is drawn on the screen with nonuniform spacing (so "warped" in that
sense), but it corresponds to uniform actual time.
2018-08-11 15:14:18 -04:00
Paul Licameli
6126f2f626 Make a one-time dynamic check that atomic<double> doesn't use mutexes 2018-08-11 00:29:44 -04:00
Paul Licameli
3f1d9ab8c1 P & R recording: change color of pin button, as for play indicator 2018-08-11 00:26:34 -04:00
Paul Licameli
0d9972b3e0 Some member functions of AudioIO can be const 2018-08-10 22:58:33 -04:00