Skip to content

Commit

Permalink
SOUND: Use DisposablePtr in LoopingAudioStream
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 29, 2016
1 parent 146bd9a commit 8b33165
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/sound/audiostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@
namespace Sound {

LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, size_t loops, bool disposeAfterUse)
: _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) {
: _parent(stream, disposeAfterUse), _loops(loops), _completeIterations(0) {
}

LoopingAudioStream::~LoopingAudioStream() {
if (_disposeAfterUse)
delete _parent;
}

size_t LoopingAudioStream::readBuffer(int16 *buffer, const size_t numSamples) {
Expand Down
4 changes: 2 additions & 2 deletions src/sound/audiostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

#include "src/common/util.h"
#include "src/common/types.h"
#include "src/common/disposableptr.h"

namespace Sound {

Expand Down Expand Up @@ -183,8 +184,7 @@ class LoopingAudioStream : public AudioStream {
uint64 getDurationOnce() const;

private:
RewindableAudioStream *_parent;
bool _disposeAfterUse;
Common::DisposablePtr<RewindableAudioStream> _parent;

size_t _loops;
size_t _completeIterations;
Expand Down

0 comments on commit 8b33165

Please sign in to comment.