more stream stuff, audio input device is unusable

This commit is contained in:
Green Sky 2024-09-25 11:25:22 +02:00
parent d0eeef2b94
commit 5eca1a99e0
No known key found for this signature in database
5 changed files with 17 additions and 9 deletions

View File

@ -107,7 +107,7 @@ struct FrameStream2MultiSource : public FrameStream2SourceI<FrameType>, public F
// TODO: forward args instead // TODO: forward args instead
std::shared_ptr<FrameStream2I<FrameType>> subscribe(void) override { std::shared_ptr<FrameStream2I<FrameType>> subscribe(void) override {
// TODO: args??? // TODO: args???
size_t queue_size = 10; size_t queue_size = 8;
bool lossy = true; bool lossy = true;
std::lock_guard lg{_sub_stream_lock}; std::lock_guard lg{_sub_stream_lock};

View File

@ -59,10 +59,12 @@ SDLAudioInputDeviceDefault::SDLAudioInputDeviceDefault(void) : _stream{nullptr,
std::this_thread::sleep_for(std::chrono::milliseconds(int64_t(interval_ms/2))); std::this_thread::sleep_for(std::chrono::milliseconds(int64_t(interval_ms/2)));
} else { } else {
std::cerr << "i guess no one is listening\n"; std::cerr << "i guess no one is listening\n";
std::cerr << "first value: " << buffer.front() << "\n";
// we just sleep 32x as long, bc no one is listening // we just sleep 32x as long, bc no one is listening
// with the hardcoded settings, this is ~320ms // with the hardcoded settings, this is ~320ms
// TODO: just hardcode something like 500ms? // TODO: just hardcode something like 500ms?
// TODO: suspend // TODO: suspend
// TODO: this is not gonna cut it, since playback slows down dramatically and will be very behind
std::this_thread::sleep_for(std::chrono::milliseconds(int64_t(interval_ms*32))); std::this_thread::sleep_for(std::chrono::milliseconds(int64_t(interval_ms*32)));
} }
} }

View File

