Skip to content

Commit

Permalink
update AudioSource open implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
CrSjimo committed Oct 21, 2024
1 parent 7ed9afd commit 97d0402
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/source/AudioSourceClipSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace talcs {
bool AudioSourceClipSeries::open(qint64 bufferSize, double sampleRate) {
Q_D(AudioSourceClipSeries);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (d->openAllClips(bufferSize, sampleRate))
return AudioSource::open(bufferSize, sampleRate);
return false;
Expand Down
1 change: 1 addition & 0 deletions src/core/source/BufferingAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ namespace talcs {
bool BufferingAudioSource::open(qint64 bufferSize, double sampleRate) {
Q_D(BufferingAudioSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
flush();
if (!d->src->open(bufferSize, sampleRate))
return false;
Expand Down
1 change: 1 addition & 0 deletions src/core/source/FutureAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace talcs {
bool FutureAudioSource::open(qint64 bufferSize, double sampleRate) {
Q_D(FutureAudioSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
switch (status()) {
case Running:
case Paused:
Expand Down
1 change: 1 addition & 0 deletions src/core/source/FutureAudioSourceClipSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace talcs {
bool FutureAudioSourceClipSeries::open(qint64 bufferSize, double sampleRate) {
Q_D(FutureAudioSourceClipSeries);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (d->openAllClips(bufferSize, sampleRate))
return AudioSource::open(bufferSize, sampleRate);
return false;
Expand Down
1 change: 1 addition & 0 deletions src/core/source/MetronomeAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace talcs {
bool MetronomeAudioSource::open(qint64 bufferSize, double sampleRate) {
Q_D(MetronomeAudioSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (d->majorBeatSource)
if (!d->majorBeatSource->open(bufferSize, sampleRate))
return false;
Expand Down
1 change: 1 addition & 0 deletions src/core/source/MixerAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace talcs {
bool MixerAudioSource::open(qint64 bufferSize, double sampleRate) {
Q_D(MixerAudioSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (d->start(bufferSize, sampleRate)) {
return AudioSource::open(bufferSize, sampleRate);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/core/source/NoteSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ namespace talcs {

bool NoteSynthesizer::open(qint64 bufferSize, double sampleRate) {
Q_D(NoteSynthesizer);
AudioSource::close();
flush(true);
return AudioSource::open(bufferSize, sampleRate);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/source/PositionableMixerAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace talcs {
Q_D(PositionableMixerAudioSource);
QMutexLocker locker(&d->mutex);
d->stop();
AudioSource::close();
if (d->start(bufferSize, sampleRate)) {
d->setNextReadPositionToAll(d->position);
return PositionableAudioSource::open(bufferSize, sampleRate);
Expand Down
4 changes: 0 additions & 4 deletions src/core/source/SineWaveAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ namespace talcs {
setFrequency(frequencyIntegration);
}

bool SineWaveAudioSource::open(qint64 bufferSize, double sampleRate) {
return AudioSource::open(bufferSize, sampleRate);
}

qint64 SineWaveAudioSource::processReading(const AudioSourceReadData &readData) {
Q_D(SineWaveAudioSource);
QMutexLocker locker(&d->mutex);
Expand Down
1 change: 0 additions & 1 deletion src/core/source/SineWaveAudioSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace talcs {
explicit SineWaveAudioSource(const std::function<double(qint64)> &frequencyIntegration);
~SineWaveAudioSource() override = default;

bool open(qint64 bufferSize, double sampleRate) override;
qint64 length() const override;

void setFrequency(double frequency);
Expand Down
1 change: 1 addition & 0 deletions src/core/source/TransportAudioSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ namespace talcs {
bool TransportAudioSource::open(qint64 bufferSize, double sampleRate) {
Q_D(TransportAudioSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
d->playbackStatus = Paused;
if (d->src && !d->src->open(bufferSize, sampleRate)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/format/source/AudioFormatInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ namespace talcs {
bool AudioFormatInputSource::open(qint64 bufferSize, double sampleRate) {
Q_D(AudioFormatInputSource);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (!d->io)
return false;
if (d->io->open(AbstractAudioFormatIO::Read)) {
Expand Down
1 change: 1 addition & 0 deletions src/midi/integrator/AbstractMidiMessageIntegrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace talcs {
bool AbstractMidiMessageIntegrator::open(qint64 bufferSize, double sampleRate) {
Q_D(AbstractMidiMessageIntegrator);
QMutexLocker locker(&d->mutex);
AudioSource::close();
if (d->stream && !d->stream->open(bufferSize, sampleRate))
return false;
return AudioSource::open(bufferSize, sampleRate);
Expand Down
1 change: 1 addition & 0 deletions src/midi/integrator/AudioMidiStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace talcs {
bool AudioMidiStream::open(qint64 bufferSize, double sampleRate) {
Q_D(AudioMidiStream);
QMutexLocker locker(&d->filterMutex);
AudioStreamBase::close();
if (d->filter.loadRelaxed() && !d->filter.loadRelaxed()->open(bufferSize, sampleRate)) {
return false;
}
Expand Down

0 comments on commit 97d0402

Please sign in to comment.