Provide copy operations for AudioDevice::LockHandle

This commit is contained in:
Dmitry Marakasov 2014-12-19 19:33:30 +03:00
parent 3dd739d4a3
commit 486dbb7bf4
2 changed files with 19 additions and 2 deletions

View File

@ -50,8 +50,8 @@ public:
LockHandle(LockHandle&& other) noexcept;
LockHandle& operator=(LockHandle&& other) noexcept;
LockHandle(const LockHandle& other) = delete;
LockHandle& operator=(const LockHandle& other) = delete;
LockHandle(const LockHandle& other);
LockHandle& operator=(const LockHandle& other);
};
typedef std::function<void(Uint8* stream, int len)> AudioCallback;

View File

@ -53,4 +53,21 @@ AudioDevice::LockHandle& AudioDevice::LockHandle::operator=(AudioDevice::LockHan
return *this;
}
AudioDevice::LockHandle::LockHandle(const AudioDevice::LockHandle& other) : device_(other.device_) {
SDL_LockAudioDevice(device_->device_id_);
}
AudioDevice::LockHandle& AudioDevice::LockHandle::operator=(const AudioDevice::LockHandle& other) {
if (&other == this)
return *this;
if (device_ != nullptr)
SDL_UnlockAudioDevice(device_->device_id_);
device_ = other.device_;
SDL_LockAudioDevice(device_->device_id_);
return *this;
}
}