@ -17,7 +17,7 @@ using AudioFrameStream2 = AudioFrameStream2MultiSource::sub_stream_type_t; // ju
// object components? // object components?
// source // source
struct SDLAudioInputDeviceDefault : protected AudioFrameStream2MultiSource { struct SDLAudioInputDeviceDefault : public AudioFrameStream2MultiSource {
std::unique_ptr<SDL_AudioStream, decltype(&SDL_DestroyAudioStream)> _stream; std::unique_ptr<SDL_AudioStream, decltype(&SDL_DestroyAudioStream)> _stream;
std::atomic<bool> _thread_should_quit {false}; std::atomic<bool> _thread_should_quit {false};

View File

@ -379,7 +379,7 @@ float DebugToxCall::render(void) {
auto new_vsink = std::make_unique<ToxAVCallVideoSink>(_toxav, fid); auto new_vsink = std::make_unique<ToxAVCallVideoSink>(_toxav, fid);
call.outgoing_vsink.emplace<ToxAVCallVideoSink*>(new_vsink.get()); call.outgoing_vsink.emplace<ToxAVCallVideoSink*>(new_vsink.get());
call.outgoing_vsink.emplace<Components::FrameStream2Sink<SDLVideoFrame>>(std::move(new_vsink)); call.outgoing_vsink.emplace<Components::FrameStream2Sink<SDLVideoFrame>>(std::move(new_vsink));
call.outgoing_vsink.emplace<Components::StreamSink>(Components::StreamSink::create<SDLVideoFrame>("ToxAV friend call video")); call.outgoing_vsink.emplace<Components::StreamSink>(Components::StreamSink::create<SDLVideoFrame>("ToxAV Friend Call Outgoing Video"));
_os.throwEventConstruct(call.outgoing_vsink); _os.throwEventConstruct(call.outgoing_vsink);
} }
call.outgoing_asink = {_os.registry(), _os.registry().create()}; call.outgoing_asink = {_os.registry(), _os.registry().create()};
@ -387,7 +387,7 @@ float DebugToxCall::render(void) {
auto new_asink = std::make_unique<ToxAVCallAudioSink>(_toxav, fid); auto new_asink = std::make_unique<ToxAVCallAudioSink>(_toxav, fid);
call.outgoing_asink.emplace<ToxAVCallAudioSink*>(new_asink.get()); call.outgoing_asink.emplace<ToxAVCallAudioSink*>(new_asink.get());
call.outgoing_asink.emplace<Components::FrameStream2Sink<AudioFrame>>(std::move(new_asink)); call.outgoing_asink.emplace<Components::FrameStream2Sink<AudioFrame>>(std::move(new_asink));
call.outgoing_asink.emplace<Components::StreamSink>(Components::StreamSink::create<AudioFrame>("ToxAV friend call audio")); call.outgoing_asink.emplace<Components::StreamSink>(Components::StreamSink::create<AudioFrame>("ToxAV Friend Call Outgoing Audio"));
_os.throwEventConstruct(call.outgoing_asink); _os.throwEventConstruct(call.outgoing_asink);
} }
@ -398,7 +398,7 @@ float DebugToxCall::render(void) {
auto new_vsrc = std::make_unique<SDLVideoFrameStream2MultiSource>(); auto new_vsrc = std::make_unique<SDLVideoFrameStream2MultiSource>();
call.incoming_vsrc.emplace<SDLVideoFrameStream2MultiSource*>(new_vsrc.get()); call.incoming_vsrc.emplace<SDLVideoFrameStream2MultiSource*>(new_vsrc.get());
call.incoming_vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(std::move(new_vsrc)); call.incoming_vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(std::move(new_vsrc));
call.incoming_vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("ToxAV friend call video")); call.incoming_vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("ToxAV Friend Call Incoming Video"));
_os.throwEventConstruct(call.incoming_vsrc); _os.throwEventConstruct(call.incoming_vsrc);
} }
} }
@ -408,7 +408,7 @@ float DebugToxCall::render(void) {
auto new_asrc = std::make_unique<AudioFrameStream2MultiSource>(); auto new_asrc = std::make_unique<AudioFrameStream2MultiSource>();
call.incoming_asrc.emplace<AudioFrameStream2MultiSource*>(new_asrc.get()); call.incoming_asrc.emplace<AudioFrameStream2MultiSource*>(new_asrc.get());
call.incoming_asrc.emplace<Components::FrameStream2Source<AudioFrame>>(std::move(new_asrc)); call.incoming_asrc.emplace<Components::FrameStream2Source<AudioFrame>>(std::move(new_asrc));
call.incoming_asrc.emplace<Components::StreamSource>(Components::StreamSource::create<AudioFrame>("ToxAV friend call audio")); call.incoming_asrc.emplace<Components::StreamSource>(Components::StreamSource::create<AudioFrame>("ToxAV Friend Call Incoming Audio"));
_os.throwEventConstruct(call.incoming_asrc); _os.throwEventConstruct(call.incoming_asrc);
} }
} }

View File

@ -162,10 +162,16 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
} }
} }
{ // audio in if (false) { // audio in
ObjectHandle asrc {os.registry(), os.registry().create()}; ObjectHandle asrc {os.registry(), os.registry().create()};
try { try {
throw int(2); asrc.emplace<Components::FrameStream2Source<AudioFrame>>(
std::make_unique<SDLAudioInputDeviceDefault>()
);
asrc.emplace<Components::StreamSource>(Components::StreamSource::create<AudioFrame>("SDL Audio Default Recording Device"));
os.throwEventConstruct(asrc);
} catch (...) { } catch (...) {
os.registry().destroy(asrc); os.registry().destroy(asrc);
} }
@ -178,7 +184,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
std::make_unique<SDLAudioOutputDeviceDefaultSink>() std::make_unique<SDLAudioOutputDeviceDefaultSink>()
); );
asink.emplace<Components::StreamSink>(Components::StreamSink::create<AudioFrame>("LoudSpeaker")); asink.emplace<Components::StreamSink>(Components::StreamSink::create<AudioFrame>("SDL Audio Default Playback Device"));
os.throwEventConstruct(asink); os.throwEventConstruct(asink);
} catch (...) { } catch (...) {