mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 23:59:37 +02:00
AudioIOStartStreamOptions includes the sample rate
This commit is contained in:
parent
5997beec9d
commit
36e5b4fbbc
@ -1520,12 +1520,14 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
const NoteTrackArray &midiPlaybackTracks,
|
||||
#endif
|
||||
double sampleRate, double t0, double t1,
|
||||
double t0, double t1,
|
||||
const AudioIOStartStreamOptions &options)
|
||||
{
|
||||
if( IsBusy() )
|
||||
return 0;
|
||||
|
||||
const auto &sampleRate = options.rate;
|
||||
|
||||
// We just want to set mStreamToken to -1 - this way avoids
|
||||
// an extremely rare but possible race condition, if two functions
|
||||
// somehow called StartStream at the same time...
|
||||
|
@ -88,9 +88,11 @@ DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, -1);
|
||||
// To avoid growing the argument list of StartStream, add fields here
|
||||
struct AudioIOStartStreamOptions
|
||||
{
|
||||
AudioIOStartStreamOptions()
|
||||
explicit
|
||||
AudioIOStartStreamOptions(double rate_)
|
||||
: timeTrack(NULL)
|
||||
, listener(NULL)
|
||||
, rate(rate_)
|
||||
, playLooped(false)
|
||||
, cutPreviewGapStart(0.0)
|
||||
, cutPreviewGapLen(0.0)
|
||||
@ -106,6 +108,7 @@ struct AudioIOStartStreamOptions
|
||||
|
||||
TimeTrack *timeTrack;
|
||||
AudioIOListener* listener;
|
||||
double rate;
|
||||
bool playLooped;
|
||||
double cutPreviewGapStart;
|
||||
double cutPreviewGapLen;
|
||||
@ -163,9 +166,8 @@ class AUDACITY_DLL_API AudioIO final {
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
const NoteTrackArray &midiTracks,
|
||||
#endif
|
||||
double sampleRate, double t0, double t1,
|
||||
const AudioIOStartStreamOptions &options =
|
||||
AudioIOStartStreamOptions());
|
||||
double t0, double t1,
|
||||
const AudioIOStartStreamOptions &options);
|
||||
|
||||
/** \brief Stop recording, playback or input monitoring.
|
||||
*
|
||||
|
@ -1131,7 +1131,7 @@ AudacityProject::~AudacityProject()
|
||||
|
||||
AudioIOStartStreamOptions AudacityProject::GetDefaultPlayOptions()
|
||||
{
|
||||
AudioIOStartStreamOptions options;
|
||||
AudioIOStartStreamOptions options { GetRate() };
|
||||
options.timeTrack = GetTracks()->GetTimeTrack();
|
||||
options.listener = this;
|
||||
return options;
|
||||
|
@ -2534,7 +2534,7 @@ void Effect::Preview(bool dryOnly)
|
||||
double previewLen;
|
||||
gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
|
||||
|
||||
double rate = mProjectRate;
|
||||
const double rate = mProjectRate;
|
||||
|
||||
if (isNyquist && isGenerator) {
|
||||
previewDuration = CalcPreviewInputLength(previewLen);
|
||||
@ -2637,12 +2637,13 @@ void Effect::Preview(bool dryOnly)
|
||||
NoteTrackArray empty;
|
||||
#endif
|
||||
// Start audio playing
|
||||
AudioIOStartStreamOptions options { rate };
|
||||
int token =
|
||||
gAudioIO->StartStream(playbackTracks, recordingTracks,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
empty,
|
||||
#endif
|
||||
rate, mT0, t1);
|
||||
mT0, t1, options);
|
||||
|
||||
if (token) {
|
||||
int previewing = eProgressSuccess;
|
||||
|
@ -634,7 +634,7 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
NoteTrackArray(),
|
||||
#endif
|
||||
p->GetRate(), tcp0, tcp1, myOptions);
|
||||
tcp0, tcp1, myOptions);
|
||||
} else
|
||||
{
|
||||
// Cannot create cut preview tracks, clean up and exit
|
||||
@ -655,7 +655,7 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
t->GetNoteTrackArray(false),
|
||||
#endif
|
||||
p->GetRate(), t0, t1, options);
|
||||
t0, t1, options);
|
||||
}
|
||||
if (token != 0) {
|
||||
success = true;
|
||||
@ -1085,7 +1085,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
midiTracks,
|
||||
#endif
|
||||
p->GetRate(), t0, t1, options);
|
||||
t0, t1, options);
|
||||
|
||||
bool success = (token != 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user