Skip to content

Commit

Permalink
fix: recursive device selection in CaptureConsoleMode
Browse files Browse the repository at this point in the history
  • Loading branch information
momentarylapse committed Oct 26, 2024
1 parent f1b095b commit 246ffaa
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/device/backend-portaudio/AudioInputStreamPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ AudioInputStreamPort::AudioInputStreamPort(Session *session, Device *device, Aud
&portaudio_stream_request_callback, this);
_portaudio_test_error(err, "Pa_OpenDefaultStream");
} else {
session->i(format("open stream %d %d", _sample_rate, num_channels));
PaStreamParameters params;
session->i(format("open stream %d %d %d", _sample_rate, num_channels, device->index_in_lib));
PaStreamParameters params{};
params.channelCount = num_channels;
params.sampleFormat = paFloat32;
params.device = device->index_in_lib;
params.hostApiSpecificStreamInfo = nullptr;
params.suggestedLatency = 0;
params.suggestedLatency = 0;//Pa_GetDeviceInfo(device->index_in_lib)->defaultLowInputLatency;
PaError err = Pa_OpenStream(&portaudio_stream, &params, nullptr, _sample_rate, chunk_size,
paNoFlag, &portaudio_stream_request_callback, this);
_portaudio_test_error(err, "Pa_OpenStream");
Expand Down
4 changes: 2 additions & 2 deletions src/device/backend-portaudio/DeviceContextPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace tsunami {

class DeviceContextPort : public DeviceContext {
public:
DeviceContextPort(Session* session);
~DeviceContextPort();
explicit DeviceContextPort(Session* session);
~DeviceContextPort() override;

bool init(Session* session) override;
void update_device(DeviceManager* device_manager, bool serious) override;
Expand Down
2 changes: 2 additions & 0 deletions src/module/stream/AudioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ Device *AudioInput::get_device() {
}

void AudioInput::set_device(Device *device) {
if (device == config.device)
return;
config.device = device;
changed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CaptureConsoleMode::update_device_list() {
// add all
c.panel->reset(c.id_source);
for (Device *d: sources)
c.panel->set_string(c.id_source, shorten(d->get_name(), 42));
c.panel->add_string(c.id_source, shorten(d->get_name(), 42));

// select current
foreachi(Device *d, sources, i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "../CaptureConsole.h"
#include "../../audioview/AudioView.h"
#include "../../mode/ViewModeCapture.h"
#include "../../../data/Song.h"
#include "../../../data/Track.h"
#include "../../../data/base.h"
#include "../../../module/SignalChain.h"
Expand Down Expand Up @@ -57,7 +56,9 @@ void CaptureConsoleModeAudio::enter() {

update_data_from_items();

event_ids.add(console->event("source", [this] { on_source(); }));
event_ids.add(console->event("source", [this] {
on_source();
}));


auto &c = items()[0];
Expand Down
1 change: 0 additions & 1 deletion src/view/sidebar/captureconsolemodes/CaptureTrackData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ void CaptureTrackData::set_map(const Array<int> &_map) {
}

void CaptureTrackData::set_device(Device *device) {

if (type() == SignalType::Audio) {
audio_input()->set_device(device);
set_map(create_default_channel_map(device->channels, track->channels));
Expand Down

0 comments on commit 246ffaa

Please sign in to comment.