mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 09:40:18 +00:00
audio/pipewire: Add bps to pw format helper
This commit is contained in:
@@ -130,6 +130,18 @@ bool initialize_pw_common(pipewire_state_common& s);
|
||||
std::vector<Pipewire_device> get_pw_device_list();
|
||||
void print_devices(std::string_view media_class);
|
||||
|
||||
inline spa_audio_format get_pw_format_from_bps(unsigned bps){
|
||||
spa_audio_format format_map[] = {
|
||||
SPA_AUDIO_FORMAT_UNKNOWN,
|
||||
SPA_AUDIO_FORMAT_S8,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_S24,
|
||||
SPA_AUDIO_FORMAT_S32,
|
||||
};
|
||||
|
||||
return bps < std::size(format_map) ? format_map[bps] : SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
#if !PW_CHECK_VERSION(0, 3, 64)
|
||||
# define STREAM_TARGET_PROPERTY_KEY PW_KEY_NODE_TARGET
|
||||
#else
|
||||
|
||||
@@ -237,24 +237,7 @@ static int audio_play_pw_reconfigure(void *state, struct audio_desc desc){
|
||||
|
||||
unsigned rate = desc.sample_rate;
|
||||
unsigned quant = 128;
|
||||
spa_audio_format format = SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
|
||||
switch(desc.bps){
|
||||
case 1:
|
||||
format = SPA_AUDIO_FORMAT_S8;
|
||||
break;
|
||||
case 2:
|
||||
format = SPA_AUDIO_FORMAT_S16;
|
||||
break;
|
||||
case 3:
|
||||
format = SPA_AUDIO_FORMAT_S24;
|
||||
break;
|
||||
case 4:
|
||||
format = SPA_AUDIO_FORMAT_S32;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
spa_audio_format format = get_pw_format_from_bps(desc.bps);
|
||||
|
||||
auto props = pw_properties_new(
|
||||
PW_KEY_MEDIA_TYPE, "Audio",
|
||||
|
||||
Reference in New Issue
Block a user