From 04e8277f38841585b6a15c990230075dc33e5052 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Sat, 14 Sep 2024 17:42:55 +0200 Subject: [PATCH] Rename "Sampling" to more common "Rate" term In audio processing software the sampling frequency of recorded audio is mostly named as sample rate or simply "rate". On the other hand the sampling frequency is more scientific term. Since bluez-alsa is audio processing software, the term "rate" should fit better here. Also, it will align with ALSA nomenclature. --- NEWS | 4 +- doc/bluealsa-aplay.1.rst | 2 +- doc/bluealsa-plugins.7.rst | 4 +- doc/bluealsactl.1.rst | 4 +- doc/bluealsad.8.rst | 12 +-- doc/org.bluealsa.PCM1.7.rst | 20 ++-- src/a2dp-aac.c | 48 ++++----- src/a2dp-aptx-hd.c | 48 ++++----- src/a2dp-aptx.c | 36 +++---- src/a2dp-faststream.c | 151 ++++++++++++++------------- src/a2dp-lc3plus.c | 72 ++++++------- src/a2dp-ldac.c | 54 +++++----- src/a2dp-mpeg.c | 56 +++++----- src/a2dp-opus.c | 66 ++++++------ src/a2dp-sbc.c | 50 ++++----- src/a2dp.c | 20 ++-- src/a2dp.h | 16 +-- src/asound/bluealsa-pcm.c | 32 +++--- src/ba-config.h | 4 +- src/ba-rfcomm.c | 8 +- src/ba-transport-pcm.h | 4 +- src/bluealsa-dbus.c | 46 ++++---- src/bluealsa-dbus.h | 2 +- src/bluealsa-iface.xml | 2 +- src/bluealsactl/cmd-codec.c | 14 +-- src/bluealsactl/main.c | 10 +- src/bluez.c | 4 +- src/codec-lc3-swb.h | 2 +- src/codec-msbc.c | 2 +- src/codec-sbc.c | 6 +- src/io.c | 2 +- src/sco.c | 20 ++-- src/shared/dbus-client-pcm.c | 34 +++--- src/shared/dbus-client-pcm.h | 10 +- src/shared/rt.c | 2 +- src/shared/rt.h | 6 +- test/inc/sine.inc | 2 +- test/integration/test-e2e-latency.py | 30 +++--- test/mock/mock-bluealsa.c | 8 +- test/test-a2dp.c | 30 +++--- test/test-alsa-pcm.c | 40 +++---- test/test-io.c | 28 ++--- test/test-utils-aplay.c | 8 +- test/test-utils-ctl.c | 4 +- utils/a2dpconf.c | 28 ++--- utils/aplay/alsa-pcm.c | 2 +- utils/aplay/aplay.c | 18 ++-- 47 files changed, 540 insertions(+), 531 deletions(-) diff --git a/NEWS b/NEWS index a79904d5c..13187f16e 100644 --- a/NEWS +++ b/NEWS @@ -11,13 +11,13 @@ bluez-alsa v4.3.1 (2024-08-30) ============================== - fix crash when playing audio with more than 2 channels -- fix AAC configuration selection for low sampling rates +- fix AAC configuration selection for low sample rates bluez-alsa v4.3.0 (2024-08-13) ============================== - optional support for Android 13 A2DP Opus codec -- multi channels and sampling rates mode for ALSA PCM plug-in +- multi channels and sample rates mode for ALSA PCM plug-in - bluealsa-aplay: fix volume synchronization on Raspberry Pi bluez-alsa v4.2.0 (2024-05-11) diff --git a/doc/bluealsa-aplay.1.rst b/doc/bluealsa-aplay.1.rst index d91ea39f3..44a94c910 100644 --- a/doc/bluealsa-aplay.1.rst +++ b/doc/bluealsa-aplay.1.rst @@ -78,7 +78,7 @@ OPTIONS Internally, **bluealsa-aplay** does not perform any audio transformations nor streams mixing. If multiple Bluetooth devices are connected it simply opens a new connection to the ALSA PCM device for each stream. Selected - hardware parameters like sampling frequency and number of channels are + hardware parameters like sample rate and number of channels are taken from the audio profile of a particular Bluetooth connection. Note, that each connection can have a different setup. diff --git a/doc/bluealsa-plugins.7.rst b/doc/bluealsa-plugins.7.rst index 062dcbc6d..62bad6472 100644 --- a/doc/bluealsa-plugins.7.rst +++ b/doc/bluealsa-plugins.7.rst @@ -72,8 +72,8 @@ PCM Parameters For the A2DP profile it is possible to also specify a "configuration" for the codec by appending the configuration as a hex string separated from the codec name by a colon. The bits responsible for the number of channels and - the sampling frequency are set by the plugin with the respect to options - provided by the user (channel mode and sampling frequency bits act as a + the sample rate are set by the plugin with the respect to options + provided by the user (channel mode and sample rate bits act as a mask). For example: :: diff --git a/doc/bluealsactl.1.rst b/doc/bluealsactl.1.rst index 073034ccc..bbb5bc7fe 100644 --- a/doc/bluealsactl.1.rst +++ b/doc/bluealsactl.1.rst @@ -90,7 +90,7 @@ info *PCM_PATH* The list of available A2DP codecs requires BlueZ SEP support (BlueZ >= 5.52) -codec [-c NUM] [-s NUM] [--force] *PCM_PATH* [*CODEC*\ [:*CONFIG*]] +codec [-c NUM] [-r NUM] [--force] *PCM_PATH* [*CODEC*\ [:*CONFIG*]] Get or set the Bluetooth codec used by the given PCM. If *CODEC* is given, change the codec to be used by the given PCM. This @@ -223,7 +223,7 @@ open [--hex] *PCM_PATH* Transfer raw audio frames to or from the given PCM. For sink PCMs the frames are read from standard input and written to the PCM. For source PCMs the frames are read from the PCM and written to standard - output. The format, channels and sampling rate must match the properties + output. The format, channels and sample rate must match the properties of the PCM, as no format conversions are performed by this tool. With the **--hex** option, the data is read or written as hexadecimal diff --git a/doc/bluealsad.8.rst b/doc/bluealsad.8.rst index e3574d084..47089fdfe 100644 --- a/doc/bluealsad.8.rst +++ b/doc/bluealsad.8.rst @@ -142,9 +142,9 @@ OPTIONS Force monophonic sound for A2DP profile. --a2dp-force-audio-cd - Force 44.1 kHz sampling frequency for A2DP profile. - Some Bluetooth devices can handle streams sampled at either 48kHz or - 44.1kHz, in which case they normally default to using 48kHz. + Force 44.1 kHz sample rate for A2DP profile. + Some Bluetooth devices can handle streams sampled at either 48 kHz or + 44.1kHz, in which case they normally default to using 48 kHz. With this option, **bluealsad** will request such a device uses only 44.1 kHz sample rate. @@ -271,9 +271,9 @@ Profiles **bluealsad** provides support for Bluetooth Advanced Audio Distribution Profile (A2DP), Hands-Free Profile (HFP), Headset Profile (HSP) and Bluetooth Low Energy MIDI (BLE-MIDI). -A2DP profile is dedicated for streaming music (i.e., stereo, 48 kHz or more -sampling frequency), while HFP and HSP for two-way voice transmission (mono, 8 -kHz or 16 kHz sampling frequency). BLE-MIDI, on the other hand, is used for +A2DP profile is dedicated for streaming music (i.e., stereo, 48 kHz or higher +sample rates), while HFP and HSP for two-way voice transmission (mono, 8 +kHz or 16 kHz sample rate). BLE-MIDI, on the other hand, is used for transmitting MIDI messages over Bluetooth LE. The Bluetooth audio profiles are not peer-to-peer; they each have a source or diff --git a/doc/org.bluealsa.PCM1.7.rst b/doc/org.bluealsa.PCM1.7.rst index f8f1b8ac5..45eb5564b 100644 --- a/doc/org.bluealsa.PCM1.7.rst +++ b/doc/org.bluealsa.PCM1.7.rst @@ -6,7 +6,7 @@ org.bluealsa.PCM1 Bluetooth Audio PCM D-Bus API ----------------------------- -:Date: August 2024 +:Date: September 2024 :Manual section: 7 :Manual group: D-Bus Interface :Version: $VERSION$ @@ -49,12 +49,12 @@ array{string, dict} GetCodecs() :array{byte} Capabilities: A2DP codec capabilities blob. - :array{byte} SupportedChannels: - List of supported number of audio channels. - :array{uint32} SupportedSampling: - List of supported sampling frequency. + :array{byte} Channels: + List of supported channel counts. :array{array{string}} ChannelMaps: List of supported channel maps. + :array{uint32} Rates: + List of supported sample rates. void SelectCodec(string codec, dict props) Select PCM codec. This call shall be made before PCM stream opening for @@ -69,9 +69,9 @@ void SelectCodec(string codec, dict props) property to true. In case of codecs which support different number of audio channels or - sampling frequencies, client can select the desired configuration by - providing the "Channels" and "Sampling" properties respectively. These - properties take precedence over the provided codec configuration. + sample rates, client can select the desired configuration by providing the + "Channels" and "Rate" properties respectively. These properties take + precedence over the provided codec configuration. Possible Errors: :: @@ -150,8 +150,8 @@ byte Channels [readonly] array{string} ChannelMap [readonly] Channel map for selected codec. -uint32 Sampling [readonly] - Sampling frequency. +uint32 Rate [readonly] + Sample rate in Hz. string Codec [readonly] Bluetooth transport codec. This property is available only when transport diff --git a/src/a2dp-aac.c b/src/a2dp-aac.c index adb990dc0..2aed30cca 100644 --- a/src/a2dp-aac.c +++ b/src/a2dp-aac.c @@ -70,7 +70,7 @@ static const struct a2dp_bit_mapping a2dp_aac_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_aac_samplings[] = { +static const struct a2dp_bit_mapping a2dp_aac_rates[] = { { AAC_SAMPLING_FREQ_8000, { 8000 } }, { AAC_SAMPLING_FREQ_11025, { 11025 } }, { AAC_SAMPLING_FREQ_12000, { 12000 } }, @@ -111,7 +111,7 @@ static int a2dp_aac_caps_foreach_channel_mode( return -1; } -static int a2dp_aac_caps_foreach_sampling_freq( +static int a2dp_aac_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, @@ -119,7 +119,7 @@ static int a2dp_aac_caps_foreach_sampling_freq( const a2dp_aac_t *caps = capabilities; if (stream == A2DP_MAIN) { const uint16_t sampling_freq = A2DP_AAC_GET_SAMPLING_FREQ(*caps); - return a2dp_bit_mapping_foreach(a2dp_aac_samplings, sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_aac_rates, sampling_freq, func, userdata); } return -1; } @@ -134,14 +134,14 @@ static void a2dp_aac_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_aac_caps_select_sampling_freq( +static void a2dp_aac_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_aac_t *caps = capabilities; if (stream == A2DP_MAIN) { - const uint16_t sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aac_samplings, - A2DP_AAC_GET_SAMPLING_FREQ(*caps), frequency); + const uint16_t sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aac_rates, + A2DP_AAC_GET_SAMPLING_FREQ(*caps), rate); A2DP_AAC_SET_SAMPLING_FREQ(*caps, sampling_freq); } } @@ -150,9 +150,9 @@ static struct a2dp_caps_helpers a2dp_aac_caps_helpers = { .intersect = a2dp_aac_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_aac_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_aac_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_aac_caps_foreach_sample_rate, .select_channel_mode = a2dp_aac_caps_select_channel_mode, - .select_sampling_freq = a2dp_aac_caps_select_sampling_freq, + .select_sample_rate = a2dp_aac_caps_select_sample_rate, }; static unsigned int a2dp_aac_get_fdk_vbr_mode( @@ -185,7 +185,7 @@ void *a2dp_aac_enc_thread(struct ba_transport_pcm *t_pcm) { const a2dp_aac_t *configuration = &t->a2dp.configuration.aac; const unsigned int bitrate = A2DP_AAC_GET_BITRATE(*configuration); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; /* create AAC encoder without the Meta Data module */ if ((err = aacEncOpen(&handle, 0x0F, channels)) != AACENC_OK) { @@ -255,8 +255,8 @@ void *a2dp_aac_enc_thread(struct ba_transport_pcm *t_pcm) { } } #endif - if ((err = aacEncoder_SetParam(handle, AACENC_SAMPLERATE, samplerate)) != AACENC_OK) { - error("Couldn't set sampling rate: %s", aacenc_strerror(err)); + if ((err = aacEncoder_SetParam(handle, AACENC_SAMPLERATE, rate)) != AACENC_OK) { + error("Couldn't set sample rate: %s", aacenc_strerror(err)); goto fail_init; } if ((err = aacEncoder_SetParam(handle, AACENC_CHANNELMODE, channel_mode)) != AACENC_OK) { @@ -317,7 +317,7 @@ void *a2dp_aac_enc_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to 90kHz */ - rtp_state_init(&rtp, samplerate, 90000); + rtp_state_init(&rtp, rate, 90000); int in_bufferIdentifiers[] = { IN_AUDIO_DATA }; int out_bufferIdentifiers[] = { OUT_BITSTREAM_DATA }; @@ -459,7 +459,7 @@ void *a2dp_aac_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(aacDecoder_Close), handle); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; #ifdef AACDECODER_LIB_VL0 if ((err = aacDecoder_SetParam(handle, AAC_PCM_MIN_OUTPUT_CHANNELS, channels)) != AAC_DEC_OK) { @@ -493,7 +493,7 @@ void *a2dp_aac_dec_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to 90kHz */ - rtp_state_init(&rtp, samplerate, 90000); + rtp_state_init(&rtp, rate, 90000); int markbit_quirk = -3; @@ -614,11 +614,11 @@ static int a2dp_aac_configuration_select( } unsigned int sampling_freq = 0; - if (a2dp_aac_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_aac_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) A2DP_AAC_SET_SAMPLING_FREQ(*caps, sampling_freq); else { - error("AAC: No supported sampling frequencies: %#x", A2DP_AAC_GET_SAMPLING_FREQ(saved)); + error("AAC: No supported sample rates: %#x", A2DP_AAC_GET_SAMPLING_FREQ(saved)); return errno = ENOTSUP, -1; } @@ -692,9 +692,9 @@ static int a2dp_aac_configuration_check( } const uint16_t conf_sampling_freq = A2DP_AAC_GET_SAMPLING_FREQ(conf_v); - if (a2dp_bit_mapping_lookup(a2dp_aac_samplings, conf_sampling_freq) == -1) { - debug("AAC: Invalid sampling frequency: %#x", A2DP_AAC_GET_SAMPLING_FREQ(*conf)); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_aac_rates, conf_sampling_freq) == -1) { + debug("AAC: Invalid sample rate: %#x", A2DP_AAC_GET_SAMPLING_FREQ(*conf)); + return A2DP_CHECK_ERR_RATE; } if (a2dp_bit_mapping_lookup(a2dp_aac_channels, conf_v.channel_mode) == -1) { @@ -712,14 +712,14 @@ static int a2dp_aac_transport_init(struct ba_transport *t) { t->a2dp.configuration.aac.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_aac_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_aac_rates, A2DP_AAC_GET_SAMPLING_FREQ(t->a2dp.configuration.aac))) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = a2dp_aac_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_aac_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_aac_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_aac_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-aptx-hd.c b/src/a2dp-aptx-hd.c index 2193adb03..56c43c8cd 100644 --- a/src/a2dp-aptx-hd.c +++ b/src/a2dp-aptx-hd.c @@ -49,7 +49,7 @@ static const struct a2dp_bit_mapping a2dp_aptx_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_aptx_samplings[] = { +static const struct a2dp_bit_mapping a2dp_aptx_rates[] = { { APTX_SAMPLING_FREQ_16000, { 16000 } }, { APTX_SAMPLING_FREQ_32000, { 32000 } }, { APTX_SAMPLING_FREQ_44100, { 44100 } }, @@ -74,14 +74,14 @@ static int a2dp_aptx_hd_caps_foreach_channel_mode( return -1; } -static int a2dp_aptx_hd_caps_foreach_sampling_freq( +static int a2dp_aptx_hd_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_aptx_hd_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_aptx_samplings, caps->aptx.sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_aptx_rates, caps->aptx.sampling_freq, func, userdata); return -1; } @@ -95,23 +95,23 @@ static void a2dp_aptx_hd_caps_select_channel_mode( caps->aptx.channel_mode, channels); } -static void a2dp_aptx_hd_caps_select_sampling_freq( +static void a2dp_aptx_hd_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_aptx_hd_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->aptx.sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aptx_samplings, - caps->aptx.sampling_freq, frequency); + caps->aptx.sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aptx_rates, + caps->aptx.sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_aptx_hd_caps_helpers = { .intersect = a2dp_aptx_hd_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_aptx_hd_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_aptx_hd_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_aptx_hd_caps_foreach_sample_rate, .select_channel_mode = a2dp_aptx_hd_caps_select_channel_mode, - .select_sampling_freq = a2dp_aptx_hd_caps_select_sampling_freq, + .select_sample_rate = a2dp_aptx_hd_caps_select_sample_rate, }; void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm) { @@ -135,7 +135,7 @@ void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(aptxhdenc_destroy), handle); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; const size_t aptx_pcm_samples = 4 * channels; const size_t aptx_code_len = 2 * 3 * sizeof(uint8_t); const size_t mtu_write = t->mtu_write; @@ -151,8 +151,8 @@ void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm) { uint8_t *rtp_payload = rtp_a2dp_init(bt.data, &rtp_header, NULL, 0); struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -269,7 +269,7 @@ void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(aptxhddec_destroy), handle); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; /* Note, that we are allocating space for one extra output packed, which is * required by the aptx_decode_sync() function of libopenaptx library. */ @@ -280,8 +280,8 @@ void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm) { } struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -357,11 +357,11 @@ static int a2dp_aptx_hd_configuration_select( a2dp_aptx_hd_caps_intersect(caps, &sep->config.capabilities); unsigned int sampling_freq = 0; - if (a2dp_aptx_hd_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_aptx_hd_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) caps->aptx.sampling_freq = sampling_freq; else { - error("apt-X HD: No supported sampling frequencies: %#x", saved.aptx.sampling_freq); + error("apt-X HD: No supported sample rates: %#x", saved.aptx.sampling_freq); return errno = ENOTSUP, -1; } @@ -387,9 +387,9 @@ static int a2dp_aptx_hd_configuration_check( /* Validate configuration against BlueALSA capabilities. */ a2dp_aptx_hd_caps_intersect(&conf_v, &sep->config.capabilities); - if (a2dp_bit_mapping_lookup(a2dp_aptx_samplings, conf_v.aptx.sampling_freq) == -1) { - debug("apt-X HD: Invalid sampling frequency: %#x", conf->aptx.sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_aptx_rates, conf_v.aptx.sampling_freq) == -1) { + debug("apt-X HD: Invalid sample rate: %#x", conf->aptx.sampling_freq); + return A2DP_CHECK_ERR_RATE; } if (a2dp_bit_mapping_lookup(a2dp_aptx_channels, conf_v.aptx.channel_mode) == -1) { @@ -407,14 +407,14 @@ static int a2dp_aptx_hd_transport_init(struct ba_transport *t) { t->a2dp.configuration.aptx_hd.aptx.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_aptx_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_aptx_rates, t->a2dp.configuration.aptx_hd.aptx.sampling_freq)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S24_4LE; t->a2dp.pcm.channels = a2dp_aptx_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_aptx_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_aptx_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_aptx_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-aptx.c b/src/a2dp-aptx.c index d7fbc0c62..f02572908 100644 --- a/src/a2dp-aptx.c +++ b/src/a2dp-aptx.c @@ -47,7 +47,7 @@ static const struct a2dp_bit_mapping a2dp_aptx_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_aptx_samplings[] = { +static const struct a2dp_bit_mapping a2dp_aptx_rates[] = { { APTX_SAMPLING_FREQ_16000, { 16000 } }, { APTX_SAMPLING_FREQ_32000, { 32000 } }, { APTX_SAMPLING_FREQ_44100, { 44100 } }, @@ -72,14 +72,14 @@ static int a2dp_aptx_caps_foreach_channel_mode( return -1; } -static int a2dp_aptx_caps_foreach_sampling_freq( +static int a2dp_aptx_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_aptx_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_aptx_samplings, caps->sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_aptx_rates, caps->sampling_freq, func, userdata); return -1; } @@ -93,23 +93,23 @@ static void a2dp_aptx_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_aptx_caps_select_sampling_freq( +static void a2dp_aptx_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_aptx_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aptx_samplings, - caps->sampling_freq, frequency); + caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_aptx_rates, + caps->sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_aptx_caps_helpers = { .intersect = a2dp_aptx_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_aptx_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_aptx_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_aptx_caps_foreach_sample_rate, .select_channel_mode = a2dp_aptx_caps_select_channel_mode, - .select_sampling_freq = a2dp_aptx_caps_select_sampling_freq, + .select_sample_rate = a2dp_aptx_caps_select_sample_rate, }; void *a2dp_aptx_enc_thread(struct ba_transport_pcm *t_pcm) { @@ -319,11 +319,11 @@ static int a2dp_aptx_configuration_select( a2dp_aptx_caps_intersect(caps, &sep->config.capabilities); unsigned int sampling_freq = 0; - if (a2dp_aptx_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_aptx_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) caps->sampling_freq = sampling_freq; else { - error("apt-X: No supported sampling frequencies: %#x", saved.sampling_freq); + error("apt-X: No supported sample rates: %#x", saved.sampling_freq); return errno = ENOTSUP, -1; } @@ -349,9 +349,9 @@ static int a2dp_aptx_configuration_check( /* Validate configuration against BlueALSA capabilities. */ a2dp_aptx_caps_intersect(&conf_v, &sep->config.capabilities); - if (a2dp_bit_mapping_lookup(a2dp_aptx_samplings, conf_v.sampling_freq) == -1) { - debug("apt-X: Invalid sampling frequency: %#x", conf->sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_aptx_rates, conf_v.sampling_freq) == -1) { + debug("apt-X: Invalid sample rate: %#x", conf->sampling_freq); + return A2DP_CHECK_ERR_RATE; } if (a2dp_bit_mapping_lookup(a2dp_aptx_channels, conf_v.channel_mode) == -1) { @@ -369,14 +369,14 @@ static int a2dp_aptx_transport_init(struct ba_transport *t) { t->a2dp.configuration.aptx.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_aptx_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_aptx_rates, t->a2dp.configuration.aptx.sampling_freq)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = a2dp_aptx_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_aptx_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_aptx_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_aptx_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-faststream.c b/src/a2dp-faststream.c index 5d2666df8..1234ec67e 100644 --- a/src/a2dp-faststream.c +++ b/src/a2dp-faststream.c @@ -32,24 +32,32 @@ #include "shared/log.h" #include "shared/rt.h" -static const struct a2dp_bit_mapping a2dp_faststream_samplings_music[] = { +static const enum ba_transport_pcm_channel a2dp_fs_channel_map_mono[] = { + BA_TRANSPORT_PCM_CHANNEL_MONO, +}; + +static const enum ba_transport_pcm_channel a2dp_fs_channel_map_stereo[] = { + BA_TRANSPORT_PCM_CHANNEL_FL, BA_TRANSPORT_PCM_CHANNEL_FR, +}; + +static const struct a2dp_bit_mapping a2dp_fs_rates_music[] = { { FASTSTREAM_SAMPLING_FREQ_MUSIC_44100, { 44100 } }, { FASTSTREAM_SAMPLING_FREQ_MUSIC_48000, { 48000 } }, { 0 } }; -static const struct a2dp_bit_mapping a2dp_faststream_samplings_voice[] = { +static const struct a2dp_bit_mapping a2dp_fs_rates_voice[] = { { FASTSTREAM_SAMPLING_FREQ_VOICE_16000, { 16000 } }, { 0 } }; -static void a2dp_faststream_caps_intersect( +static void a2dp_fs_caps_intersect( void *capabilities, const void *mask) { a2dp_caps_bitwise_intersect(capabilities, mask, sizeof(a2dp_faststream_t)); } -static bool a2dp_faststream_caps_has_stream( +static bool a2dp_fs_caps_has_stream( const void *capabilities, enum a2dp_stream stream) { const a2dp_faststream_t *caps = capabilities; @@ -58,33 +66,35 @@ static bool a2dp_faststream_caps_has_stream( return caps->direction & FASTSTREAM_DIRECTION_VOICE; } -static int a2dp_faststream_caps_foreach_channel_mode( +static int a2dp_fs_caps_foreach_channel_mode( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { (void)capabilities; - const struct a2dp_bit_mapping channels_mono = { .value = 1 }; - const struct a2dp_bit_mapping channels_stereo = { .value = 2 }; + const struct a2dp_bit_mapping channels_mono = { + .ch = { 1, a2dp_fs_channel_map_mono } }; + const struct a2dp_bit_mapping channels_stereo = { + .ch = { 2, a2dp_fs_channel_map_stereo } }; if (stream == A2DP_MAIN) return func(channels_stereo, userdata); return func(channels_mono, userdata); } -static int a2dp_faststream_caps_foreach_sampling_freq( +static int a2dp_fs_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_faststream_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_faststream_samplings_music, + return a2dp_bit_mapping_foreach(a2dp_fs_rates_music, caps->sampling_freq_music, func, userdata); - return a2dp_bit_mapping_foreach(a2dp_faststream_samplings_voice, + return a2dp_bit_mapping_foreach(a2dp_fs_rates_voice, caps->sampling_freq_voice, func, userdata); } -static void a2dp_faststream_caps_select_channel_mode( +static void a2dp_fs_caps_select_channel_mode( void *capabilities, enum a2dp_stream stream, unsigned int channels) { @@ -93,29 +103,29 @@ static void a2dp_faststream_caps_select_channel_mode( (void)channels; } -static void a2dp_faststream_caps_select_sampling_freq( +static void a2dp_fs_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_faststream_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq_music = a2dp_bit_mapping_lookup_value(a2dp_faststream_samplings_music, - caps->sampling_freq_music, frequency); + caps->sampling_freq_music = a2dp_bit_mapping_lookup_value(a2dp_fs_rates_music, + caps->sampling_freq_music, rate); else - caps->sampling_freq_voice = a2dp_bit_mapping_lookup_value(a2dp_faststream_samplings_voice, - caps->sampling_freq_voice, frequency); + caps->sampling_freq_voice = a2dp_bit_mapping_lookup_value(a2dp_fs_rates_voice, + caps->sampling_freq_voice, rate); } -static struct a2dp_caps_helpers a2dp_faststream_caps_helpers = { - .intersect = a2dp_faststream_caps_intersect, - .has_stream = a2dp_faststream_caps_has_stream, - .foreach_channel_mode = a2dp_faststream_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_faststream_caps_foreach_sampling_freq, - .select_channel_mode = a2dp_faststream_caps_select_channel_mode, - .select_sampling_freq = a2dp_faststream_caps_select_sampling_freq, +static struct a2dp_caps_helpers a2dp_fs_caps_helpers = { + .intersect = a2dp_fs_caps_intersect, + .has_stream = a2dp_fs_caps_has_stream, + .foreach_channel_mode = a2dp_fs_caps_foreach_channel_mode, + .foreach_sample_rate = a2dp_fs_caps_foreach_sample_rate, + .select_channel_mode = a2dp_fs_caps_select_channel_mode, + .select_sample_rate = a2dp_fs_caps_select_sample_rate, }; -void *a2dp_faststream_enc_thread(struct ba_transport_pcm *t_pcm) { +void *a2dp_fs_enc_thread(struct ba_transport_pcm *t_pcm) { pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm); @@ -237,7 +247,7 @@ void *a2dp_faststream_enc_thread(struct ba_transport_pcm *t_pcm) { } __attribute__ ((weak)) -void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm) { +void *a2dp_fs_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm); @@ -320,7 +330,7 @@ void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm) { return NULL; } -static int a2dp_faststream_configuration_select( +static int a2dp_fs_configuration_select( const struct a2dp_sep *sep, void *capabilities) { @@ -328,7 +338,7 @@ static int a2dp_faststream_configuration_select( const a2dp_faststream_t saved = *caps; /* Narrow capabilities to values supported by BlueALSA. */ - a2dp_faststream_caps_intersect(caps, &sep->config.capabilities); + a2dp_fs_caps_intersect(caps, &sep->config.capabilities); if ((caps->direction & (FASTSTREAM_DIRECTION_MUSIC | FASTSTREAM_DIRECTION_VOICE)) == 0) { error("FastStream: No supported directions: %#x", saved.direction); @@ -337,28 +347,28 @@ static int a2dp_faststream_configuration_select( unsigned int sampling_freq_v = 0; if (caps->direction & FASTSTREAM_DIRECTION_VOICE && - a2dp_faststream_caps_foreach_sampling_freq(caps, A2DP_BACKCHANNEL, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq_v) != -1) + a2dp_fs_caps_foreach_sample_rate(caps, A2DP_BACKCHANNEL, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq_v) != -1) caps->sampling_freq_voice = sampling_freq_v; else { - error("FastStream: No supported voice sampling frequencies: %#x", saved.sampling_freq_voice); + error("FastStream: No supported voice sample rates: %#x", saved.sampling_freq_voice); return errno = ENOTSUP, -1; } unsigned int sampling_freq_m = 0; if (caps->direction & FASTSTREAM_DIRECTION_MUSIC && - a2dp_faststream_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq_m) != -1) + a2dp_fs_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq_m) != -1) caps->sampling_freq_music = sampling_freq_m; else { - error("FastStream: No supported music sampling frequencies: %#x", saved.sampling_freq_music); + error("FastStream: No supported music sample rates: %#x", saved.sampling_freq_music); return errno = ENOTSUP, -1; } return 0; } -static int a2dp_faststream_configuration_check( +static int a2dp_fs_configuration_check( const struct a2dp_sep *sep, const void *configuration) { @@ -366,7 +376,7 @@ static int a2dp_faststream_configuration_check( a2dp_faststream_t conf_v = *conf; /* Validate configuration against BlueALSA capabilities. */ - a2dp_faststream_caps_intersect(&conf_v, &sep->config.capabilities); + a2dp_fs_caps_intersect(&conf_v, &sep->config.capabilities); if ((conf_v.direction & (FASTSTREAM_DIRECTION_MUSIC | FASTSTREAM_DIRECTION_VOICE)) == 0) { debug("FastStream: Invalid direction: %#x", conf->direction); @@ -374,57 +384,58 @@ static int a2dp_faststream_configuration_check( } if (conf_v.direction & FASTSTREAM_DIRECTION_VOICE && - a2dp_bit_mapping_lookup(a2dp_faststream_samplings_voice, conf_v.sampling_freq_voice) == -1) { - debug("FastStream: Invalid voice sampling frequency: %#x", conf->sampling_freq_voice); - return A2DP_CHECK_ERR_SAMPLING_VOICE; + a2dp_bit_mapping_lookup(a2dp_fs_rates_voice, conf_v.sampling_freq_voice) == -1) { + debug("FastStream: Invalid voice sample rate: %#x", conf->sampling_freq_voice); + return A2DP_CHECK_ERR_RATE_VOICE; } if (conf_v.direction & FASTSTREAM_DIRECTION_MUSIC && - a2dp_bit_mapping_lookup(a2dp_faststream_samplings_music, conf_v.sampling_freq_music) == -1) { - debug("FastStream: Invalid music sampling frequency: %#x", conf->sampling_freq_music); - return A2DP_CHECK_ERR_SAMPLING_MUSIC; + a2dp_bit_mapping_lookup(a2dp_fs_rates_music, conf_v.sampling_freq_music) == -1) { + debug("FastStream: Invalid music sample rate: %#x", conf->sampling_freq_music); + return A2DP_CHECK_ERR_RATE_MUSIC; } return A2DP_CHECK_OK; } -static int a2dp_faststream_transport_init(struct ba_transport *t) { +static int a2dp_fs_transport_init(struct ba_transport *t) { if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_MUSIC) { - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_faststream_samplings_music, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_fs_rates_music, t->a2dp.configuration.faststream.sampling_freq_music)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = 2; - t->a2dp.pcm.sampling = a2dp_faststream_samplings_music[sampling_i].value; + t->a2dp.pcm.rate = a2dp_fs_rates_music[rate_i].value; - t->a2dp.pcm.channel_map[0] = BA_TRANSPORT_PCM_CHANNEL_FL; - t->a2dp.pcm.channel_map[1] = BA_TRANSPORT_PCM_CHANNEL_FR; + memcpy(t->a2dp.pcm.channel_map, + a2dp_fs_channel_map_stereo, sizeof(a2dp_fs_channel_map_stereo)); } if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_VOICE) { - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_faststream_samplings_voice, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_fs_rates_voice, t->a2dp.configuration.faststream.sampling_freq_voice)) == -1) return -1; t->a2dp.pcm_bc.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm_bc.channels = 1; - t->a2dp.pcm_bc.sampling = a2dp_faststream_samplings_voice[sampling_i].value; + t->a2dp.pcm_bc.rate = a2dp_fs_rates_voice[rate_i].value; - t->a2dp.pcm_bc.channel_map[0] = BA_TRANSPORT_PCM_CHANNEL_MONO; + memcpy(t->a2dp.pcm_bc.channel_map, + a2dp_fs_channel_map_mono, sizeof(a2dp_fs_channel_map_mono)); } return 0; } -static int a2dp_faststream_source_init(struct a2dp_sep *sep) { +static int a2dp_fs_source_init(struct a2dp_sep *sep) { if (config.a2dp.force_mono) warn("FastStream: Mono channel mode not supported"); if (config.a2dp.force_44100) @@ -432,16 +443,16 @@ static int a2dp_faststream_source_init(struct a2dp_sep *sep) { return 0; } -static int a2dp_faststream_source_transport_start(struct ba_transport *t) { +static int a2dp_fs_source_transport_start(struct ba_transport *t) { struct ba_transport_pcm *pcm = &t->a2dp.pcm; struct ba_transport_pcm *pcm_bc = &t->a2dp.pcm_bc; int rv = 0; if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_MUSIC) - rv |= ba_transport_pcm_start(pcm, a2dp_faststream_enc_thread, "ba-a2dp-fs-m"); + rv |= ba_transport_pcm_start(pcm, a2dp_fs_enc_thread, "ba-a2dp-fs-m"); if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_VOICE) - rv |= ba_transport_pcm_start(pcm_bc, a2dp_faststream_dec_thread, "ba-a2dp-fs-v"); + rv |= ba_transport_pcm_start(pcm_bc, a2dp_fs_dec_thread, "ba-a2dp-fs-v"); return rv; } @@ -462,24 +473,24 @@ struct a2dp_sep a2dp_faststream_source = { FASTSTREAM_SAMPLING_FREQ_VOICE_16000, }, }, - .init = a2dp_faststream_source_init, - .configuration_select = a2dp_faststream_configuration_select, - .configuration_check = a2dp_faststream_configuration_check, - .transport_init = a2dp_faststream_transport_init, - .transport_start = a2dp_faststream_source_transport_start, - .caps_helpers = &a2dp_faststream_caps_helpers, + .init = a2dp_fs_source_init, + .configuration_select = a2dp_fs_configuration_select, + .configuration_check = a2dp_fs_configuration_check, + .transport_init = a2dp_fs_transport_init, + .transport_start = a2dp_fs_source_transport_start, + .caps_helpers = &a2dp_fs_caps_helpers, }; -static int a2dp_faststream_sink_transport_start(struct ba_transport *t) { +static int a2dp_fs_sink_transport_start(struct ba_transport *t) { struct ba_transport_pcm *pcm = &t->a2dp.pcm; struct ba_transport_pcm *pcm_bc = &t->a2dp.pcm_bc; int rv = 0; if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_MUSIC) - rv |= ba_transport_pcm_start(pcm, a2dp_faststream_dec_thread, "ba-a2dp-fs-m"); + rv |= ba_transport_pcm_start(pcm, a2dp_fs_dec_thread, "ba-a2dp-fs-m"); if (t->a2dp.configuration.faststream.direction & FASTSTREAM_DIRECTION_VOICE) - rv |= ba_transport_pcm_start(pcm_bc, a2dp_faststream_enc_thread, "ba-a2dp-fs-v"); + rv |= ba_transport_pcm_start(pcm_bc, a2dp_fs_enc_thread, "ba-a2dp-fs-v"); return rv; } @@ -500,9 +511,9 @@ struct a2dp_sep a2dp_faststream_sink = { FASTSTREAM_SAMPLING_FREQ_VOICE_16000, }, }, - .configuration_select = a2dp_faststream_configuration_select, - .configuration_check = a2dp_faststream_configuration_check, - .transport_init = a2dp_faststream_transport_init, - .transport_start = a2dp_faststream_sink_transport_start, - .caps_helpers = &a2dp_faststream_caps_helpers, + .configuration_select = a2dp_fs_configuration_select, + .configuration_check = a2dp_fs_configuration_check, + .transport_init = a2dp_fs_transport_init, + .transport_start = a2dp_fs_sink_transport_start, + .caps_helpers = &a2dp_fs_caps_helpers, }; diff --git a/src/a2dp-lc3plus.c b/src/a2dp-lc3plus.c index 2a7edecdd..98e84489e 100644 --- a/src/a2dp-lc3plus.c +++ b/src/a2dp-lc3plus.c @@ -53,7 +53,7 @@ static const struct a2dp_bit_mapping a2dp_lc3plus_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_lc3plus_samplings[] = { +static const struct a2dp_bit_mapping a2dp_lc3plus_rates[] = { { LC3PLUS_SAMPLING_FREQ_48000, { 48000 } }, { LC3PLUS_SAMPLING_FREQ_96000, { 96000 } }, { 0 } @@ -76,7 +76,7 @@ static int a2dp_lc3plus_caps_foreach_channel_mode( return -1; } -static int a2dp_lc3plus_caps_foreach_sampling_freq( +static int a2dp_lc3plus_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, @@ -84,7 +84,7 @@ static int a2dp_lc3plus_caps_foreach_sampling_freq( const a2dp_lc3plus_t *caps = capabilities; if (stream == A2DP_MAIN) { const uint16_t sampling_freq = A2DP_LC3PLUS_GET_SAMPLING_FREQ(*caps); - return a2dp_bit_mapping_foreach(a2dp_lc3plus_samplings, sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_lc3plus_rates, sampling_freq, func, userdata); } return -1; } @@ -99,14 +99,14 @@ static void a2dp_lc3plus_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_lc3plus_caps_select_sampling_freq( +static void a2dp_lc3plus_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_lc3plus_t *caps = capabilities; if (stream == A2DP_MAIN) { - const uint16_t sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_lc3plus_samplings, - A2DP_LC3PLUS_GET_SAMPLING_FREQ(*caps), frequency); + const uint16_t sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_lc3plus_rates, + A2DP_LC3PLUS_GET_SAMPLING_FREQ(*caps), rate); A2DP_LC3PLUS_SET_SAMPLING_FREQ(*caps, sampling_freq); } } @@ -115,31 +115,31 @@ static struct a2dp_caps_helpers a2dp_lc3plus_caps_helpers = { .intersect = a2dp_lc3plus_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_lc3plus_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_lc3plus_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_lc3plus_caps_foreach_sample_rate, .select_channel_mode = a2dp_lc3plus_caps_select_channel_mode, - .select_sampling_freq = a2dp_lc3plus_caps_select_sampling_freq, + .select_sample_rate = a2dp_lc3plus_caps_select_sample_rate, }; -static bool a2dp_lc3plus_supported(int samplerate, int channels) { +static bool a2dp_lc3plus_supported(int rate, int channels) { if (lc3plus_channels_supported(channels) == 0) { error("Number of channels not supported by LC3plus library: %u", channels); return false; } - if (lc3plus_samplerate_supported(samplerate) == 0) { - error("Sampling frequency not supported by LC3plus library: %u", samplerate); + if (lc3plus_samplerate_supported(rate) == 0) { + error("sample rate not supported by LC3plus library: %u", rate); return false; } return true; } -static LC3PLUS_Enc *a2dp_lc3plus_enc_init(int samplerate, int channels) { +static LC3PLUS_Enc *a2dp_lc3plus_enc_init(int rate, int channels) { LC3PLUS_Enc *handle; int32_t lfe_channel_array[1] = { 0 }; - if ((handle = malloc(lc3plus_enc_get_size(samplerate, channels))) != NULL && - lc3plus_enc_init(handle, samplerate, channels, 1, lfe_channel_array) == LC3PLUS_OK) + if ((handle = malloc(lc3plus_enc_get_size(rate, channels))) != NULL && + lc3plus_enc_init(handle, rate, channels, 1, lfe_channel_array) == LC3PLUS_OK) return handle; free(handle); return NULL; @@ -152,10 +152,10 @@ static void a2dp_lc3plus_enc_free(LC3PLUS_Enc *handle) { free(handle); } -static LC3PLUS_Dec *a2dp_lc3plus_dec_init(int samplerate, int channels) { +static LC3PLUS_Dec *a2dp_lc3plus_dec_init(int rate, int channels) { LC3PLUS_Dec *handle; - if ((handle = malloc(lc3plus_dec_get_size(samplerate, channels))) != NULL && - lc3plus_dec_init(handle, samplerate, channels, LC3PLUS_PLC_ADVANCED, 1) == LC3PLUS_OK) + if ((handle = malloc(lc3plus_dec_get_size(rate, channels))) != NULL && + lc3plus_dec_init(handle, rate, channels, LC3PLUS_PLC_ADVANCED, 1) == LC3PLUS_OK) return handle; free(handle); return NULL; @@ -194,17 +194,17 @@ void *a2dp_lc3plus_enc_thread(struct ba_transport_pcm *t_pcm) { const a2dp_lc3plus_t *configuration = &t->a2dp.configuration.lc3plus; const int lc3plus_frame_dms = a2dp_lc3plus_get_frame_dms(configuration); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; const unsigned int rtp_ts_clockrate = 96000; /* check whether library supports selected configuration */ - if (!a2dp_lc3plus_supported(samplerate, channels)) + if (!a2dp_lc3plus_supported(rate, channels)) goto fail_init; LC3PLUS_Enc *handle; LC3PLUS_Error err; - if ((handle = a2dp_lc3plus_enc_init(samplerate, channels)) == NULL) { + if ((handle = a2dp_lc3plus_enc_init(rate, channels)) == NULL) { error("Couldn't initialize LC3plus codec: %s", strerror(errno)); goto fail_init; } @@ -263,7 +263,7 @@ void *a2dp_lc3plus_enc_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to the RTP clock rate */ - rtp_state_init(&rtp, samplerate, rtp_ts_clockrate); + rtp_state_init(&rtp, rate, rtp_ts_clockrate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -416,17 +416,17 @@ void *a2dp_lc3plus_dec_thread(struct ba_transport_pcm *t_pcm) { const a2dp_lc3plus_t *configuration = &t->a2dp.configuration.lc3plus; const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; const unsigned int rtp_ts_clockrate = 96000; /* check whether library supports selected configuration */ - if (!a2dp_lc3plus_supported(samplerate, channels)) + if (!a2dp_lc3plus_supported(rate, channels)) goto fail_init; LC3PLUS_Dec *handle; LC3PLUS_Error err; - if ((handle = a2dp_lc3plus_dec_init(samplerate, channels)) == NULL) { + if ((handle = a2dp_lc3plus_dec_init(rate, channels)) == NULL) { error("Couldn't initialize LC3plus codec: %s", strerror(errno)); goto fail_init; } @@ -465,7 +465,7 @@ void *a2dp_lc3plus_dec_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to the RTP clock rate */ - rtp_state_init(&rtp, samplerate, rtp_ts_clockrate); + rtp_state_init(&rtp, rate, rtp_ts_clockrate); /* If true, we should skip fragmented RTP media packets until we will see * not fragmented one or the first fragment of fragmented packet. */ @@ -646,11 +646,11 @@ static int a2dp_lc3plus_configuration_select( } unsigned int sampling_freq = 0; - if (a2dp_lc3plus_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_lc3plus_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) A2DP_LC3PLUS_SET_SAMPLING_FREQ(*caps, sampling_freq); else { - error("LC3plus: No supported sampling frequencies: %#x", A2DP_LC3PLUS_GET_SAMPLING_FREQ(saved)); + error("LC3plus: No supported sample rates: %#x", A2DP_LC3PLUS_GET_SAMPLING_FREQ(saved)); return errno = ENOTSUP, -1; } @@ -683,9 +683,9 @@ static int a2dp_lc3plus_configuration_check( } uint16_t conf_sampling_freq = A2DP_LC3PLUS_GET_SAMPLING_FREQ(conf_v); - if (a2dp_bit_mapping_lookup(a2dp_lc3plus_samplings, conf_sampling_freq) == -1) { - debug("LC3plus: Invalid sampling frequency: %#x", A2DP_LC3PLUS_GET_SAMPLING_FREQ(*conf)); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_lc3plus_rates, conf_sampling_freq) == -1) { + debug("LC3plus: Invalid sample rate: %#x", A2DP_LC3PLUS_GET_SAMPLING_FREQ(*conf)); + return A2DP_CHECK_ERR_RATE; } return A2DP_CHECK_OK; @@ -698,14 +698,14 @@ static int a2dp_lc3plus_transport_init(struct ba_transport *t) { t->a2dp.configuration.lc3plus.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_lc3plus_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_lc3plus_rates, A2DP_LC3PLUS_GET_SAMPLING_FREQ(t->a2dp.configuration.lc3plus))) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S24_4LE; t->a2dp.pcm.channels = a2dp_lc3plus_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_lc3plus_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_lc3plus_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_lc3plus_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); @@ -717,7 +717,7 @@ static int a2dp_lc3plus_source_init(struct a2dp_sep *sep) { if (config.a2dp.force_mono) sep->config.capabilities.lc3plus.channel_mode = LC3PLUS_CHANNEL_MODE_MONO; if (config.a2dp.force_44100) - warn("LC3plus: 44.1 kHz sampling frequency not supported"); + warn("LC3plus: 44.1 kHz sample rate not supported"); return 0; } diff --git a/src/a2dp-ldac.c b/src/a2dp-ldac.c index 47729f6c7..0c450fefa 100644 --- a/src/a2dp-ldac.c +++ b/src/a2dp-ldac.c @@ -51,7 +51,7 @@ static const struct a2dp_bit_mapping a2dp_ldac_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_ldac_samplings[] = { +static const struct a2dp_bit_mapping a2dp_ldac_rates[] = { { LDAC_SAMPLING_FREQ_44100, { 44100 } }, { LDAC_SAMPLING_FREQ_48000, { 48000 } }, { LDAC_SAMPLING_FREQ_88200, { 88200 } }, @@ -78,14 +78,14 @@ static int a2dp_ldac_caps_foreach_channel_mode( return -1; } -static int a2dp_ldac_caps_foreach_sampling_freq( +static int a2dp_ldac_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_ldac_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_ldac_samplings, caps->sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_ldac_rates, caps->sampling_freq, func, userdata); return -1; } @@ -99,23 +99,23 @@ static void a2dp_ldac_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_ldac_caps_select_sampling_freq( +static void a2dp_ldac_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_ldac_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_ldac_samplings, - caps->sampling_freq, frequency); + caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_ldac_rates, + caps->sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_ldac_caps_helpers = { .intersect = a2dp_ldac_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_ldac_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_ldac_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_ldac_caps_foreach_sample_rate, .select_channel_mode = a2dp_ldac_caps_select_channel_mode, - .select_sampling_freq = a2dp_ldac_caps_select_sampling_freq, + .select_sample_rate = a2dp_ldac_caps_select_sample_rate, }; void *a2dp_ldac_enc_thread(struct ba_transport_pcm *t_pcm) { @@ -145,16 +145,16 @@ void *a2dp_ldac_enc_thread(struct ba_transport_pcm *t_pcm) { const a2dp_ldac_t *configuration = &t->a2dp.configuration.ldac; const size_t sample_size = BA_TRANSPORT_PCM_FORMAT_BYTES(t_pcm->format); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; const size_t ldac_pcm_samples = LDACBT_ENC_LSU * channels; if (ldacBT_init_handle_encode(handle, t->mtu_write, config.ldac_eqmid, - configuration->channel_mode, LDACBT_SMPL_FMT_S32, samplerate) == -1) { + configuration->channel_mode, LDACBT_SMPL_FMT_S32, rate) == -1) { error("Couldn't initialize LDAC encoder: %s", ldacBT_strerror(ldacBT_get_error_code(handle))); goto fail_init; } - if (ldac_ABR_Init(handle_abr, 1000 * ldac_pcm_samples / channels / samplerate) == -1) { + if (ldac_ABR_Init(handle_abr, 1000 * ldac_pcm_samples / channels / rate) == -1) { error("Couldn't initialize LDAC ABR"); goto fail_init; } @@ -181,8 +181,8 @@ void *a2dp_ldac_enc_thread(struct ba_transport_pcm *t_pcm) { (void **)&rtp_media_header, sizeof(*rtp_media_header)); struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -313,9 +313,9 @@ void *a2dp_ldac_dec_thread(struct ba_transport_pcm *t_pcm) { const a2dp_ldac_t *configuration = &t->a2dp.configuration.ldac; const size_t sample_size = BA_TRANSPORT_PCM_FORMAT_BYTES(t_pcm->format); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; - if (ldacBT_init_handle_decode(handle, configuration->channel_mode, samplerate, 0, 0, 0) == -1) { + if (ldacBT_init_handle_decode(handle, configuration->channel_mode, rate, 0, 0, 0) == -1) { error("Couldn't initialize LDAC decoder: %s", ldacBT_strerror(ldacBT_get_error_code(handle))); goto fail_init; } @@ -332,8 +332,8 @@ void *a2dp_ldac_dec_thread(struct ba_transport_pcm *t_pcm) { } struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -413,11 +413,11 @@ static int a2dp_ldac_configuration_select( a2dp_ldac_caps_intersect(caps, &sep->config.capabilities); unsigned int sampling_freq = 0; - if (a2dp_ldac_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_ldac_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) caps->sampling_freq = sampling_freq; else { - error("LDAC: No supported sampling frequencies: %#x", saved.sampling_freq); + error("LDAC: No supported sample rates: %#x", saved.sampling_freq); return errno = ENOTSUP, -1; } @@ -443,9 +443,9 @@ static int a2dp_ldac_configuration_check( /* Validate configuration against BlueALSA capabilities. */ a2dp_ldac_caps_intersect(&conf_v, &sep->config.capabilities); - if (a2dp_bit_mapping_lookup(a2dp_ldac_samplings, conf_v.sampling_freq) == -1) { - debug("LDAC: Invalid sampling frequency: %#x", conf->sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_ldac_rates, conf_v.sampling_freq) == -1) { + debug("LDAC: Invalid sample rate: %#x", conf->sampling_freq); + return A2DP_CHECK_ERR_RATE; } if (a2dp_bit_mapping_lookup(a2dp_ldac_channels, conf_v.channel_mode) == -1) { @@ -463,8 +463,8 @@ static int a2dp_ldac_transport_init(struct ba_transport *t) { t->a2dp.configuration.ldac.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_ldac_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_ldac_rates, t->a2dp.configuration.ldac.sampling_freq)) == -1) return -1; @@ -472,7 +472,7 @@ static int a2dp_ldac_transport_init(struct ba_transport *t) { * floats, so the best choice for PCM sample is signed 32-bit. */ t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S32_4LE; t->a2dp.pcm.channels = a2dp_ldac_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_ldac_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_ldac_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_ldac_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-mpeg.c b/src/a2dp-mpeg.c index 89b22d04a..7a9bfa957 100644 --- a/src/a2dp-mpeg.c +++ b/src/a2dp-mpeg.c @@ -60,7 +60,7 @@ static const struct a2dp_bit_mapping a2dp_mpeg_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_mpeg_samplings[] = { +static const struct a2dp_bit_mapping a2dp_mpeg_rates[] = { { MPEG_SAMPLING_FREQ_16000, { 16000 } }, { MPEG_SAMPLING_FREQ_22050, { 22050 } }, { MPEG_SAMPLING_FREQ_24000, { 24000 } }, @@ -87,14 +87,14 @@ static int a2dp_mpeg_caps_foreach_channel_mode( return -1; } -static int a2dp_mpeg_caps_foreach_sampling_freq( +static int a2dp_mpeg_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_mpeg_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_mpeg_samplings, caps->sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_mpeg_rates, caps->sampling_freq, func, userdata); return -1; } @@ -108,23 +108,23 @@ static void a2dp_mpeg_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_mpeg_caps_select_sampling_freq( +static void a2dp_mpeg_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_mpeg_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_mpeg_samplings, - caps->sampling_freq, frequency); + caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_mpeg_rates, + caps->sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_mpeg_caps_helpers = { .intersect = a2dp_mpeg_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_mpeg_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_mpeg_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_mpeg_caps_foreach_sample_rate, .select_channel_mode = a2dp_mpeg_caps_select_channel_mode, - .select_sampling_freq = a2dp_mpeg_caps_select_sampling_freq, + .select_sample_rate = a2dp_mpeg_caps_select_sample_rate, }; #if ENABLE_MP3LAME @@ -146,11 +146,11 @@ void *a2dp_mp3_enc_thread(struct ba_transport_pcm *t_pcm) { const a2dp_mpeg_t *configuration = &t->a2dp.configuration.mpeg; const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; MPEG_mode mode = NOT_SET; lame_set_num_channels(handle, channels); - lame_set_in_samplerate(handle, samplerate); + lame_set_in_samplerate(handle, rate); switch (configuration->channel_mode) { case MPEG_CHANNEL_MODE_MONO: @@ -242,7 +242,7 @@ void *a2dp_mp3_enc_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to 90kHz */ - rtp_state_init(&rtp, samplerate, 90000); + rtp_state_init(&rtp, rate, 90000); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -367,7 +367,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(mpg123_delete), handle); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; mpg123_param(handle, MPG123_RESYNC_LIMIT, -1, 0); mpg123_param(handle, MPG123_ADD_FLAGS, MPG123_QUIET, 0); @@ -376,7 +376,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { #endif mpg123_format_none(handle); - if (mpg123_format(handle, samplerate, channels, MPG123_ENC_SIGNED_16) != MPG123_OK) { + if (mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16) != MPG123_OK) { error("Couldn't set MPG123 format: %s", mpg123_strerror(handle)); goto fail_open; } @@ -397,7 +397,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { } const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; pthread_cleanup_push(PTHREAD_CLEANUP(hip_decode_exit), handle); /* NOTE: Size of the output buffer is "hard-coded" in hip_decode(). What is @@ -421,7 +421,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { struct rtp_state rtp = { .synced = false }; /* RTP clock frequency equal to 90kHz */ - rtp_state_init(&rtp, samplerate, 90000); + rtp_state_init(&rtp, rate, 90000); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -452,7 +452,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { #if ENABLE_MPG123 - long rate; + long rate_; int channels_; int encoding; @@ -464,8 +464,8 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { case MPG123_OK: break; case MPG123_NEW_FORMAT: - mpg123_getformat(handle, &rate, &channels_, &encoding); - debug("MPG123 new format detected: r:%ld, ch:%d, enc:%#x", rate, channels_, encoding); + mpg123_getformat(handle, &rate_, &channels_, &encoding); + debug("MPG123 new format detected: r:%ld, ch:%d, enc:%#x", rate_, channels_, encoding); break; default: error("MPG123 decoding error: %s", mpg123_strerror(handle)); @@ -567,11 +567,11 @@ static int a2dp_mpeg_configuration_select( } unsigned int sampling_freq = 0; - if (a2dp_mpeg_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_mpeg_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) caps->sampling_freq = sampling_freq; else { - error("MPEG: No supported sampling frequencies: %#x", saved.sampling_freq); + error("MPEG: No supported sample rates: %#x", saved.sampling_freq); return errno = ENOTSUP, -1; } @@ -608,9 +608,9 @@ static int a2dp_mpeg_configuration_check( return A2DP_CHECK_ERR_CHANNEL_MODE; } - if (a2dp_bit_mapping_lookup(a2dp_mpeg_samplings, conf_v.sampling_freq) == -1) { - debug("MPEG: Invalid sampling frequency: %#x", conf->sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_mpeg_rates, conf_v.sampling_freq) == -1) { + debug("MPEG: Invalid sample rate: %#x", conf->sampling_freq); + return A2DP_CHECK_ERR_RATE; } return A2DP_CHECK_OK; @@ -623,14 +623,14 @@ static int a2dp_mpeg_transport_init(struct ba_transport *t) { t->a2dp.configuration.mpeg.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_mpeg_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_mpeg_rates, t->a2dp.configuration.mpeg.sampling_freq)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = a2dp_mpeg_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_mpeg_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_mpeg_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_mpeg_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-opus.c b/src/a2dp-opus.c index d7a9a48ba..32c2933ec 100644 --- a/src/a2dp-opus.c +++ b/src/a2dp-opus.c @@ -51,7 +51,7 @@ static const struct a2dp_bit_mapping a2dp_opus_channels[] = { { 0 } }; -static const struct a2dp_bit_mapping a2dp_opus_samplings[] = { +static const struct a2dp_bit_mapping a2dp_opus_rates[] = { { OPUS_SAMPLING_FREQ_48000, { 48000 } }, { 0 } }; @@ -73,14 +73,14 @@ static int a2dp_opus_caps_foreach_channel_mode( return -1; } -static int a2dp_opus_caps_foreach_sampling_freq( +static int a2dp_opus_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_opus_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_opus_samplings, caps->sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_opus_rates, caps->sampling_freq, func, userdata); return -1; } @@ -94,23 +94,23 @@ static void a2dp_opus_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_opus_caps_select_sampling_freq( +static void a2dp_opus_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_opus_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_opus_samplings, - caps->sampling_freq, frequency); + caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_opus_rates, + caps->sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_opus_caps_helpers = { .intersect = a2dp_opus_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_opus_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_opus_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_opus_caps_foreach_sample_rate, .select_channel_mode = a2dp_opus_caps_select_channel_mode, - .select_sampling_freq = a2dp_opus_caps_select_sampling_freq, + .select_sample_rate = a2dp_opus_caps_select_sample_rate, }; static unsigned int a2dp_opus_get_frame_dms(const a2dp_opus_t *conf) { @@ -140,15 +140,15 @@ void *a2dp_opus_enc_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(opus_encoder_destroy_ptr), &opus); const a2dp_opus_t *configuration = &t->a2dp.configuration.opus; - const unsigned int channels = t->a2dp.pcm.channels; - const unsigned int sampling = t->a2dp.pcm.sampling; + const unsigned int channels = t_pcm->channels; + const unsigned int rate = t_pcm->rate; const unsigned int opus_frame_dms = a2dp_opus_get_frame_dms(configuration); - const size_t opus_frame_pcm_samples = opus_frame_dms * sampling / 10000; + const size_t opus_frame_pcm_samples = opus_frame_dms * rate / 10000; const size_t opus_frame_pcm_frames = opus_frame_pcm_samples / channels; int err; - if ((opus = opus_encoder_create(sampling, channels, OPUS_APPLICATION_AUDIO, &err)) == NULL || - (err = opus_encoder_init(opus, sampling, channels, OPUS_APPLICATION_AUDIO)) != OPUS_OK) { + if ((opus = opus_encoder_create(rate, channels, OPUS_APPLICATION_AUDIO, &err)) == NULL || + (err = opus_encoder_init(opus, rate, channels, OPUS_APPLICATION_AUDIO)) != OPUS_OK) { error("Couldn't initialize Opus encoder: %s", opus_strerror(err)); goto fail_init; } @@ -181,8 +181,8 @@ void *a2dp_opus_enc_thread(struct ba_transport_pcm *t_pcm) { (void **)&rtp_media_header, sizeof(*rtp_media_header)); struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio sampling rate */ - rtp_state_init(&rtp, sampling, sampling); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -190,7 +190,7 @@ void *a2dp_opus_enc_thread(struct ba_transport_pcm *t_pcm) { switch (io_poll_and_read_pcm(&io, t_pcm, &pcm)) { case -1: if (errno == ESTALE) { - opus_encoder_init(opus, sampling, channels, OPUS_APPLICATION_AUDIO); + opus_encoder_init(opus, rate, channels, OPUS_APPLICATION_AUDIO); ffb_rewind(&pcm); continue; } @@ -277,14 +277,14 @@ void *a2dp_opus_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(opus_decoder_destroy_ptr), &opus); const a2dp_opus_t *configuration = &t->a2dp.configuration.opus; - const unsigned int channels = t->a2dp.pcm.channels; - const unsigned int sampling = t->a2dp.pcm.sampling; + const unsigned int channels = t_pcm->channels; + const unsigned int rate = t_pcm->rate; const unsigned int opus_frame_dms = a2dp_opus_get_frame_dms(configuration); - const size_t opus_frame_pcm_samples = opus_frame_dms * sampling / 10000; + const size_t opus_frame_pcm_samples = opus_frame_dms * rate / 10000; int err; - if ((opus = opus_decoder_create(sampling, channels, &err)) == NULL || - (err = opus_decoder_init(opus, sampling, channels)) != OPUS_OK) { + if ((opus = opus_decoder_create(rate, channels, &err)) == NULL || + (err = opus_decoder_init(opus, rate, channels)) != OPUS_OK) { error("Couldn't initialize Opus decoder: %s", opus_strerror(err)); goto fail_init; } @@ -301,8 +301,8 @@ void *a2dp_opus_dec_thread(struct ba_transport_pcm *t_pcm) { } struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio sampling rate */ - rtp_state_init(&rtp, sampling, sampling); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -369,11 +369,11 @@ static int a2dp_opus_configuration_select( a2dp_opus_caps_intersect(caps, &sep->config.capabilities); unsigned int sampling_freq = 0; - if (a2dp_opus_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) != -1) + if (a2dp_opus_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) != -1) caps->sampling_freq = sampling_freq; else { - error("Opus: No supported sampling frequencies: %#x", saved.sampling_freq); + error("Opus: No supported sample rates: %#x", saved.sampling_freq); return errno = ENOTSUP, -1; } @@ -408,9 +408,9 @@ static int a2dp_opus_configuration_check( /* Validate configuration against BlueALSA capabilities. */ a2dp_opus_caps_intersect(&conf_v, &sep->config.capabilities); - if (a2dp_bit_mapping_lookup(a2dp_opus_samplings, conf_v.sampling_freq) == -1) { - debug("Opus: Invalid sampling frequency: %#x", conf->sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_opus_rates, conf_v.sampling_freq) == -1) { + debug("Opus: Invalid sample rate: %#x", conf->sampling_freq); + return A2DP_CHECK_ERR_RATE; } switch (conf_v.frame_duration) { @@ -437,14 +437,14 @@ static int a2dp_opus_transport_init(struct ba_transport *t) { t->a2dp.configuration.opus.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_opus_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_opus_rates, t->a2dp.configuration.opus.sampling_freq)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = a2dp_opus_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_opus_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_opus_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_opus_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp-sbc.c b/src/a2dp-sbc.c index 8dedf2e95..1ffd27585 100644 --- a/src/a2dp-sbc.c +++ b/src/a2dp-sbc.c @@ -54,7 +54,7 @@ static const struct a2dp_bit_mapping a2dp_sbc_channels[] = { { 0 }, }; -static const struct a2dp_bit_mapping a2dp_sbc_samplings[] = { +static const struct a2dp_bit_mapping a2dp_sbc_rates[] = { { SBC_SAMPLING_FREQ_16000, { 16000 } }, { SBC_SAMPLING_FREQ_32000, { 32000 } }, { SBC_SAMPLING_FREQ_44100, { 44100 } }, @@ -89,14 +89,14 @@ static int a2dp_sbc_caps_foreach_channel_mode( return -1; } -static int a2dp_sbc_caps_foreach_sampling_freq( +static int a2dp_sbc_caps_foreach_sample_rate( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, void *userdata) { const a2dp_sbc_t *caps = capabilities; if (stream == A2DP_MAIN) - return a2dp_bit_mapping_foreach(a2dp_sbc_samplings, caps->sampling_freq, func, userdata); + return a2dp_bit_mapping_foreach(a2dp_sbc_rates, caps->sampling_freq, func, userdata); return -1; } @@ -110,23 +110,23 @@ static void a2dp_sbc_caps_select_channel_mode( caps->channel_mode, channels); } -static void a2dp_sbc_caps_select_sampling_freq( +static void a2dp_sbc_caps_select_sample_rate( void *capabilities, enum a2dp_stream stream, - unsigned int frequency) { + unsigned int rate) { a2dp_sbc_t *caps = capabilities; if (stream == A2DP_MAIN) - caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_sbc_samplings, - caps->sampling_freq, frequency); + caps->sampling_freq = a2dp_bit_mapping_lookup_value(a2dp_sbc_rates, + caps->sampling_freq, rate); } static struct a2dp_caps_helpers a2dp_sbc_caps_helpers = { .intersect = a2dp_sbc_caps_intersect, .has_stream = a2dp_caps_has_main_stream_only, .foreach_channel_mode = a2dp_sbc_caps_foreach_channel_mode, - .foreach_sampling_freq = a2dp_sbc_caps_foreach_sampling_freq, + .foreach_sample_rate = a2dp_sbc_caps_foreach_sample_rate, .select_channel_mode = a2dp_sbc_caps_select_channel_mode, - .select_sampling_freq = a2dp_sbc_caps_select_sampling_freq, + .select_sample_rate = a2dp_sbc_caps_select_sample_rate, }; void *a2dp_sbc_enc_thread(struct ba_transport_pcm *t_pcm) { @@ -152,7 +152,7 @@ void *a2dp_sbc_enc_thread(struct ba_transport_pcm *t_pcm) { const size_t sbc_frame_samples = sbc_get_codesize(&sbc) / sizeof(int16_t); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; /* initialize SBC encoder bit-pool */ sbc.bitpool = sbc_a2dp_get_bitpool(configuration, config.sbc_quality); @@ -193,8 +193,8 @@ void *a2dp_sbc_enc_thread(struct ba_transport_pcm *t_pcm) { (void **)&rtp_media_header, sizeof(*rtp_media_header)); struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); debug_transport_pcm_thread_loop(t_pcm, "START"); for (ba_transport_pcm_state_set_running(t_pcm);;) { @@ -320,7 +320,7 @@ void *a2dp_sbc_dec_thread(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(ffb_free), &pcm); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; if (ffb_init_int16_t(&pcm, sbc_get_codesize(&sbc)) == -1 || ffb_init_uint8_t(&bt, t->mtu_read) == -1) { @@ -329,8 +329,8 @@ void *a2dp_sbc_dec_thread(struct ba_transport_pcm *t_pcm) { } struct rtp_state rtp = { .synced = false }; - /* RTP clock frequency equal to audio samplerate */ - rtp_state_init(&rtp, samplerate, samplerate); + /* RTP clock frequency equal to PCM sample rate */ + rtp_state_init(&rtp, rate, rate); #if DEBUG uint16_t sbc_bitpool = 0; @@ -418,9 +418,9 @@ static int a2dp_sbc_configuration_select( a2dp_sbc_caps_intersect(caps, &sep->config.capabilities); unsigned int sampling_freq = 0; - if (a2dp_sbc_caps_foreach_sampling_freq(caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq) == -1) { - error("SBC: No supported sampling frequencies: %#x", saved.sampling_freq); + if (a2dp_sbc_caps_foreach_sample_rate(caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq) == -1) { + error("SBC: No supported sample rates: %#x", saved.sampling_freq); return errno = ENOTSUP, -1; } @@ -436,7 +436,7 @@ static int a2dp_sbc_configuration_select( if (caps->sampling_freq & SBC_SAMPLING_FREQ_44100) sampling_freq = SBC_SAMPLING_FREQ_44100; else - warn("SBC XQ: 44.1 kHz sampling frequency not supported: %#x", saved.sampling_freq); + warn("SBC XQ: 44.1 kHz sample rate not supported: %#x", saved.sampling_freq); if (caps->channel_mode & SBC_CHANNEL_MODE_DUAL_CHANNEL) channel_mode = SBC_CHANNEL_MODE_DUAL_CHANNEL; else @@ -496,9 +496,9 @@ static int a2dp_sbc_configuration_check( /* Validate configuration against BlueALSA capabilities. */ a2dp_sbc_caps_intersect(&conf_v, &sep->config.capabilities); - if (a2dp_bit_mapping_lookup(a2dp_sbc_samplings, conf_v.sampling_freq) == -1) { - debug("SBC: Invalid sampling frequency: %#x", conf->sampling_freq); - return A2DP_CHECK_ERR_SAMPLING; + if (a2dp_bit_mapping_lookup(a2dp_sbc_rates, conf_v.sampling_freq) == -1) { + debug("SBC: Invalid sample rate: %#x", conf->sampling_freq); + return A2DP_CHECK_ERR_RATE; } if (a2dp_bit_mapping_lookup(a2dp_sbc_channels, conf_v.channel_mode) == -1) { @@ -554,14 +554,14 @@ static int a2dp_sbc_transport_init(struct ba_transport *t) { t->a2dp.configuration.sbc.channel_mode)) == -1) return -1; - ssize_t sampling_i; - if ((sampling_i = a2dp_bit_mapping_lookup(a2dp_sbc_samplings, + ssize_t rate_i; + if ((rate_i = a2dp_bit_mapping_lookup(a2dp_sbc_rates, t->a2dp.configuration.sbc.sampling_freq)) == -1) return -1; t->a2dp.pcm.format = BA_TRANSPORT_PCM_FORMAT_S16_2LE; t->a2dp.pcm.channels = a2dp_sbc_channels[channels_i].value; - t->a2dp.pcm.sampling = a2dp_sbc_samplings[sampling_i].value; + t->a2dp.pcm.rate = a2dp_sbc_rates[rate_i].value; memcpy(t->a2dp.pcm.channel_map, a2dp_sbc_channels[channels_i].ch.map, t->a2dp.pcm.channels * sizeof(*t->a2dp.pcm.channel_map)); diff --git a/src/a2dp.c b/src/a2dp.c index f6d45117b..f3dbb7be5 100644 --- a/src/a2dp.c +++ b/src/a2dp.c @@ -74,18 +74,18 @@ int a2dp_bit_mapping_foreach_get_best_channel_mode( } /** - * Callback function which returns bitmask for the best sampling rate. + * Callback function which returns bitmask for the best sample rate. * * Note: * The user data passed to a2dp_bit_mapping_foreach() function shall be * a pointer to an unsigned integer variable initialized to 0. */ -int a2dp_bit_mapping_foreach_get_best_sampling_freq( +int a2dp_bit_mapping_foreach_get_best_sample_rate( struct a2dp_bit_mapping mapping, void *userdata) { unsigned int *output = userdata; - /* Skip anything above 48000 Hz. If desired, bigger sampling rates can be + /* Skip anything above 48000 Hz. If desired, bigger sample rates can be * selected manually by the user using the SelectCodec() D-Bus method. */ if (mapping.value > 48000 && *output != 0) return 1; @@ -95,7 +95,7 @@ int a2dp_bit_mapping_foreach_get_best_sampling_freq( if (config.a2dp.force_44100 && mapping.value == 44100) return 1; - /* Keep iterating, so the last sampling rate will be selected. */ + /* Keep iterating, so the last sample rate will be selected. */ return 0; } @@ -364,8 +364,8 @@ const char *a2dp_check_strerror( return "Invalid size"; case A2DP_CHECK_ERR_CHANNEL_MODE: return "Invalid channel mode"; - case A2DP_CHECK_ERR_SAMPLING: - return "Invalid sampling frequency"; + case A2DP_CHECK_ERR_RATE: + return "Invalid sample rate"; case A2DP_CHECK_ERR_ALLOCATION_METHOD: return "Invalid allocation method"; case A2DP_CHECK_ERR_BIT_POOL_RANGE: @@ -380,10 +380,10 @@ const char *a2dp_check_strerror( return "Invalid object type"; case A2DP_CHECK_ERR_DIRECTIONS: return "Invalid directions"; - case A2DP_CHECK_ERR_SAMPLING_VOICE: - return "Invalid voice sampling frequency"; - case A2DP_CHECK_ERR_SAMPLING_MUSIC: - return "Invalid music sampling frequency"; + case A2DP_CHECK_ERR_RATE_VOICE: + return "Invalid voice sample rate"; + case A2DP_CHECK_ERR_RATE_MUSIC: + return "Invalid music sample rate"; case A2DP_CHECK_ERR_FRAME_DURATION: return "Invalid frame duration"; } diff --git a/src/a2dp.h b/src/a2dp.h index 7a7ba0e89..d451310f8 100644 --- a/src/a2dp.h +++ b/src/a2dp.h @@ -59,7 +59,7 @@ typedef int (*a2dp_bit_mapping_foreach_func)( int a2dp_bit_mapping_foreach_get_best_channel_mode( struct a2dp_bit_mapping mapping, void *userdata); -int a2dp_bit_mapping_foreach_get_best_sampling_freq( +int a2dp_bit_mapping_foreach_get_best_sample_rate( struct a2dp_bit_mapping mapping, void *userdata); @@ -116,8 +116,8 @@ struct a2dp_caps_helpers { a2dp_bit_mapping_foreach_func func, void *userdata); - /* Function for iterating over sampling frequencies. */ - int (*foreach_sampling_freq)( + /* Function for iterating over sample rates. */ + int (*foreach_sample_rate)( const void *capabilities, enum a2dp_stream stream, a2dp_bit_mapping_foreach_func func, @@ -128,10 +128,10 @@ struct a2dp_caps_helpers { enum a2dp_stream stream, unsigned int channels); - void (*select_sampling_freq)( + void (*select_sample_rate)( void *capabilities, enum a2dp_stream stream, - unsigned int frequency); + unsigned int rate); }; @@ -219,7 +219,7 @@ enum a2dp_check_err { A2DP_CHECK_OK = 0, A2DP_CHECK_ERR_SIZE, A2DP_CHECK_ERR_CHANNEL_MODE, - A2DP_CHECK_ERR_SAMPLING, + A2DP_CHECK_ERR_RATE, A2DP_CHECK_ERR_ALLOCATION_METHOD, A2DP_CHECK_ERR_BIT_POOL_RANGE, A2DP_CHECK_ERR_SUB_BANDS, @@ -227,8 +227,8 @@ enum a2dp_check_err { A2DP_CHECK_ERR_MPEG_LAYER, A2DP_CHECK_ERR_OBJECT_TYPE, A2DP_CHECK_ERR_DIRECTIONS, - A2DP_CHECK_ERR_SAMPLING_VOICE, - A2DP_CHECK_ERR_SAMPLING_MUSIC, + A2DP_CHECK_ERR_RATE_VOICE, + A2DP_CHECK_ERR_RATE_MUSIC, A2DP_CHECK_ERR_FRAME_DURATION, }; diff --git a/src/asound/bluealsa-pcm.c b/src/asound/bluealsa-pcm.c index dbf93de32..2ad702883 100644 --- a/src/asound/bluealsa-pcm.c +++ b/src/asound/bluealsa-pcm.c @@ -572,18 +572,18 @@ static int bluealsa_hw_params(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params) if ((ret = snd_pcm_hw_params_get_channels(params, &channels)) < 0) return ret; - unsigned int sampling; - if ((ret = snd_pcm_hw_params_get_rate(params, &sampling, NULL)) < 0) + unsigned int rate; + if ((ret = snd_pcm_hw_params_get_rate(params, &rate, NULL)) < 0) return ret; - if (pcm->ba_pcm.channels != channels || pcm->ba_pcm.sampling != sampling) { + if (pcm->ba_pcm.channels != channels || pcm->ba_pcm.rate != rate) { debug2("Changing BlueALSA PCM configuration: %u ch, %u Hz -> %u ch, %u Hz", - pcm->ba_pcm.channels, pcm->ba_pcm.sampling, channels, sampling); + pcm->ba_pcm.channels, pcm->ba_pcm.rate, channels, rate); const char *codec_name = pcm->ba_pcm.codec.name; if (!ba_dbus_pcm_select_codec(&pcm->dbus_ctx, pcm->ba_pcm.pcm_path, codec_name, pcm->ba_pcm_codec_config, pcm->ba_pcm_codec_config_len, - channels, sampling, BA_PCM_SELECT_CODEC_FLAG_NONE, &err)) { + channels, rate, BA_PCM_SELECT_CODEC_FLAG_NONE, &err)) { SNDERR("Couldn't change BlueALSA PCM configuration: %s", err.message); return -dbus_error_to_errno(&err); } @@ -593,7 +593,7 @@ static int bluealsa_hw_params(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params) * speed up the process. */ pcm->ba_pcm.channels = channels; - pcm->ba_pcm.sampling = sampling; + pcm->ba_pcm.rate = rate; for (size_t i = 0; i < pcm->ba_pcm_codecs.codecs_len; i++) { const struct ba_pcm_codec *codec = &pcm->ba_pcm_codecs.codecs[i]; @@ -1408,20 +1408,20 @@ static int bluealsa_set_hw_constraint(struct bluealsa_pcm *pcm) { /* In order to prevent audio tearing and minimize CPU utilization, we're * going to setup period size constraint. The limit is derived from the - * transport sampling rate and the number of channels, so the period + * transport sample rate and the number of channels, so the period * "time" size will be constant, and should be about 10ms. The upper * limit will not be constrained. */ - unsigned int min_p = pcm->ba_pcm.sampling / 100 * pcm->ba_pcm.channels * + unsigned int min_p = pcm->ba_pcm.rate / 100 * pcm->ba_pcm.channels * snd_pcm_format_physical_width(get_snd_pcm_format(pcm->ba_pcm.format)) / 8; if ((err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_PERIOD_BYTES, min_p, 1024 * 1024)) < 0) return err; - unsigned int list[ARRAYSIZE(codec->sampling)]; + unsigned int list[ARRAYSIZE(codec->rates)]; unsigned int n; - /* Populate the list of supported channels and sampling rates. For codecs + /* Populate the list of supported channels and sample rates. For codecs * with fixed configuration, the list will contain only one element. For * other codecs, the list might contain all supported configurations. */ @@ -1432,8 +1432,8 @@ static int bluealsa_set_hw_constraint(struct bluealsa_pcm *pcm) { return err; n = 0; - for (size_t i = 0; i < ARRAYSIZE(codec->sampling) && codec->sampling[i] != 0; i++) - list[n++] = codec->sampling[i]; + for (size_t i = 0; i < ARRAYSIZE(codec->rates) && codec->rates[i] != 0; i++) + list[n++] = codec->rates[i]; if ((err = snd_pcm_ioplug_set_param_list(io, SND_PCM_IOPLUG_HW_RATE, n, list)) < 0) return err; @@ -1650,7 +1650,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluealsa) { if (codec_name[0] != '\0') { /* If the codec was given, change it now, so we can get the correct - * sampling rate and channels for HW constraints. */ + * sample rate and channels for HW constraints. */ const char *canonical = ba_dbus_pcm_codec_get_canonical_name(codec_name); const bool name_changed = strcmp(canonical, pcm->ba_pcm.codec.name) != 0; if (name_changed && !ba_dbus_pcm_select_codec(&pcm->dbus_ctx, pcm->ba_pcm.pcm_path, @@ -1663,7 +1663,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluealsa) { memcpy(pcm->ba_pcm_codec_config, codec_config, codec_config_len); pcm->ba_pcm_codec_config_len = codec_config_len; - /* Changing the codec may change the audio format, sampling rate and/or + /* Changing the codec may change the audio format, sample rate and/or * channels. We need to refresh our cache of PCM properties. */ if (name_changed && !ba_dbus_pcm_get(&pcm->dbus_ctx, &ba_addr, ba_profile, stream == SND_PCM_STREAM_PLAYBACK ? BA_PCM_MODE_SINK : BA_PCM_MODE_SOURCE, @@ -1676,9 +1676,9 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluealsa) { } } - /* If the BT transport codec is not known (which means that PCM sampling + /* If the BT transport codec is not known (which means that PCM sample * rate is also not know), we cannot construct useful constraints. */ - if (pcm->ba_pcm.sampling == 0) { + if (pcm->ba_pcm.rate == 0) { ret = -EAGAIN; goto fail; } diff --git a/src/ba-config.h b/src/ba-config.h index 2c8c84ae3..0fa695fca 100644 --- a/src/ba-config.h +++ b/src/ba-config.h @@ -116,7 +116,7 @@ struct ba_config { * sink and semi-mandatory for source. So, if one wants only the bare * minimum, it would be possible - e.g. due to bandwidth limitations. */ bool force_mono; - /* The sampling rates of 44.1 kHz (aka Audio CD) and 48 kHz are mandatory + /* The sample rates of 44.1 kHz (aka Audio CD) and 48 kHz are mandatory * for sink endpoint and semi-mandatory for source. It is then possible * to force lower sampling in order to save Bluetooth bandwidth. */ bool force_44100; @@ -131,7 +131,7 @@ struct ba_config { #endif /* BlueALSA supports 5 SBC qualities: low, medium, high, XQ and XQ+. The XQ - * mode uses 44.1 kHz sampling rate, dual channel mode with bitpool 38, 16 + * mode uses 44.1 kHz sample rate, dual channel mode with bitpool 38, 16 * blocks in frame, 8 frequency bands and allocation method Loudness, which * is also known as SBC XQ Dual Channel HD. The "+" version uses bitpool 47 * instead of 38. */ diff --git a/src/ba-rfcomm.c b/src/ba-rfcomm.c index 8ec2cb213..8313f75ce 100644 --- a/src/ba-rfcomm.c +++ b/src/ba-rfcomm.c @@ -1318,9 +1318,9 @@ static void *rfcomm_thread(struct ba_rfcomm *r) { * notify BlueALSA D-Bus clients about the change. */ if (ba_transport_get_codec(t_sco) != HFP_CODEC_UNDEFINED) { bluealsa_dbus_pcm_update(&t_sco->sco.pcm_spk, - BA_DBUS_PCM_UPDATE_SAMPLING | BA_DBUS_PCM_UPDATE_CODEC); + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC); bluealsa_dbus_pcm_update(&t_sco->sco.pcm_mic, - BA_DBUS_PCM_UPDATE_SAMPLING | BA_DBUS_PCM_UPDATE_CODEC); + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC); } } @@ -1343,9 +1343,9 @@ static void *rfcomm_thread(struct ba_rfcomm *r) { * notify BlueALSA D-Bus clients about the change. */ if (ba_transport_get_codec(t_sco) != HFP_CODEC_UNDEFINED) { bluealsa_dbus_pcm_update(&t_sco->sco.pcm_spk, - BA_DBUS_PCM_UPDATE_SAMPLING | BA_DBUS_PCM_UPDATE_CODEC); + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC); bluealsa_dbus_pcm_update(&t_sco->sco.pcm_mic, - BA_DBUS_PCM_UPDATE_SAMPLING | BA_DBUS_PCM_UPDATE_CODEC); + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC); } } diff --git a/src/ba-transport-pcm.h b/src/ba-transport-pcm.h index e2b013945..40d7a0c2d 100644 --- a/src/ba-transport-pcm.h +++ b/src/ba-transport-pcm.h @@ -119,8 +119,8 @@ struct ba_transport_pcm { uint16_t format; /* number of audio channels */ unsigned int channels; - /* PCM sampling frequency */ - unsigned int sampling; + /* PCM sample rate */ + unsigned int rate; /* Overall PCM delay in 1/10 of millisecond, caused by * audio encoding or decoding and data transfer. */ diff --git a/src/bluealsa-dbus.c b/src/bluealsa-dbus.c index b72ffb8e0..14f8a5bef 100644 --- a/src/bluealsa-dbus.c +++ b/src/bluealsa-dbus.c @@ -256,8 +256,8 @@ static GVariant *ba_variant_new_pcm_channel_map(const struct ba_transport_pcm *p return g_variant_new_strv(strv, n); } -static GVariant *ba_variant_new_pcm_sampling(const struct ba_transport_pcm *pcm) { - return g_variant_new_uint32(pcm->sampling); +static GVariant *ba_variant_new_pcm_rate(const struct ba_transport_pcm *pcm) { + return g_variant_new_uint32(pcm->rate); } static GVariant *ba_variant_new_pcm_codec(const struct ba_transport_pcm *pcm) { @@ -325,7 +325,7 @@ static int ba_populate_channels(struct a2dp_bit_mapping mapping, void *userdata) return 0; } -static int ba_populate_sampling(struct a2dp_bit_mapping mapping, void *userdata) { +static int ba_populate_rates(struct a2dp_bit_mapping mapping, void *userdata) { struct ba_populate_data *data = userdata; g_variant_builder_add_value(data->builder, g_variant_new_uint32(mapping.value)); return 0; @@ -364,18 +364,18 @@ static void ba_variant_populate_remote_sep(GVariantBuilder *props, data.value = 0; g_variant_builder_init(&builder, G_VARIANT_TYPE("ay")); sep->caps_helpers->foreach_channel_mode(&caps, stream, ba_populate_channels, &data); - g_variant_builder_add(props, "{sv}", "SupportedChannels", g_variant_builder_end(&builder)); - - data.value = 0; - g_variant_builder_init(&builder, G_VARIANT_TYPE("au")); - sep->caps_helpers->foreach_sampling_freq(&caps, stream, ba_populate_sampling, &data); - g_variant_builder_add(props, "{sv}", "SupportedSampling", g_variant_builder_end(&builder)); + g_variant_builder_add(props, "{sv}", "Channels", g_variant_builder_end(&builder)); data.value = 0; g_variant_builder_init(&builder, G_VARIANT_TYPE("aas")); sep->caps_helpers->foreach_channel_mode(&caps, stream, ba_populate_channel_map, &data); g_variant_builder_add(props, "{sv}", "ChannelMaps", g_variant_builder_end(&builder)); + data.value = 0; + g_variant_builder_init(&builder, G_VARIANT_TYPE("au")); + sep->caps_helpers->foreach_sample_rate(&caps, stream, ba_populate_rates, &data); + g_variant_builder_add(props, "{sv}", "Rates", g_variant_builder_end(&builder)); + } static GVariant *bluealsa_manager_get_property(const char *property, @@ -662,7 +662,7 @@ static void bluealsa_pcm_get_codecs(GDBusMethodInvocation *inv, void *userdata) const struct { uint8_t codec_id; - unsigned int sampling; + unsigned int rate; bool is_enabled_in_config; bool is_available_in_rfcomm_ag; bool is_available_in_rfcomm_hf; @@ -691,11 +691,11 @@ static void bluealsa_pcm_get_codecs(GDBusMethodInvocation *inv, void *userdata) g_variant_builder_init(&props, G_VARIANT_TYPE("a{sv}")); const uint8_t channels[] = { 1 }; - g_variant_builder_add(&props, "{sv}", "SupportedChannels", g_variant_new_fixed_array( + g_variant_builder_add(&props, "{sv}", "Channels", g_variant_new_fixed_array( G_VARIANT_TYPE_BYTE, channels, 1, sizeof(*channels))); - const uint32_t sampling[] = { sco_codecs[i].sampling }; - g_variant_builder_add(&props, "{sv}", "SupportedSampling", g_variant_new_fixed_array( - G_VARIANT_TYPE_UINT32, sampling, 1, sizeof(*sampling))); + const uint32_t rates[] = { sco_codecs[i].rate }; + g_variant_builder_add(&props, "{sv}", "Rates", g_variant_new_fixed_array( + G_VARIANT_TYPE_UINT32, rates, 1, sizeof(*rates))); g_variant_builder_add(&codecs, "{sa{sv}}", hfp_codec_id_to_string(sco_codecs[i].codec_id), &props); @@ -730,7 +730,7 @@ static void bluealsa_pcm_select_codec(GDBusMethodInvocation *inv, void *userdata a2dp_t a2dp_configuration = {}; size_t a2dp_configuration_size = 0; unsigned int channels = 0; - unsigned int sampling = 0; + unsigned int rate = 0; bool conformance_check = true; g_variant_get(params, "(&sa{sv})", &codec_name, &properties); @@ -755,9 +755,9 @@ static void bluealsa_pcm_select_codec(GDBusMethodInvocation *inv, void *userdata g_variant_validate_value(value, G_VARIANT_TYPE_BYTE, property)) { channels = g_variant_get_byte(value); } - else if (strcmp(property, "Sampling") == 0 && + else if (strcmp(property, "Rate") == 0 && g_variant_validate_value(value, G_VARIANT_TYPE_UINT32, property)) { - sampling = g_variant_get_uint32(value); + rate = g_variant_get_uint32(value); } else if (strcmp(property, "NonConformant") == 0 && g_variant_validate_value(value, G_VARIANT_TYPE_BOOLEAN, property)) { @@ -819,8 +819,8 @@ static void bluealsa_pcm_select_codec(GDBusMethodInvocation *inv, void *userdata if (channels != 0) sep->caps_helpers->select_channel_mode(&a2dp_configuration, pcm_sep_stream, channels); - if (sampling != 0) - sep->caps_helpers->select_sampling_freq(&a2dp_configuration, pcm_sep_stream, sampling); + if (rate != 0) + sep->caps_helpers->select_sample_rate(&a2dp_configuration, pcm_sep_stream, rate); if (a2dp_configuration_size == 0) { /* Setup default configuration if it was not provided. */ @@ -988,8 +988,8 @@ static GVariant *bluealsa_pcm_get_property(const char *property, return ba_variant_new_pcm_channels(pcm); if (strcmp(property, "ChannelMap") == 0) return ba_variant_new_pcm_channel_map(pcm); - if (strcmp(property, "Sampling") == 0) - return ba_variant_new_pcm_sampling(pcm); + if (strcmp(property, "Rate") == 0) + return ba_variant_new_pcm_rate(pcm); if (strcmp(property, "Codec") == 0) { if ((value = ba_variant_new_pcm_codec(pcm)) == NULL) goto unavailable; @@ -1153,8 +1153,8 @@ void bluealsa_dbus_pcm_update(struct ba_transport_pcm *pcm, unsigned int mask) { g_variant_builder_add(&props, "{sv}", "Channels", ba_variant_new_pcm_channels(pcm)); if (mask & BA_DBUS_PCM_UPDATE_CHANNEL_MAP) g_variant_builder_add(&props, "{sv}", "ChannelMap", ba_variant_new_pcm_channel_map(pcm)); - if (mask & BA_DBUS_PCM_UPDATE_SAMPLING) - g_variant_builder_add(&props, "{sv}", "Sampling", ba_variant_new_pcm_sampling(pcm)); + if (mask & BA_DBUS_PCM_UPDATE_RATE) + g_variant_builder_add(&props, "{sv}", "Rate", ba_variant_new_pcm_rate(pcm)); if (mask & BA_DBUS_PCM_UPDATE_CODEC) g_variant_builder_add(&props, "{sv}", "Codec", ba_variant_new_pcm_codec(pcm)); if (mask & BA_DBUS_PCM_UPDATE_CODEC_CONFIG) diff --git a/src/bluealsa-dbus.h b/src/bluealsa-dbus.h index d81cc0f9d..c8edfee3c 100644 --- a/src/bluealsa-dbus.h +++ b/src/bluealsa-dbus.h @@ -25,7 +25,7 @@ #define BA_DBUS_PCM_UPDATE_FORMAT (1 << 0) #define BA_DBUS_PCM_UPDATE_CHANNELS (1 << 1) #define BA_DBUS_PCM_UPDATE_CHANNEL_MAP (1 << 2) -#define BA_DBUS_PCM_UPDATE_SAMPLING (1 << 3) +#define BA_DBUS_PCM_UPDATE_RATE (1 << 3) #define BA_DBUS_PCM_UPDATE_CODEC (1 << 4) #define BA_DBUS_PCM_UPDATE_CODEC_CONFIG (1 << 5) #define BA_DBUS_PCM_UPDATE_DELAY (1 << 6) diff --git a/src/bluealsa-iface.xml b/src/bluealsa-iface.xml index 5f29da915..1c14356c9 100644 --- a/src/bluealsa-iface.xml +++ b/src/bluealsa-iface.xml @@ -38,7 +38,7 @@ - + diff --git a/src/bluealsactl/cmd-codec.c b/src/bluealsactl/cmd-codec.c index eb389dc1e..159d02ce4 100644 --- a/src/bluealsactl/cmd-codec.c +++ b/src/bluealsactl/cmd-codec.c @@ -28,7 +28,7 @@ static void usage(const char *command) { printf("\nOptions:\n" " -h, --help\t\tShow this message and exit\n" " -c, --channels=NUM\tSelect configuration with NUM channels\n" - " -s, --sampling=NUM\tSelect configuration with NUM sampling frequency\n" + " -r, --rate=NUM\tSelect configuration with NUM sample rate\n" " -f, --force\t\tForce codec configuration (skip conformance check)\n" "\nPositional arguments:\n" " PCM-PATH\tBlueALSA PCM D-Bus object path\n" @@ -42,19 +42,19 @@ static void usage(const char *command) { static int cmd_codec_func(int argc, char *argv[]) { int opt; - const char *opts = "hqvc:s:f"; + const char *opts = "hqvc:r:f"; const struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "quiet", no_argument, NULL, 'q' }, { "verbose", no_argument, NULL, 'v' }, { "channels", required_argument, NULL, 'c' }, - { "sampling", required_argument, NULL, 's' }, + { "rate", required_argument, NULL, 'r' }, { "force", no_argument, NULL, 'f' }, { 0 }, }; unsigned int channels = 0; - unsigned int sampling = 0; + unsigned int rate = 0; bool force = false; opterr = 0; @@ -68,8 +68,8 @@ static int cmd_codec_func(int argc, char *argv[]) { case 'c' /* --channels */ : channels = atoi(optarg); break; - case 's' /* --sampling */ : - sampling = atoi(optarg); + case 'r' /* --rate */ : + rate = atoi(optarg); break; case 'f' /* --force */ : force = true; @@ -132,7 +132,7 @@ static int cmd_codec_func(int argc, char *argv[]) { flags |= BA_PCM_SELECT_CODEC_FLAG_NON_CONFORMANT; if (!ba_dbus_pcm_select_codec(&config.dbus, path, ba_dbus_pcm_codec_get_canonical_name(codec), - codec_config, codec_config_len, channels, sampling, flags, &err)) + codec_config, codec_config_len, channels, rate, flags, &err)) goto fail; result = EXIT_SUCCESS; diff --git a/src/bluealsactl/main.c b/src/bluealsactl/main.c index 67943af02..8552311a3 100644 --- a/src/bluealsactl/main.c +++ b/src/bluealsactl/main.c @@ -113,9 +113,9 @@ static void print_pcm_codec(const struct ba_pcm_codec *codec) { printf(" %u", codec->channels[i]); printf("]"); - printf(" [sampling:"); - for (size_t i = 0; i < ARRAYSIZE(codec->sampling) && codec->sampling[i] != 0; i++) - printf(" %u", codec->sampling[i]); + printf(" [rate:"); + for (size_t i = 0; i < ARRAYSIZE(codec->rates) && codec->rates[i] != 0; i++) + printf(" %u", codec->rates[i]); printf("]"); } @@ -310,13 +310,13 @@ void bactl_print_pcm_properties(const struct ba_pcm *pcm, DBusError *err) { printf("Running: %s\n", pcm->running ? "true" : "false"); printf("Format: %s\n", pcm_format_to_string(pcm->format)); printf("Channels: %d\n", pcm->channels); - printf("Sampling: %d Hz\n", pcm->sampling); + bactl_print_pcm_channel_map(pcm); + printf("Rate: %d Hz\n", pcm->rate); bactl_print_pcm_available_codecs(pcm, err); bactl_print_pcm_selected_codec(pcm); printf("Delay: %#.1f ms\n", (double)pcm->delay / 10); printf("DelayAdjustment: %#.1f ms\n", (double)pcm->delay_adjustment / 10); bactl_print_pcm_soft_volume(pcm); - bactl_print_pcm_channel_map(pcm); bactl_print_pcm_volume(pcm); bactl_print_pcm_mute(pcm); } diff --git a/src/bluez.c b/src/bluez.c index fefc0e9d6..e82fd4df5 100644 --- a/src/bluez.c +++ b/src/bluez.c @@ -574,8 +574,8 @@ static void bluez_endpoint_set_configuration(GDBusMethodInvocation *inv, void *u batostr_(&d->addr)); hexdump("A2DP selected configuration blob", &configuration, sep->config.caps_size); - debug("PCM configuration: channels: %u, sampling: %u", - t->a2dp.pcm.channels, t->a2dp.pcm.sampling); + debug("PCM configuration: channels=%u rate=%u", + t->a2dp.pcm.channels, t->a2dp.pcm.rate); ba_transport_set_a2dp_state(t, state); diff --git a/src/codec-lc3-swb.h b/src/codec-lc3-swb.h index 350518ac3..30da8732e 100644 --- a/src/codec-lc3-swb.h +++ b/src/codec-lc3-swb.h @@ -28,7 +28,7 @@ #include "shared/ffb.h" /* LC3-SWB uses LC3 encoding with precisely defined parameters: mono, 32 kHz - * sampling rate, 7.5 ms frame duration. Hence, the size of the input (number + * sample rate, 7.5 ms frame duration. Hence, the size of the input (number * of PCM samples) and output is known up front. */ #define LC3_SWB_CODESIZE 240 * sizeof(int16_t) #define LC3_SWB_CODESAMPLES (LC3_SWB_CODESIZE / sizeof(int16_t)) diff --git a/src/codec-msbc.c b/src/codec-msbc.c index cfb9785de..88ac3a098 100644 --- a/src/codec-msbc.c +++ b/src/codec-msbc.c @@ -31,7 +31,7 @@ * If defined to 1, in case of SBC frame decoding error the msbc_decode() * function will not return error code, but will use PLC to conceal missing * PCM samples. Such behavior should ensure that a PCM client will receive - * correct number of PCM samples - matching sampling frequency. */ + * correct number of PCM samples - matching sample rate. */ #define MSBC_DECODE_ERROR_PLC 1 /** diff --git a/src/codec-sbc.c b/src/codec-sbc.c index 360cb2b15..7ef0c6de0 100644 --- a/src/codec-sbc.c +++ b/src/codec-sbc.c @@ -265,18 +265,18 @@ void sbc_print_internals(const sbc_t *sbc) { [SBC_AM_LOUDNESS] = "Loudness", [SBC_AM_SNR] = "SNR", }; - static const unsigned int frequency[] = { + static const unsigned int rate[] = { [SBC_SAMPLING_FREQ_16000] = 16000, [SBC_SAMPLING_FREQ_32000] = 32000, [SBC_SAMPLING_FREQ_44100] = 44100, [SBC_SAMPLING_FREQ_48000] = 48000, }; - const unsigned int br = 8 * sbc_get_frame_length((sbc_t *)sbc) * frequency[sbc->frequency] / + const unsigned int br = 8 * sbc_get_frame_length((sbc_t *)sbc) * rate[sbc->frequency] / ((sbc->subbands + 1) * 4) / ((sbc->blocks + 1) * 4); debug("SBC setup: %u Hz %s allocation=%s blocks=%u sub-bands=%u bit-pool=%u => %u bps", - frequency[sbc->frequency], + rate[sbc->frequency], mode[sbc->mode], allocation[sbc->allocation], (sbc->blocks + 1) * 4, diff --git a/src/io.c b/src/io.c index 55b6032a8..2bbcfc7c8 100644 --- a/src/io.c +++ b/src/io.c @@ -384,7 +384,7 @@ ssize_t io_poll_and_read_pcm( * In order to correctly calculate time drift, the zero time point has to * be obtained after the stream has started. */ if (io->asrs.frames == 0) - asrsync_init(&io->asrs, pcm->sampling); + asrsync_init(&io->asrs, pcm->rate); ffb_seek(buffer, samples); return samples; diff --git a/src/sco.c b/src/sco.c index bb94008d5..532985940 100644 --- a/src/sco.c +++ b/src/sco.c @@ -269,23 +269,23 @@ void sco_transport_init(struct ba_transport *t) { uint32_t codec_id; switch (codec_id = ba_transport_get_codec(t)) { case HFP_CODEC_UNDEFINED: - t->sco.pcm_spk.sampling = 0; - t->sco.pcm_mic.sampling = 0; + t->sco.pcm_spk.rate = 0; + t->sco.pcm_mic.rate = 0; break; case HFP_CODEC_CVSD: - t->sco.pcm_spk.sampling = 8000; - t->sco.pcm_mic.sampling = 8000; + t->sco.pcm_spk.rate = 8000; + t->sco.pcm_mic.rate = 8000; break; #if ENABLE_MSBC case HFP_CODEC_MSBC: - t->sco.pcm_spk.sampling = 16000; - t->sco.pcm_mic.sampling = 16000; + t->sco.pcm_spk.rate = 16000; + t->sco.pcm_mic.rate = 16000; break; #endif #if ENABLE_LC3_SWB case HFP_CODEC_LC3_SWB: - t->sco.pcm_spk.sampling = 32000; - t->sco.pcm_mic.sampling = 32000; + t->sco.pcm_spk.rate = 32000; + t->sco.pcm_mic.rate = 32000; break; #endif default: @@ -295,13 +295,13 @@ void sco_transport_init(struct ba_transport *t) { if (t->sco.pcm_spk.ba_dbus_exported) bluealsa_dbus_pcm_update(&t->sco.pcm_spk, - BA_DBUS_PCM_UPDATE_SAMPLING | + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC | BA_DBUS_PCM_UPDATE_DELAY_ADJUSTMENT); if (t->sco.pcm_mic.ba_dbus_exported) bluealsa_dbus_pcm_update(&t->sco.pcm_mic, - BA_DBUS_PCM_UPDATE_SAMPLING | + BA_DBUS_PCM_UPDATE_RATE | BA_DBUS_PCM_UPDATE_CODEC | BA_DBUS_PCM_UPDATE_DELAY_ADJUSTMENT); diff --git a/src/shared/dbus-client-pcm.c b/src/shared/dbus-client-pcm.c index 7705959de..4728c2235 100644 --- a/src/shared/dbus-client-pcm.c +++ b/src/shared/dbus-client-pcm.c @@ -229,7 +229,7 @@ static void dbus_message_iter_get_codec_data(DBusMessageIter *variant, } -static void dbus_message_iter_get_codec_supported_channels(DBusMessageIter *variant, +static void dbus_message_iter_get_codec_channels(DBusMessageIter *variant, struct ba_pcm_codec *codec) { DBusMessageIter iter; @@ -245,7 +245,7 @@ static void dbus_message_iter_get_codec_supported_channels(DBusMessageIter *vari } -static void dbus_message_iter_get_codec_supported_sampling(DBusMessageIter *variant, +static void dbus_message_iter_get_codec_rates(DBusMessageIter *variant, struct ba_pcm_codec *codec) { DBusMessageIter iter; @@ -255,9 +255,9 @@ static void dbus_message_iter_get_codec_supported_sampling(DBusMessageIter *vari dbus_message_iter_recurse(variant, &iter); dbus_message_iter_get_fixed_array(&iter, &data, &len); - len = MIN(len, ARRAYSIZE(codec->sampling)); + len = MIN(len, ARRAYSIZE(codec->rates)); for (size_t i = 0; i < (size_t)len; i++) - codec->sampling[i] = data[i]; + codec->rates[i] = data[i]; } @@ -307,20 +307,20 @@ static dbus_bool_t ba_dbus_message_iter_pcm_codec_get_props_cb(const char *key, goto fail; dbus_message_iter_get_codec_data(&variant, codec); } - else if (strcmp(key, "SupportedChannels") == 0) { + else if (strcmp(key, "Channels") == 0) { if (type != (type_expected = DBUS_TYPE_ARRAY)) goto fail; - dbus_message_iter_get_codec_supported_channels(&variant, codec); + dbus_message_iter_get_codec_channels(&variant, codec); } - else if (strcmp(key, "SupportedSampling") == 0) { + else if (strcmp(key, "ChannelMaps") == 0) { if (type != (type_expected = DBUS_TYPE_ARRAY)) goto fail; - dbus_message_iter_get_codec_supported_sampling(&variant, codec); + dbus_message_iter_get_codec_channel_maps(&variant, codec); } - else if (strcmp(key, "ChannelMaps") == 0) { + else if (strcmp(key, "Rates") == 0) { if (type != (type_expected = DBUS_TYPE_ARRAY)) goto fail; - dbus_message_iter_get_codec_channel_maps(&variant, codec); + dbus_message_iter_get_codec_rates(&variant, codec); } return TRUE; @@ -423,7 +423,7 @@ dbus_bool_t ba_dbus_pcm_select_codec( const void *configuration, size_t configuration_len, unsigned int channels, - unsigned int sampling, + unsigned int rate, unsigned int flags, DBusError *error) { @@ -473,9 +473,9 @@ dbus_bool_t ba_dbus_pcm_select_codec( } } - if (sampling != 0) { - const uint32_t value = sampling; - if (!dbus_message_iter_dict_append_basic(&props, "Sampling", DBUS_TYPE_UINT32, &value)) { + if (rate != 0) { + const uint32_t value = rate; + if (!dbus_message_iter_dict_append_basic(&props, "Rate", DBUS_TYPE_UINT32, &value)) { dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, NULL); goto fail; } @@ -811,11 +811,11 @@ static dbus_bool_t dbus_message_iter_get_ba_pcm_props_cb(const char *key, strncpy(pcm->channel_map[i], data[i], sizeof(pcm->channel_map[i]) - 1); } - else if (strcmp(key, "Sampling") == 0) { + else if (strcmp(key, "Rate") == 0) { if (type != (type_expected = DBUS_TYPE_UINT32)) goto fail; - dbus_message_iter_get_basic(&variant, &pcm->sampling); - pcm->codec.sampling[0] = pcm->sampling; + dbus_message_iter_get_basic(&variant, &pcm->rate); + pcm->codec.rates[0] = pcm->rate; } else if (strcmp(key, "Codec") == 0) { if (type != (type_expected = DBUS_TYPE_STRING)) diff --git a/src/shared/dbus-client-pcm.h b/src/shared/dbus-client-pcm.h index 2d11daedb..29007eaf0 100644 --- a/src/shared/dbus-client-pcm.h +++ b/src/shared/dbus-client-pcm.h @@ -87,10 +87,10 @@ struct ba_pcm_codec { size_t data_len; /* number of channels supported by the codec */ unsigned char channels[8]; - /* sampling frequencies supported by the codec */ - dbus_uint32_t sampling[16]; /* channel maps associated with supported number of channels */ char channel_maps[8][8][5]; + /* sample rates supported by the codec */ + dbus_uint32_t rates[16]; }; /** @@ -125,8 +125,8 @@ struct ba_pcm { unsigned char channels; /* channel map for selected codec */ char channel_map[8][5]; - /* PCM sampling frequency */ - dbus_uint32_t sampling; + /* PCM sample rate */ + dbus_uint32_t rate; /* device address */ bdaddr_t addr; @@ -200,7 +200,7 @@ dbus_bool_t ba_dbus_pcm_select_codec( const void *configuration, size_t configuration_len, unsigned int channels, - unsigned int sampling, + unsigned int rate, unsigned int flags, DBusError *error); diff --git a/src/shared/rt.c b/src/shared/rt.c index 05ec6fd23..5db47b4a2 100644 --- a/src/shared/rt.c +++ b/src/shared/rt.c @@ -14,7 +14,7 @@ #include /** - * Synchronize time with the sampling rate. + * Synchronize time with the sample rate. * * Notes: * 1. Time synchronization relies on the frame counter being linear. diff --git a/src/shared/rt.h b/src/shared/rt.h index 58b6b3455..1fc9db136 100644 --- a/src/shared/rt.h +++ b/src/shared/rt.h @@ -44,11 +44,11 @@ * Structure used for time synchronization. * * With the size of the frame counter being 32 bits, it is possible to track - * up to ~24 hours, with the sampling rate of 48 kHz. If it is insufficient, + * up to ~24 hours, with the sample rate of 48 kHz. If it is insufficient, * one can switch to 64 bits, which would suffice for 12 million years. */ struct asrsync { - /* used sampling rate */ + /* used sample rate */ unsigned int rate; /* reference time point */ struct timespec ts0; @@ -72,7 +72,7 @@ struct asrsync { * Start (initialize) time synchronization. * * @param asrs Pointer to the time synchronization structure. - * @param sr Synchronization sampling rate. */ + * @param sr Synchronization sample rate. */ #define asrsync_init(asrs, sr) do { \ (asrs)->rate = sr; \ gettimestamp(&(asrs)->ts0); \ diff --git a/test/inc/sine.inc b/test/inc/sine.inc index 52d1bb7e0..e38effc70 100644 --- a/test/inc/sine.inc +++ b/test/inc/sine.inc @@ -24,7 +24,7 @@ * @param frames The number of PCM frames to generate. * @param channels Number of channels per PCM frame. * @param x Sampling argument of the sine function. - * @param f Required sine frequency divided by the PCM sampling frequency. + * @param f Required sine frequency divided by the PCM sample rate. * @return Updated x parameter. One may use this value for a next call, in * order to generate smooth sine curve. */ int snd_pcm_sine_s16_2le(int16_t *buffer, size_t frames, diff --git a/test/integration/test-e2e-latency.py b/test/integration/test-e2e-latency.py index d44439fdb..141623b90 100755 --- a/test/integration/test-e2e-latency.py +++ b/test/integration/test-e2e-latency.py @@ -35,8 +35,8 @@ } -def samplerate_sync(t0: float, frames: int, sampling: int): - delta = frames / sampling - time.monotonic() + t0 +def rate_sync(t0: float, frames: int, rate: int): + delta = frames / rate - time.monotonic() + t0 if (delta > 0): print(f"Rate sync: {delta:.6f}") time.sleep(delta) @@ -44,11 +44,11 @@ def samplerate_sync(t0: float, frames: int, sampling: int): print(f"Rate sync overdue: {-delta:.6f}") -def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): +def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_rate, interval): """Write PCM test signal. This function generates test signal when real time modulo interval is zero - (within sampling rate resolution capabilities). Providing that both devices + (within sample rate resolution capabilities). Providing that both devices are in sync with NTP, this should be a reliable way to detect end-to-end latency. """ @@ -58,7 +58,7 @@ def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): struct = Struct(fmt[0] + fmt[1] * pcm_channels) # Time quantum in seconds - t_quantum = 1.0 / pcm_sampling + t_quantum = 1.0 / pcm_rate # Noise PCM value range v_noise_min = int(LIMITS[pcm_format][0] * 0.05) @@ -68,7 +68,7 @@ def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): v_signal_min = int(LIMITS[pcm_format][1] * 0.8) v_signal_max = int(LIMITS[pcm_format][1] * 1.0) - signal_frames = int(0.1 * pcm_sampling) + signal_frames = int(0.1 * pcm_rate) print(f"Signal frames: {signal_frames}") frames = 0 @@ -82,7 +82,7 @@ def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): print(f"Next signal at: {t:.6f} + {t_delta:.6f} -> {t + t_delta:.6f}") # Write random data to keep encoder busy - noise_frames = int(t_delta * pcm_sampling) + noise_frames = int(t_delta * pcm_rate) print(f"Noise frames: {noise_frames}") pcm.writelines( struct.pack(*[randint(v_noise_min, v_noise_max)] * pcm_channels) @@ -90,7 +90,7 @@ def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): pcm.flush() frames += noise_frames - samplerate_sync(t0, frames, pcm_sampling) + rate_sync(t0, frames, pcm_rate) # Write signal data pcm.writelines( @@ -99,10 +99,10 @@ def test_pcm_write(pcm, pcm_format, pcm_channels, pcm_sampling, interval): pcm.flush() frames += signal_frames - samplerate_sync(t0, frames, pcm_sampling) + rate_sync(t0, frames, pcm_rate) -def test_pcm_read(pcm, pcm_format, pcm_channels, pcm_sampling, interval): +def test_pcm_read(pcm, pcm_format, pcm_channels, pcm_rate, interval): """Read PCM test signal.""" fmt = FORMATS[pcm_format] @@ -161,10 +161,10 @@ def test_pcm_read(pcm, pcm_format, pcm_channels, pcm_sampling, interval): for key, value in (line.split(':', 1) for line in output.splitlines())} channels = int(info['channels']) -sampling = int(info['sampling'].split()[0]) +rate = int(info['rate'].split()[0]) print(f"Bluetooth: {info['transport']} {info['selected codec']}") -print(f"PCM: {info['format']} {channels} channels {sampling} Hz") +print(f"PCM: {info['format']} {channels} channels {rate} Hz") print("==========") cmd = ['bluealsactl', *options, 'open', args.PCM_PATH] @@ -174,9 +174,7 @@ def test_pcm_read(pcm, pcm_format, pcm_channels, pcm_sampling, interval): time.sleep(1) if info['mode'] == 'sink': - test_pcm_write(client.stdin, info['format'], channels, sampling, - args.interval) + test_pcm_write(client.stdin, info['format'], channels, rate, args.interval) if info['mode'] == 'source': - test_pcm_read(client.stdout, info['format'], channels, sampling, - args.interval) + test_pcm_read(client.stdout, info['format'], channels, rate, args.interval) diff --git a/test/mock/mock-bluealsa.c b/test/mock/mock-bluealsa.c index f9b377b14..62058a328 100644 --- a/test/mock/mock-bluealsa.c +++ b/test/mock/mock-bluealsa.c @@ -102,7 +102,7 @@ static void *mock_dec(struct ba_transport_pcm *t_pcm) { pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm); const unsigned int channels = t_pcm->channels; - const unsigned int samplerate = t_pcm->sampling; + const unsigned int rate = t_pcm->rate; struct pollfd fds[1] = {{ t_pcm->pipe[0], POLLIN, 0 }}; struct asrsync asrs = { .frames = 0 }; int16_t buffer[1024 * 2]; @@ -134,11 +134,11 @@ static void *mock_dec(struct ba_transport_pcm *t_pcm) { fprintf(stderr, "."); if (asrs.frames == 0) - asrsync_init(&asrs, samplerate); + asrsync_init(&asrs, rate); const size_t samples = ARRAYSIZE(buffer); const size_t frames = samples / channels; - x = snd_pcm_sine_s16_2le(buffer, frames, channels, x, 146.83 / samplerate); + x = snd_pcm_sine_s16_2le(buffer, frames, channels, x, 146.83 / rate); io_pcm_scale(t_pcm, buffer, samples); if (io_pcm_write(t_pcm, buffer, samples) == -1) @@ -158,7 +158,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_p void *a2dp_aac_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } void *a2dp_aptx_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } -void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } +void *a2dp_fs_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } void *sco_dec_thread(struct ba_transport_pcm *t_pcm) { return mock_dec(t_pcm); } static struct ba_adapter *ba_adapter = NULL; diff --git a/test/test-a2dp.c b/test/test-a2dp.c index 9001201b9..c69f9828e 100644 --- a/test/test-a2dp.c +++ b/test/test-a2dp.c @@ -153,7 +153,7 @@ CK_START_TEST(test_a2dp_check_configuration) { }; ck_assert_int_eq(a2dp_check_configuration(&a2dp_sbc_source, - &cfg_invalid, sizeof(cfg_invalid)), A2DP_CHECK_ERR_SAMPLING); + &cfg_invalid, sizeof(cfg_invalid)), A2DP_CHECK_ERR_RATE); #if ENABLE_AAC a2dp_aac_t cfg_aac_invalid = { @@ -207,9 +207,9 @@ CK_START_TEST(test_a2dp_caps) { ck_assert_ptr_ne(sep->caps_helpers->intersect, NULL); ck_assert_ptr_ne(sep->caps_helpers->has_stream, NULL); ck_assert_ptr_ne(sep->caps_helpers->foreach_channel_mode, NULL); - ck_assert_ptr_ne(sep->caps_helpers->foreach_sampling_freq, NULL); + ck_assert_ptr_ne(sep->caps_helpers->foreach_sample_rate, NULL); ck_assert_ptr_ne(sep->caps_helpers->select_channel_mode, NULL); - ck_assert_ptr_ne(sep->caps_helpers->select_sampling_freq, NULL); + ck_assert_ptr_ne(sep->caps_helpers->select_sample_rate, NULL); /* Run smoke tests for all capability helpers. */ @@ -229,16 +229,16 @@ CK_START_TEST(test_a2dp_caps) { a2dp_bit_mapping_foreach_get_best_channel_mode, &channel_mode); unsigned int sampling_freq = 0; - sep->caps_helpers->foreach_sampling_freq(&caps, A2DP_MAIN, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq); - sep->caps_helpers->foreach_sampling_freq(&caps, A2DP_BACKCHANNEL, - a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq); + sep->caps_helpers->foreach_sample_rate(&caps, A2DP_MAIN, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq); + sep->caps_helpers->foreach_sample_rate(&caps, A2DP_BACKCHANNEL, + a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq); sep->caps_helpers->select_channel_mode(&caps, A2DP_MAIN, 2); sep->caps_helpers->select_channel_mode(&caps, A2DP_BACKCHANNEL, 1); - sep->caps_helpers->select_sampling_freq(&caps, A2DP_MAIN, 48000); - sep->caps_helpers->select_sampling_freq(&caps, A2DP_BACKCHANNEL, 16000); + sep->caps_helpers->select_sample_rate(&caps, A2DP_MAIN, 48000); + sep->caps_helpers->select_sample_rate(&caps, A2DP_BACKCHANNEL, 16000); } @@ -302,14 +302,14 @@ CK_START_TEST(test_a2dp_caps_foreach_get_best) { ck_assert_uint_eq(channel_mode, SBC_CHANNEL_MODE_STEREO); unsigned int sampling_freq = 0; - ck_assert_int_eq(a2dp_sbc_source.caps_helpers->foreach_sampling_freq(&caps_sbc, - A2DP_MAIN, a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq), 0); + ck_assert_int_eq(a2dp_sbc_source.caps_helpers->foreach_sample_rate(&caps_sbc, + A2DP_MAIN, a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq), 0); ck_assert_uint_eq(sampling_freq, SBC_SAMPLING_FREQ_44100); #if ENABLE_AAC /* Check default internal limits for selecting number of channels (up to - * 2 channels) and sampling frequency (up to 48 kHz). */ + * 2 channels) and sample rate (up to 48 kHz). */ a2dp_aac_t caps_aac = { A2DP_AAC_INIT_SAMPLING_FREQ(AAC_SAMPLING_FREQ_48000 | AAC_SAMPLING_FREQ_96000) @@ -322,8 +322,8 @@ CK_START_TEST(test_a2dp_caps_foreach_get_best) { ck_assert_uint_eq(channel_mode, AAC_CHANNEL_MODE_STEREO); sampling_freq = 0; - ck_assert_int_eq(a2dp_aac_source.caps_helpers->foreach_sampling_freq(&caps_aac, - A2DP_MAIN, a2dp_bit_mapping_foreach_get_best_sampling_freq, &sampling_freq), 1); + ck_assert_int_eq(a2dp_aac_source.caps_helpers->foreach_sample_rate(&caps_aac, + A2DP_MAIN, a2dp_bit_mapping_foreach_get_best_sample_rate, &sampling_freq), 1); ck_assert_uint_eq(sampling_freq, AAC_SAMPLING_FREQ_48000); #endif @@ -340,7 +340,7 @@ CK_START_TEST(test_a2dp_caps_select_channels_and_sampling) { a2dp_sbc_source.caps_helpers->select_channel_mode(&caps_sbc, A2DP_MAIN, 2); ck_assert_uint_eq(caps_sbc.channel_mode, SBC_CHANNEL_MODE_STEREO); - a2dp_sbc_source.caps_helpers->select_sampling_freq(&caps_sbc, A2DP_MAIN, 16000); + a2dp_sbc_source.caps_helpers->select_sample_rate(&caps_sbc, A2DP_MAIN, 16000); ck_assert_uint_eq(caps_sbc.sampling_freq, SBC_SAMPLING_FREQ_16000); } CK_END_TEST diff --git a/test/test-alsa-pcm.c b/test/test-alsa-pcm.c index 65836b601..c1dfeae5b 100644 --- a/test/test-alsa-pcm.c +++ b/test/test-alsa-pcm.c @@ -42,7 +42,7 @@ static const char *pcm_device = NULL; static unsigned int pcm_channels = 2; -static unsigned int pcm_sampling = 44100; +static unsigned int pcm_rate = 44100; static snd_pcm_format_t pcm_format = SND_PCM_FORMAT_S16_LE; /* big enough buffer to keep one period of data */ static int16_t pcm_buffer[1024 * 8]; @@ -158,7 +158,7 @@ static int test_pcm_close(struct spawn_process *sp_ba_mock, snd_pcm_t *pcm) { static int16_t *test_sine_s16le(snd_pcm_uframes_t size) { static size_t x = 0; assert(ARRAYSIZE(pcm_buffer) >= size * pcm_channels); - x = snd_pcm_sine_s16_2le(pcm_buffer, size, pcm_channels, x, 441.0 / pcm_sampling); + x = snd_pcm_sine_s16_2le(pcm_buffer, size, pcm_channels, x, 441.0 / pcm_rate); return pcm_buffer; } @@ -198,7 +198,7 @@ CK_START_TEST(test_capture_start) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_CAPTURE), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -246,7 +246,7 @@ CK_START_TEST(test_capture_drain) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_CAPTURE), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); ck_assert_int_eq(snd_pcm_start(pcm), 0); @@ -269,7 +269,7 @@ CK_START_TEST(test_capture_pause) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_CAPTURE), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -332,7 +332,7 @@ CK_START_TEST(test_capture_overrun) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_CAPTURE), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -373,7 +373,7 @@ CK_START_TEST(test_capture_poll) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_CAPTURE), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); struct pollfd pfds[8]; @@ -419,7 +419,7 @@ CK_START_TEST(dump_playback) { ck_assert_int_eq(snd_pcm_dump(pcm, output), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); snd_pcm_hw_params_t *params; @@ -539,7 +539,7 @@ CK_START_TEST(ba_test_playback_channel_maps) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); /* get all supported channel maps */ @@ -681,7 +681,7 @@ CK_START_TEST(test_playback_hw_set_free) { int set_hw_param_ret; /* acquire Bluetooth transport */ if ((set_hw_param_ret = set_hw_params(pcm, pcm_format, pcm_channels, - pcm_sampling, &buffer_time, &period_time)) == -EBUSY) { + pcm_rate, &buffer_time, &period_time)) == -EBUSY) { debug("Retrying snd_pcm_hw_params_set..."); /* do not treat busy as an error */ i--; @@ -708,7 +708,7 @@ CK_START_TEST(test_playback_start) { size_t i; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); /* setup PCM to be started by writing the last period of data */ @@ -748,7 +748,7 @@ CK_START_TEST(test_playback_drain) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -783,7 +783,7 @@ CK_START_TEST(test_playback_drain_not_started) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); /* setup PCM to be started by writing the last period of data */ @@ -816,7 +816,7 @@ CK_START_TEST(test_playback_drain_nonblock) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -868,7 +868,7 @@ CK_START_TEST(test_playback_pause) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -933,7 +933,7 @@ CK_START_TEST(test_playback_reset) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -986,7 +986,7 @@ CK_START_TEST(test_playback_underrun) { snd_pcm_t *pcm = NULL; ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_get_params(pcm, &buffer_size, &period_size), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -1054,7 +1054,7 @@ CK_START_TEST(reference_playback_device_unplug) { ck_assert_ptr_ne(pcm_device, NULL); ck_assert_int_eq(test_pcm_open(NULL, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -1096,7 +1096,7 @@ CK_START_TEST(ba_test_playback_device_unplug) { ck_assert_ptr_eq(pcm_device, NULL); ck_assert_int_eq(test_pcm_open(&sp_ba_mock, &pcm, SND_PCM_STREAM_PLAYBACK), 0); - ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_sampling, + ck_assert_int_eq(set_hw_params(pcm, pcm_format, pcm_channels, pcm_rate, &buffer_time, &period_time), 0); ck_assert_int_eq(snd_pcm_prepare(pcm), 0); @@ -1167,7 +1167,7 @@ int main(int argc, char *argv[]) { pcm_format = SND_PCM_FORMAT_U8; break; case 'r' /* --rate=NUM */ : - pcm_sampling = atoi(optarg); + pcm_rate = atoi(optarg); break; default: fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]); diff --git a/test/test-io.c b/test/test-io.c index 45bb69ff4..115ce6f35 100644 --- a/test/test-io.c +++ b/test/test-io.c @@ -106,8 +106,8 @@ void *a2dp_aptx_dec_thread(struct ba_transport_pcm *t_pcm); void *a2dp_aptx_enc_thread(struct ba_transport_pcm *t_pcm); void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm); void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm); -void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm); -void *a2dp_faststream_enc_thread(struct ba_transport_pcm *t_pcm); +void *a2dp_fs_dec_thread(struct ba_transport_pcm *t_pcm); +void *a2dp_fs_enc_thread(struct ba_transport_pcm *t_pcm); void *a2dp_lc3plus_dec_thread(struct ba_transport_pcm *t_pcm); void *a2dp_lc3plus_enc_thread(struct ba_transport_pcm *t_pcm); void *a2dp_ldac_dec_thread(struct ba_transport_pcm *t_pcm); @@ -499,7 +499,7 @@ static void *test_io_thread_dump_pcm(struct ba_transport_pcm *t_pcm) { SF_INFO sf_info = { .format = SF_FORMAT_WAV, .channels = t_pcm->channels, - .samplerate = t_pcm->sampling, + .samplerate = t_pcm->rate, }; switch (BA_TRANSPORT_PCM_FORMAT_WIDTH(t_pcm->format)) { case 8: @@ -1017,7 +1017,7 @@ CK_START_TEST(test_a2dp_aac) { CK_START_TEST(test_a2dp_aac_configuration_select) { static const unsigned int channels[] = { 1, 2, 6, 8 }; - static const unsigned int samplings[] = { + static const unsigned int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }; /* Probe AAC encoder for supported configurations. */ @@ -1027,19 +1027,19 @@ CK_START_TEST(test_a2dp_aac_configuration_select) { * allegedly supported configurations. */ for (size_t i = 0; i < ARRAYSIZE(channels); i++) - for (size_t j = 0; j < ARRAYSIZE(samplings); j++) { + for (size_t j = 0; j < ARRAYSIZE(rates); j++) { a2dp_aac_t config_aac; /* Initialize all bit-fields to 1. */ memset(&config_aac, 0xFF, sizeof(config_aac)); a2dp_aac_source.caps_helpers->select_channel_mode(&config_aac, A2DP_MAIN, channels[i]); - a2dp_aac_source.caps_helpers->select_sampling_freq(&config_aac, A2DP_MAIN, samplings[j]); + a2dp_aac_source.caps_helpers->select_sample_rate(&config_aac, A2DP_MAIN, rates[j]); /* Select the configuration based on the pre-selected capabilities. */ if (a2dp_aac_source.configuration_select(&a2dp_aac_source, &config_aac) != 0) { - debug("AAC unsupported configuration: channels=%u, sampling=%u", - channels[i], samplings[j]); + debug("AAC unsupported configuration: channels=%u, rate=%u", + channels[i], rates[j]); continue; } @@ -1138,12 +1138,12 @@ CK_START_TEST(test_a2dp_faststream_music) { if (aging_duration) { t1->mtu_read = t1->mtu_write = t2->mtu_read = t2->mtu_write = 72 * 3; - test_io(t1_pcm, t2_pcm, a2dp_faststream_enc_thread, a2dp_faststream_dec_thread, 4 * 1024); + test_io(t1_pcm, t2_pcm, a2dp_fs_enc_thread, a2dp_fs_dec_thread, 4 * 1024); } else { t1->mtu_read = t1->mtu_write = t2->mtu_read = t2->mtu_write = 72 * 3; - test_io(t1_pcm, t2_pcm, a2dp_faststream_enc_thread, test_io_thread_dump_bt, 2 * 1024); - test_io(t1_pcm, t2_pcm, test_io_thread_dump_pcm, a2dp_faststream_dec_thread, 2 * 1024); + test_io(t1_pcm, t2_pcm, a2dp_fs_enc_thread, test_io_thread_dump_bt, 2 * 1024); + test_io(t1_pcm, t2_pcm, test_io_thread_dump_pcm, a2dp_fs_dec_thread, 2 * 1024); } ba_transport_destroy(t1); @@ -1167,12 +1167,12 @@ CK_START_TEST(test_a2dp_faststream_voice) { if (aging_duration) { t1->mtu_read = t1->mtu_write = t2->mtu_read = t2->mtu_write = 72 * 3; - test_io(t2_pcm_bc, t1_pcm_bc, a2dp_faststream_enc_thread, a2dp_faststream_dec_thread, 4 * 1024); + test_io(t2_pcm_bc, t1_pcm_bc, a2dp_fs_enc_thread, a2dp_fs_dec_thread, 4 * 1024); } else { t1->mtu_read = t1->mtu_write = t2->mtu_read = t2->mtu_write = 72 * 3; - test_io(t2_pcm_bc, t1_pcm_bc, a2dp_faststream_enc_thread, test_io_thread_dump_bt, 2 * 1024); - test_io(t2_pcm_bc, t1_pcm_bc, test_io_thread_dump_pcm, a2dp_faststream_dec_thread, 2 * 1024); + test_io(t2_pcm_bc, t1_pcm_bc, a2dp_fs_enc_thread, test_io_thread_dump_bt, 2 * 1024); + test_io(t2_pcm_bc, t1_pcm_bc, test_io_thread_dump_pcm, a2dp_fs_dec_thread, 2 * 1024); } ba_transport_destroy(t1); diff --git a/test/test-utils-aplay.c b/test/test-utils-aplay.c index 12bc1b2bf..16b6b44d9 100644 --- a/test/test-utils-aplay.c +++ b/test/test-utils-aplay.c @@ -289,16 +289,16 @@ CK_START_TEST(test_play_dbus_signals) { ck_assert_ptr_ne(strstr(output, "Used configuration for 12:34:56:78:9A:BC"), NULL); - /* check proper sampling rate for CVSD codec */ + /* check proper sample rate for CVSD codec */ ck_assert_ptr_ne(strstr(output, - "Sampling rate: 8000 Hz"), NULL); + "Sample rate: 8000 Hz"), NULL); #if ENABLE_MSBC ck_assert_ptr_ne(strstr(output, "Used configuration for 12:34:56:78:9A:BC"), NULL); - /* check proper sampling rate for mSBC codec */ + /* check proper sample rate for mSBC codec */ ck_assert_ptr_ne(strstr(output, - "Sampling rate: 16000 Hz"), NULL); + "Sample rate: 16000 Hz"), NULL); #endif spawn_close(&sp_ba_aplay, NULL); diff --git a/test/test-utils-ctl.c b/test/test-utils-ctl.c index 48823bfa3..b81429141 100644 --- a/test/test-utils-ctl.c +++ b/test/test-utils-ctl.c @@ -198,7 +198,7 @@ CK_START_TEST(test_info) { ck_assert_ptr_ne(strstr(output, "Transport: A2DP-source"), NULL); ck_assert_ptr_ne(strstr(output, - "Selected codec:\n\tSBC:211502fa [channels: 2] [sampling: 44100]"), NULL); + "Selected codec:\n\tSBC:211502fa [channels: 2] [rate: 44100]"), NULL); ck_assert_ptr_ne(strstr(output, "ChannelMap: FL FR"), NULL); @@ -252,7 +252,7 @@ CK_START_TEST(test_codec) { /* check selecting A2DP codec (with our mock BlueZ) */ ck_assert_int_eq(run_bluealsactl(output, sizeof(output), "codec", "-vf", "/org/bluealsa/hci11/dev_12_34_56_78_9A_BC/a2dpsrc/sink", - "SBC:FF150255", "--channels=1", "--sampling=44100", + "SBC:FF150255", "--channels=1", "--rate=44100", NULL), EXIT_SUCCESS); spawn_terminate(&sp_ba_mock, 0); diff --git a/utils/a2dpconf.c b/utils/a2dpconf.c index ecaca6618..e00e40cff 100644 --- a/utils/a2dpconf.c +++ b/utils/a2dpconf.c @@ -78,7 +78,7 @@ static void dump_sbc(const void *blob, size_t size) { if (check_blob_size(sizeof(*sbc), size) == -1) return; printf("SBC {\n" - " sampling-frequency:4 =%s%s%s%s\n" + " sample-rate:4 =%s%s%s%s\n" " channel-mode:4 =%s%s%s%s\n" " block-length:4 =%s%s%s%s\n" " sub-bands:2 =%s%s\n" @@ -116,7 +116,7 @@ static void dump_mpeg(const void *blob, size_t size) { " channel-mode:4 =%s%s%s%s\n" " :1\n" " media-payload-format:1 = MPF-1%s\n" - " sampling-frequency:6 =%s%s%s%s%s%s\n" + " sample-rate:6 =%s%s%s%s%s%s\n" " vbr:1 = %s\n" " bitrate-index:15 = %#x\n" "}\n", @@ -148,7 +148,7 @@ static void dump_aac(const void *blob, size_t size) { printf("MPEG-2,4 AAC {\n" " object-type:7 =%s%s%s%s%s%s%s\n" " dynamic-range-control:1 = %s\n" - " sampling-frequency:12 =%s%s%s%s%s%s%s%s%s%s%s%s\n" + " sample-rate:12 =%s%s%s%s%s%s%s%s%s%s%s%s\n" " channel-mode:4 =%s%s%s%s\n" " vbr:1 = %s\n" " bitrate:23 = %u\n" @@ -189,7 +189,7 @@ static void dump_usac(const void *blob, size_t size) { const uint32_t usac_sampling_freq = A2DP_USAC_GET_SAMPLING_FREQ(*usac); printf("MPEG-D USAC {\n" " object-type:2 =%s\n" - " sampling-frequency:26 =%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n" + " sample-rate:26 =%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n" " channel-mode:4 =%s%s\n" " vbr:1 = %s\n" " bitrate:23 = %u\n" @@ -236,7 +236,7 @@ static void dump_atrac(const void *blob, size_t size) { " version:3 = ATRAC%u\n" " channel-mode:3 =%s%s%s\n" " :4\n" - " sampling-frequency:2 =%s%s\n" + " sample-rate:2 =%s%s\n" " vbr:1 = %s\n" " bitrate-index:19 = %#x\n" " max-sound-unit-length:16 = %u\n" @@ -281,7 +281,7 @@ static void dump_vendor(const void *blob, size_t size) { static void printf_aptx(const a2dp_aptx_t *aptx) { printf("" " channel-mode:4 =%s%s%s\n" - " sampling-frequency:4 =%s%s%s%s\n", + " sample-rate:4 =%s%s%s%s\n", aptx->channel_mode & APTX_CHANNEL_MODE_STEREO ? " Stereo" : "", aptx->channel_mode & APTX_CHANNEL_MODE_TWS ? " DualChannel" : "", aptx->channel_mode & APTX_CHANNEL_MODE_MONO ? " Mono" : "", @@ -370,8 +370,8 @@ static void dump_faststream(const void *blob, size_t size) { printf_vendor(&faststream->info); printf("" " direction:8 =%s%s\n" - " sampling-frequency-voice:8 =%s\n" - " sampling-frequency-music:8 =%s%s\n" + " sample-rate-voice:8 =%s\n" + " sample-rate-music:8 =%s%s\n" "}\n", faststream->direction & FASTSTREAM_DIRECTION_MUSIC ? " Music" : "", faststream->direction & FASTSTREAM_DIRECTION_VOICE ? " Voice" : "", @@ -391,7 +391,7 @@ static void dump_lc3plus(const void *blob, size_t size) { " frame-duration:4 =%s%s%s\n" " :4\n" " channel-mode:8 =%s%s\n" - " sampling-frequency:16 =%s%s\n" + " sample-rate:16 =%s%s\n" "}\n", lc3plus->frame_duration & LC3PLUS_FRAME_DURATION_025 ? " 2.5ms" : "", lc3plus->frame_duration & LC3PLUS_FRAME_DURATION_050 ? " 5ms" : "", @@ -410,7 +410,7 @@ static void dump_ldac(const void *blob, size_t size) { printf_vendor(&ldac->info); printf("" " :2\n" - " sampling-frequency:6 =%s%s%s%s%s%s\n" + " sample-rate:6 =%s%s%s%s%s%s\n" " :5\n" " channel-mode:3 =%s%s%s\n" "}\n", @@ -448,7 +448,7 @@ static void dump_lhdc_v1(const void *blob, size_t size) { " :1\n" " ch-separation:1 = %s\n" " bit-depth:2 =%s%s\n" - " sampling-frequency:4 =%s%s%s%s\n" + " sample-rate:4 =%s%s%s%s\n" "}\n", lhdc->ch_separation ? "true" : "false", lhdc->bit_depth & LHDC_BIT_DEPTH_24 ? " 24" : "", @@ -468,7 +468,7 @@ static void dump_lhdc_v2(const void *blob, size_t size) { printf("" " :2\n" " bit-depth:2 =%s%s\n" - " sampling-frequency:4 =%s%s%s%s\n" + " sample-rate:4 =%s%s%s%s\n" " low-latency:1 = %s\n" " max-bitrate:3 = %d\n" " version:4 = %u\n" @@ -499,7 +499,7 @@ static void dump_lhdc_v3(const void *blob, size_t size) { " ar:1 = %s\n" " jas:1 = %s\n" " bit-depth:2 =%s%s\n" - " sampling-frequency:4 =%s%s%s%s\n" + " sample-rate:4 =%s%s%s%s\n" " llac:1 = %s\n" " low-latency:1 = %s\n" " max-bitrate:2 = %d\n" @@ -552,7 +552,7 @@ static void dump_opus(const void *blob, size_t size) { printf_vendor(&opus->info); printf("" " :2\n" - " sampling-frequency:1 =%s\n" + " sample-rate:1 =%s\n" " frame-duration:2 =%s%s\n" " channel-mode:3 =%s%s%s\n" "}\n", diff --git a/utils/aplay/alsa-pcm.c b/utils/aplay/alsa-pcm.c index ebe2ee662..f47546839 100644 --- a/utils/aplay/alsa-pcm.c +++ b/utils/aplay/alsa-pcm.c @@ -46,7 +46,7 @@ static int alsa_pcm_set_hw_params(snd_pcm_t *pcm, snd_pcm_format_t format, int c } if ((err = snd_pcm_hw_params_set_rate(pcm, params, rate, 0)) != 0) { - snprintf(buf, sizeof(buf), "Set sampling rate: %s: %d", snd_strerror(err), rate); + snprintf(buf, sizeof(buf), "Set sample rate: %s: %d", snd_strerror(err), rate); goto fail; } diff --git a/utils/aplay/aplay.c b/utils/aplay/aplay.c index b7552eae9..a3bc8aa60 100644 --- a/utils/aplay/aplay.c +++ b/utils/aplay/aplay.c @@ -205,7 +205,7 @@ static void print_bt_device_list(void) { pcm->codec.name, snd_pcm_format_name(bluealsa_get_snd_pcm_format(pcm)), pcm->channels, pcm->channels != 1 ? "s" : "", - pcm->sampling); + pcm->rate); } } @@ -246,7 +246,7 @@ static void print_bt_pcm_list(void) { pcm->codec.name, snd_pcm_format_name(bluealsa_get_snd_pcm_format(pcm)), pcm->channels, pcm->channels != 1 ? "s" : "", - pcm->sampling); + pcm->rate); } @@ -538,7 +538,7 @@ static void *io_worker_routine(struct io_worker *w) { snd_pcm_format_t pcm_format = bluealsa_get_snd_pcm_format(&w->ba_pcm); ssize_t pcm_format_size = snd_pcm_format_size(pcm_format, 1); - size_t pcm_1s_samples = w->ba_pcm.sampling * w->ba_pcm.channels; + size_t pcm_1s_samples = w->ba_pcm.rate * w->ba_pcm.channels; ffb_t buffer = { 0 }; /* Cancellation should be possible only in the carefully selected place @@ -728,9 +728,9 @@ static void *io_worker_routine(struct io_worker *w) { } debug("Opening ALSA playback PCM: name=%s channels=%u rate=%u", - pcm_device, w->ba_pcm.channels, w->ba_pcm.sampling); + pcm_device, w->ba_pcm.channels, w->ba_pcm.rate); if (alsa_pcm_open(&w->snd_pcm, pcm_device, pcm_format, w->ba_pcm.channels, - w->ba_pcm.sampling, &buffer_time, &period_time, &tmp) != 0) { + w->ba_pcm.rate, &buffer_time, &period_time, &tmp) != 0) { warn("Couldn't open ALSA playback PCM: %s", tmp); pcm_max_read_len = pcm_max_read_len_init; pcm_open_retry_pcm_samples = 0; @@ -754,13 +754,13 @@ static void *io_worker_routine(struct io_worker *w) { " ALSA PCM buffer time: %u us (%zu bytes)\n" " ALSA PCM period time: %u us (%zu bytes)\n" " PCM format: %s\n" - " Sampling rate: %u Hz\n" + " Sample rate: %u Hz\n" " Channels: %u", w->addr, buffer_time, snd_pcm_frames_to_bytes(w->snd_pcm, buffer_frames), period_time, snd_pcm_frames_to_bytes(w->snd_pcm, period_frames), snd_pcm_format_name(pcm_format), - w->ba_pcm.sampling, + w->ba_pcm.rate, w->ba_pcm.channels); } @@ -835,7 +835,7 @@ static bool pcm_hw_params_equal( return false; if (ba_pcm_1->channels != ba_pcm_2->channels) return false; - if (ba_pcm_1->sampling != ba_pcm_2->sampling) + if (ba_pcm_1->rate != ba_pcm_2->rate) return false; return true; } @@ -933,7 +933,7 @@ static struct io_worker *supervise_io_worker(const struct ba_pcm *ba_pcm) { /* check whether SCO has selected codec */ if (ba_pcm->transport & BA_PCM_TRANSPORT_MASK_SCO && - ba_pcm->sampling == 0) { + ba_pcm->rate == 0) { debug("Skipping SCO with codec not selected"); goto stop; }