blob: 686eac0c416f314284f2b01fa11ff449cb153047 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXAMPLES_MEDIA_AUDIO_SIMPLE_SINE_SIMPLE_SINE_H_
#define EXAMPLES_MEDIA_AUDIO_SIMPLE_SINE_SIMPLE_SINE_H_
#include <fuchsia/media/cpp/fidl.h>
#include <lib/fit/function.h>
#include <lib/fzl/vmo-mapper.h>
#include <lib/sys/cpp/component_context.h>
namespace examples {
class MediaApp {
public:
MediaApp(fit::closure quit_callback);
void Run(sys::ComponentContext* app_context);
private:
void AcquireAudioRenderer(sys::ComponentContext* app_context);
void SetStreamType();
zx_status_t CreateMemoryMapping();
void WriteAudioIntoBuffer();
fuchsia::media::StreamPacket CreatePacket(size_t packet_num);
void SendPacket(fuchsia::media::StreamPacket packet);
void OnSendPacketComplete();
void Shutdown();
fit::closure quit_callback_;
fuchsia::media::AudioRendererPtr audio_renderer_;
fzl::VmoMapper payload_buffer_;
size_t payload_size_;
size_t total_mapping_size_;
size_t num_packets_sent_ = 0u;
size_t num_packets_completed_ = 0u;
};
} // namespace examples
#endif // EXAMPLES_MEDIA_AUDIO_SIMPLE_SINE_SIMPLE_SINE_H_