2020-04-19 23:04:05 +02:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
2020-03-27 20:36:02 +01:00
|
|
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
|
|
|
|
2020-01-02 21:19:34 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <services/serviceman.h>
|
2020-02-17 20:11:59 +01:00
|
|
|
#include <audio/resampler.h>
|
|
|
|
#include <audio.h>
|
2020-01-02 21:19:34 +01:00
|
|
|
|
2020-02-17 20:11:59 +01:00
|
|
|
namespace skyline::service::audio {
|
2020-01-02 21:19:34 +01:00
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief IAudioOut is a service opened when OpenAudioOut is called by IAudioOutManager
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#IAudioOut
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
|
|
|
class IAudioOut : public BaseService {
|
|
|
|
private:
|
2020-02-17 20:11:59 +01:00
|
|
|
skyline::audio::Resampler resampler; //!< The audio resampler object used to resample audio
|
|
|
|
std::shared_ptr<skyline::audio::AudioTrack> track; //!< The audio track associated with the audio out
|
2020-01-02 21:19:34 +01:00
|
|
|
std::shared_ptr<type::KEvent> releaseEvent; //!< The KEvent that is signalled when a buffer has been released
|
|
|
|
|
2020-08-21 15:28:47 +02:00
|
|
|
u32 sampleRate;
|
|
|
|
u8 channelCount;
|
2020-01-24 23:03:12 +01:00
|
|
|
|
2020-01-02 21:19:34 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @param channelCount The channel count of the audio data the audio out will be fed
|
|
|
|
* @param sampleRate The sample rate of the audio data the audio out will be fed
|
|
|
|
*/
|
2020-04-22 19:02:27 +02:00
|
|
|
IAudioOut(const DeviceState &state, ServiceManager &manager, u8 channelCount, u32 sampleRate);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Closes the audio track
|
|
|
|
*/
|
|
|
|
~IAudioOut();
|
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Returns the playback state of the audio output
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#GetAudioOutState
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result GetAudioOutState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Starts playback using data from appended samples
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#StartAudioOut
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result StartAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Stops playback of audio, waits for all samples to be released
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#StartAudioOut
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result StopAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Appends sample data to the output buffer
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result AppendAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Returns a handle to the sample release KEvent
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result RegisterBufferEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Returns the IDs of all pending released buffers
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#GetReleasedAudioOutBuffer
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result GetReleasedAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-01-02 21:19:34 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-28 12:05:17 +02:00
|
|
|
* @brief Checks if the given buffer ID is in the playback queue
|
|
|
|
* @url https://switchbrew.org/wiki/Audio_services#ContainsAudioOutBuffer
|
2020-01-02 21:19:34 +01:00
|
|
|
*/
|
2020-09-03 20:43:52 +02:00
|
|
|
Result ContainsAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
2020-09-21 12:04:26 +02:00
|
|
|
|
|
|
|
SERVICE_DECL(
|
|
|
|
SFUNC(0x0, IAudioOut, GetAudioOutState),
|
|
|
|
SFUNC(0x1, IAudioOut, StartAudioOut),
|
|
|
|
SFUNC(0x2, IAudioOut, StopAudioOut),
|
|
|
|
SFUNC(0x3, IAudioOut, AppendAudioOutBuffer),
|
|
|
|
SFUNC(0x4, IAudioOut, RegisterBufferEvent),
|
|
|
|
SFUNC(0x5, IAudioOut, GetReleasedAudioOutBuffer),
|
|
|
|
SFUNC(0x6, IAudioOut, ContainsAudioOutBuffer),
|
|
|
|
SFUNC(0x7, IAudioOut, AppendAudioOutBuffer),
|
|
|
|
SFUNC(0x8, IAudioOut, GetReleasedAudioOutBuffer)
|
|
|
|
)
|
2020-01-02 21:19:34 +01:00
|
|
|
};
|
|
|
|
}
|