mirror of
https://github.com/uowuo/abaddon.git
synced 2025-03-04 03:03:16 -05:00
dont error if no capture or playback devices are available to try initializing (#193)
This commit is contained in:
parent
49bbc926e7
commit
857e94af38
@ -93,19 +93,23 @@ AudioManager::AudioManager() {
|
||||
if (const auto playback_id = m_devices.GetDefaultPlayback(); playback_id.has_value()) {
|
||||
m_playback_id = *playback_id;
|
||||
m_playback_config.playback.pDeviceID = &m_playback_id;
|
||||
}
|
||||
|
||||
if (ma_device_init(&m_context, &m_playback_config, &m_playback_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to initialize playback device");
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
if (ma_device_init(&m_context, &m_playback_config, &m_playback_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to initialize playback device");
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ma_device_start(&m_playback_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to start playback");
|
||||
ma_device_uninit(&m_playback_device);
|
||||
m_ok = false;
|
||||
return;
|
||||
if (ma_device_start(&m_playback_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to start playback");
|
||||
ma_device_uninit(&m_playback_device);
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
char playback_device_name[MA_MAX_DEVICE_NAME_LENGTH + 1];
|
||||
ma_device_get_name(&m_playback_device, ma_device_type_playback, playback_device_name, sizeof(playback_device_name), nullptr);
|
||||
spdlog::get("audio")->info("using {} as playback device", playback_device_name);
|
||||
}
|
||||
|
||||
m_capture_config = ma_device_config_init(ma_device_type_capture);
|
||||
@ -119,22 +123,18 @@ AudioManager::AudioManager() {
|
||||
if (const auto capture_id = m_devices.GetDefaultCapture(); capture_id.has_value()) {
|
||||
m_capture_id = *capture_id;
|
||||
m_capture_config.capture.pDeviceID = &m_capture_id;
|
||||
|
||||
if (ma_device_init(&m_context, &m_capture_config, &m_capture_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to initialize capture device");
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
char capture_device_name[MA_MAX_DEVICE_NAME_LENGTH + 1];
|
||||
ma_device_get_name(&m_capture_device, ma_device_type_capture, capture_device_name, sizeof(capture_device_name), nullptr);
|
||||
spdlog::get("audio")->info("using {} as capture device", capture_device_name);
|
||||
}
|
||||
|
||||
if (ma_device_init(&m_context, &m_capture_config, &m_capture_device) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to initialize capture device");
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
char playback_device_name[MA_MAX_DEVICE_NAME_LENGTH + 1];
|
||||
ma_device_get_name(&m_playback_device, ma_device_type_playback, playback_device_name, sizeof(playback_device_name), nullptr);
|
||||
spdlog::get("audio")->info("using {} as playback device", playback_device_name);
|
||||
|
||||
char capture_device_name[MA_MAX_DEVICE_NAME_LENGTH + 1];
|
||||
ma_device_get_name(&m_capture_device, ma_device_type_capture, capture_device_name, sizeof(capture_device_name), nullptr);
|
||||
spdlog::get("audio")->info("using {} as capture device", capture_device_name);
|
||||
|
||||
Glib::signal_timeout().connect(sigc::mem_fun(*this, &AudioManager::DecayVolumeMeters), 40);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,9 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
|
||||
m_playback_combo.set_hexpand(true);
|
||||
m_playback_combo.set_halign(Gtk::ALIGN_FILL);
|
||||
m_playback_combo.set_model(Abaddon::Get().GetAudio().GetDevices().GetPlaybackDeviceModel());
|
||||
m_playback_combo.set_active(Abaddon::Get().GetAudio().GetDevices().GetActivePlaybackDevice());
|
||||
if (const auto iter = Abaddon::Get().GetAudio().GetDevices().GetActivePlaybackDevice()) {
|
||||
m_playback_combo.set_active(iter);
|
||||
}
|
||||
m_playback_combo.pack_start(*playback_renderer);
|
||||
m_playback_combo.add_attribute(*playback_renderer, "text", 0);
|
||||
m_playback_combo.signal_changed().connect([this]() {
|
||||
@ -151,7 +153,9 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
|
||||
m_capture_combo.set_hexpand(true);
|
||||
m_capture_combo.set_halign(Gtk::ALIGN_FILL);
|
||||
m_capture_combo.set_model(Abaddon::Get().GetAudio().GetDevices().GetCaptureDeviceModel());
|
||||
m_capture_combo.set_active(Abaddon::Get().GetAudio().GetDevices().GetActiveCaptureDevice());
|
||||
if (const auto iter = Abaddon::Get().GetAudio().GetDevices().GetActiveCaptureDevice()) {
|
||||
m_capture_combo.set_active(iter);
|
||||
}
|
||||
m_capture_combo.pack_start(*capture_renderer);
|
||||
m_capture_combo.add_attribute(*capture_renderer, "text", 0);
|
||||
m_capture_combo.signal_changed().connect([this]() {
|
||||
|
Loading…
Reference in New Issue
Block a user