yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

audio_core: Sinks need unique names as well.

This commit is contained in:
bunnei 2018-08-02 18:54:25 -04:00
parent 9f846d3aa4
commit 34b3f83498
5 changed files with 14 additions and 9 deletions

View File

@ -36,7 +36,7 @@ StreamPtr AudioOut::OpenStream(u32 sample_rate, u32 num_channels, std::string&&
return std::make_shared<Stream>( return std::make_shared<Stream>(
sample_rate, ChannelsToStreamFormat(num_channels), std::move(release_callback), sample_rate, ChannelsToStreamFormat(num_channels), std::move(release_callback),
sink->AcquireSinkStream(sample_rate, num_channels), std::move(name)); sink->AcquireSinkStream(sample_rate, num_channels, name), std::move(name));
} }
std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) {

View File

@ -13,7 +13,7 @@ namespace AudioCore {
class SinkStreamImpl final : public SinkStream { class SinkStreamImpl final : public SinkStream {
public: public:
SinkStreamImpl(cubeb* ctx, cubeb_devid output_device) : ctx{ctx} { SinkStreamImpl(cubeb* ctx, cubeb_devid output_device, const std::string& name) : ctx{ctx} {
cubeb_stream_params params; cubeb_stream_params params;
params.rate = 48000; params.rate = 48000;
params.channels = GetNumChannels(); params.channels = GetNumChannels();
@ -25,8 +25,8 @@ public:
LOG_CRITICAL(Audio_Sink, "Error getting minimum latency"); LOG_CRITICAL(Audio_Sink, "Error getting minimum latency");
} }
if (cubeb_stream_init(ctx, &stream_backend, "yuzu Audio Output", nullptr, nullptr, if (cubeb_stream_init(ctx, &stream_backend, name.c_str(), nullptr, nullptr, output_device,
output_device, &params, std::max(512u, minimum_latency), &params, std::max(512u, minimum_latency),
&SinkStreamImpl::DataCallback, &SinkStreamImpl::StateCallback, &SinkStreamImpl::DataCallback, &SinkStreamImpl::StateCallback,
this) != CUBEB_OK) { this) != CUBEB_OK) {
LOG_CRITICAL(Audio_Sink, "Error initializing cubeb stream"); LOG_CRITICAL(Audio_Sink, "Error initializing cubeb stream");
@ -129,8 +129,9 @@ CubebSink::~CubebSink() {
cubeb_destroy(ctx); cubeb_destroy(ctx);
} }
SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels) { SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels,
sink_streams.push_back(std::make_unique<SinkStreamImpl>(ctx, output_device)); const std::string& name) {
sink_streams.push_back(std::make_unique<SinkStreamImpl>(ctx, output_device, name));
return *sink_streams.back(); return *sink_streams.back();
} }

View File

@ -18,7 +18,8 @@ public:
explicit CubebSink(std::string device_id); explicit CubebSink(std::string device_id);
~CubebSink() override; ~CubebSink() override;
SinkStream& AcquireSinkStream(u32 sample_rate, u32 num_channels) override; SinkStream& AcquireSinkStream(u32 sample_rate, u32 num_channels,
const std::string& name) override;
private: private:
cubeb* ctx{}; cubeb* ctx{};

View File

@ -13,7 +13,8 @@ public:
explicit NullSink(std::string){}; explicit NullSink(std::string){};
~NullSink() override = default; ~NullSink() override = default;
SinkStream& AcquireSinkStream(u32 /*sample_rate*/, u32 /*num_channels*/) override { SinkStream& AcquireSinkStream(u32 /*sample_rate*/, u32 /*num_channels*/,
const std::string& /*name*/) override {
return null_sink_stream; return null_sink_stream;
} }

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string>
#include "audio_core/sink_stream.h" #include "audio_core/sink_stream.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -21,7 +22,8 @@ constexpr char auto_device_name[] = "auto";
class Sink { class Sink {
public: public:
virtual ~Sink() = default; virtual ~Sink() = default;
virtual SinkStream& AcquireSinkStream(u32 sample_rate, u32 num_channels) = 0; virtual SinkStream& AcquireSinkStream(u32 sample_rate, u32 num_channels,
const std::string& name) = 0;
}; };
using SinkPtr = std::unique_ptr<Sink>; using SinkPtr = std::unique_ptr<Sink>;