X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fplatform%2Fsdl%2Faudio_sink.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fplatform%2Fsdl%2Faudio_sink.h;h=f09db6975f6dfec7ac88fc356eef9ba723074567;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/audio_sink.h b/src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/audio_sink.h new file mode 100644 index 0000000..f09db69 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/audio_sink.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_PLATFORM_SDL_AUDIO_SINK_H_ +#define ANBOX_PLATFORM_SDL_AUDIO_SINK_H_ + +#include "anbox/audio/sink.h" +#include "anbox/graphics/buffer_queue.h" +#include "anbox/platform/sdl/sdl_wrapper.h" + +#include + +namespace anbox { +namespace platform { +namespace sdl { +class AudioSink : public audio::Sink { + public: + AudioSink(); + ~AudioSink(); + + void write_data(const std::vector &data) override; + + private: + bool connect_audio(); + void disconnect_audio(); + void read_data(std::uint8_t *buffer, int size); + + static void on_data_requested(void *user_data, std::uint8_t *buffer, int size); + + std::mutex lock_; + SDL_AudioSpec spec_; + SDL_AudioDeviceID device_id_; + graphics::BufferQueue queue_; + graphics::Buffer read_buffer_; + size_t read_buffer_left_ = 0; +}; +} // namespace sdl +} // namespace platform +} // namespace anbox + +#endif