On November 27, 2003 06:21 am, Sylvain Petreolle wrote:
> Is this second attempt better ?
> (not tested with alsa 0.9)
Why don't you define the snd_pcm_hw_params_* macros for
alsa 0.9. For example, this bit:
- snd_pcm_format_t format = snd_pcm_hw_params_get_format(hw_params);
- snd_pcm_access_t access = snd_pcm_hw_params_get_access(hw_params);
+ snd_pcm_format_t format;
+ snd_pcm_access_t access;
+ snd_pcm_uframes_t buffer_size, bufsize_min, bufsize_max;
+ int dir=0, channels, channels_min, channels_max;
+ long int period_size, periods_min=0, periods_max=0;
+
+#if (SND_LIB_MAJOR == 0)
+ format = snd_pcm_hw_params_get_format(hw_params);
+ access = snd_pcm_hw_params_get_access(hw_params);
+#else
+ snd_pcm_hw_params_get_format(hw_params,&format);
+ snd_pcm_hw_params_get_access(hw_params,&access);
+#endif
Could have been coded like so:
+#if (SND_LIB_MAJOR == 0)
+# define snd_pcm_hw_params_get_format(hw_params,format) do{ *format = snd_pcm_hw_params_get_format(hw_params);} while(0)
+# define snd_pcm_hw_params_get_access(hw_params,access) do{ *access = snd_pcm_hw_params_get_access(hw_params);} while(0)
... more snd_pcm_hw_params_* definitions
+#endif
...
- snd_pcm_format_t format = snd_pcm_hw_params_get_format(hw_params);
- snd_pcm_access_t access = snd_pcm_hw_params_get_access(hw_params);
+ snd_pcm_format_t format;
+ snd_pcm_access_t access;
+ snd_pcm_uframes_t buffer_size, bufsize_min, bufsize_max;
+ int dir=0, channels, channels_min, channels_max;
+ long int period_size, periods_min=0, periods_max=0;
+
+ snd_pcm_hw_params_get_format(hw_params,&format);
+ snd_pcm_hw_params_get_access(hw_params,&access);
Eliminates a lot of #ifdefs, cleaner code, etc.
--
Dimi.