Add AudioSpec copy constructor

Since callback is non-copyable, new callback is specified
This commit is contained in:
Dmitry Marakasov 2014-11-30 00:44:43 +03:00
parent e034f6cd67
commit 7ebd613d01
2 changed files with 8 additions and 0 deletions

View File

@ -44,6 +44,7 @@ private:
public:
AudioSpec();
AudioSpec(int freq, SDL_AudioFormat format, Uint8 channels, Uint16 samples, AudioCallback&& callback = AudioCallback());
AudioSpec(const AudioSpec& other, AudioCallback&& callback = AudioCallback());
~AudioSpec();
AudioSpec(AudioSpec&& other);

View File

@ -47,6 +47,13 @@ AudioSpec::AudioSpec(int freq, SDL_AudioFormat format, Uint8 channels, Uint16 sa
}
}
AudioSpec::AudioSpec(const AudioSpec& other, AudioSpec::AudioCallback&& callback) : SDL_AudioSpec(*other.Get()), callback_(std::move(callback)) {
if (callback) {
SDL_AudioSpec::callback = SDLCallback;
SDL_AudioSpec::userdata = static_cast<void*>(this);
}
}
AudioSpec::~AudioSpec() {
}