summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules')
-rw-r--r--src/osd/modules/sound/pipewire_sound.cpp17
-rw-r--r--src/osd/modules/sound/sdl_sound.cpp9
2 files changed, 13 insertions, 13 deletions
diff --git a/src/osd/modules/sound/pipewire_sound.cpp b/src/osd/modules/sound/pipewire_sound.cpp
index 8bf5b8e0afa..c597a81fdb3 100644
--- a/src/osd/modules/sound/pipewire_sound.cpp
+++ b/src/osd/modules/sound/pipewire_sound.cpp
@@ -90,6 +90,7 @@ private:
struct stream_info {
sound_pipewire *m_wire;
bool m_is_output;
+ bool m_wait_stream;
uint32_t m_osdid;
uint32_t m_node_id;
node_info *m_node;
@@ -98,7 +99,7 @@ private:
std::vector<float> m_volumes;
abuffer m_buffer;
- stream_info(sound_pipewire *wire, bool is_output, uint32_t osdid, uint32_t channels) : m_wire(wire), m_is_output(is_output), m_osdid(osdid), m_channels(channels), m_stream(nullptr), m_buffer(channels) {}
+ stream_info(sound_pipewire *wire, bool is_output, uint32_t osdid, uint32_t channels) : m_wire(wire), m_is_output(is_output), m_wait_stream(true), m_osdid(osdid), m_channels(channels), m_stream(nullptr), m_buffer(channels) {}
};
static const pw_core_events core_events;
@@ -127,7 +128,7 @@ private:
uint32_t m_node_current_id, m_stream_current_id;
uint32_t m_generation;
- bool m_wait_sync, m_wait_stream;
+ bool m_wait_sync;
void sync();
@@ -483,7 +484,6 @@ int sound_pipewire::init(osd_interface &osd, osd_options const &options)
m_generation = 1;
m_wait_sync = false;
- m_wait_stream = false;
pw_init(nullptr, nullptr);
m_loop = pw_thread_loop_new(nullptr, nullptr);
@@ -630,15 +630,14 @@ void sound_pipewire::stream_event_param_changed(stream_info *stream, uint32_t id
if(id == SPA_PARAM_Props) {
const spa_pod_prop *vols = spa_pod_find_prop(param, nullptr, SPA_PROP_channelVolumes);
if(vols) {
- bool initial = stream->m_volumes.empty();
stream->m_volumes.clear();
float *entry;
SPA_POD_ARRAY_FOREACH((spa_pod_array *)(&vols->value), entry) {
stream->m_volumes.push_back(osd::linear_to_db(*entry));
}
if(!stream->m_volumes.empty()) {
- if(initial) {
- m_wait_stream = false;
+ if(stream->m_wait_stream) {
+ stream->m_wait_stream = false;
pw_thread_loop_signal(m_loop, false);
} else
m_generation++;
@@ -697,8 +696,7 @@ uint32_t sound_pipewire::stream_sink_open(uint32_t node, std::string name, uint3
pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS),
&params, 1);
- m_wait_stream = true;
- while(m_wait_stream)
+ while(stream.m_wait_stream)
pw_thread_loop_wait(m_loop);
stream.m_node_id = pw_stream_get_node_id(stream.m_stream);
@@ -751,8 +749,7 @@ uint32_t sound_pipewire::stream_source_open(uint32_t node, std::string name, uin
pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS),
&params, 1);
- m_wait_stream = true;
- while(m_wait_stream)
+ while(stream.m_wait_stream)
pw_thread_loop_wait(m_loop);
stream.m_node_id = pw_stream_get_node_id(stream.m_stream);
diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp
index 35c11eae86d..6fbbbf14f4b 100644
--- a/src/osd/modules/sound/sdl_sound.cpp
+++ b/src/osd/modules/sound/sdl_sound.cpp
@@ -58,7 +58,8 @@ private:
std::string m_name;
int m_freq;
uint8_t m_channels;
- device_info(const char *name, int freq, uint8_t channels) : m_name(name), m_freq(freq), m_channels(channels) {}
+ bool m_def;
+ device_info(const char *name, int freq, uint8_t channels, bool def = false) : m_name(name), m_freq(freq), m_channels(channels), m_def(def) {}
};
struct stream_info {
@@ -100,6 +101,7 @@ int sound_sdl::init(osd_interface &osd, const osd_options &options)
for(int i=0; i != dev_count; i++) {
SDL_AudioSpec spec;
const char *name = SDL_GetAudioDeviceName(i, 0);
+ fprintf(stderr, "Device name %s\n", name);
int err = SDL_GetAudioDeviceSpec(i, 0, &spec);
if(!err)
m_devices.emplace_back(name, spec.freq, spec.channels);
@@ -107,10 +109,11 @@ int sound_sdl::init(osd_interface &osd, const osd_options &options)
char *def_name;
SDL_AudioSpec def_spec;
if(!SDL_GetDefaultAudioInfo(&def_name, &def_spec, 0)) {
+ fprintf(stderr, "Default name %s\n", def_name);
uint32_t idx;
for(idx = 0; idx != m_devices.size() && m_devices[idx].m_name != def_name; idx++);
if(idx == m_devices.size())
- m_devices.emplace_back(def_name, def_spec.freq, def_spec.channels);
+ m_devices.emplace_back(def_name, def_spec.freq, def_spec.channels, true);
m_default_sink = idx+1;
SDL_free(def_name);
} else
@@ -190,7 +193,7 @@ uint32_t sound_sdl::stream_sink_open(uint32_t node, std::string name, uint32_t r
dspec.callback = sink_callback;
dspec.userdata = stream.get();
- stream->m_sdl_id = SDL_OpenAudioDevice(dev.m_name.c_str(), 0, &dspec, &ospec, 0);
+ stream->m_sdl_id = SDL_OpenAudioDevice(dev.m_def ? nullptr : dev.m_name.c_str(), 0, &dspec, &ospec, 0);
if(!stream->m_sdl_id)
return 0;
SDL_PauseAudioDevice(stream->m_sdl_id, 0);