Codebase list alsa-lib / 7f2d6c3
pcm: hw: change rate range syntax Allow three configuration types: rate 48000 # single rate rate [ 48000 ] # single rate (2nd) rate [ 44100 48000 ] # range Fixes: https://github.com/alsa-project/alsa-lib/pull/191 Fixes: ac04cb63 ("hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter") Signed-off-by: Jaroslav Kysela <perex@perex.cz> Jaroslav Kysela 1 year, 11 months ago
1 changed file(s) with 33 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
354354 }
355355 if (hw->rates.min > 0) {
356356 err = _snd_pcm_hw_param_set_minmax(params, SND_PCM_HW_PARAM_RATE,
357 #if 1 // TODO: find out which arguments are correct
358357 hw->rates.min, 0, hw->rates.max + 1, -1);
359 #else
360 hw->rates.min, 0, hw->rates.max, 0);
361 #endif
362 if (err < 0)
358
363359 return err;
364360 }
365361
17721768 [format STR] # Restrict only to the given format
17731769 [channels INT] # Restrict only to the given channels
17741770 [rate INT] # Restrict only to the given rate
1771 or [rate [INT INT]] # Restrict only to the given rate range (min max)
17751772 [chmap MAP] # Override channel maps; MAP is a string array
17761773 }
17771774 \endcode
18051802 long card = -1, device = 0, subdevice = -1;
18061803 const char *str;
18071804 int err, sync_ptr_ioctl = 0;
1808 int rate = 0, channels = 0, min_rate = 0, max_rate = 0;
1805 int min_rate = 0, max_rate = 0, channels = 0;
18091806 snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN;
18101807 snd_config_t *n;
18111808 int nonblock = 1; /* non-block per default */
18641861 }
18651862 if (strcmp(id, "rate") == 0) {
18661863 long val;
1867 err = snd_config_get_integer(n, &val);
1868 if (err < 0) {
1869 SNDERR("Invalid type for %s", id);
1870 goto fail;
1864 if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND &&
1865 snd_config_is_array(n)) {
1866 snd_config_t *m;
1867 err = snd_config_search(n, "0", &m);
1868 if (err < 0) {
1869 SNDERR("array expected for rate compound");
1870 goto fail;
1871 }
1872 err = snd_config_get_integer(m, &val);
1873 if (err < 0) {
1874 SNDERR("Invalid type for rate.0");
1875 goto fail;
1876 }
1877 min_rate = max_rate = val;
1878 err = snd_config_search(n, "1", &m);
1879 if (err >= 0) {
1880 err = snd_config_get_integer(m, &val);
1881 if (err < 0) {
1882 SNDERR("Invalid type for rate.0");
1883 goto fail;
1884 }
1885 max_rate = val;
1886 }
1887 } else {
1888 err = snd_config_get_integer(n, &val);
1889 if (err < 0) {
1890 SNDERR("Invalid type for %s", id);
1891 goto fail;
1892 }
1893 min_rate = max_rate = val;
18711894 }
1872 rate = val;
18731895 continue;
18741896 }
18751897 if (strcmp(id, "min_rate") == 0) {
19571979 hw->format = format;
19581980 if (channels > 0)
19591981 hw->channels = channels;
1960 if ((min_rate == 0) && (max_rate == 0)) {
1961 min_rate = rate;
1962 max_rate = rate;
1963 }
19641982 if (min_rate > 0) {
19651983 hw->rates.min = min_rate;
19661984 hw->rates.max = max_rate;