]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
alsa: Make two variables local to alsa_init().
authorAndre Noll <maan@systemlinux.org>
Fri, 29 Jul 2011 21:46:28 +0000 (23:46 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 18 Oct 2011 17:29:33 +0000 (19:29 +0200)
The two members buffer_frames and buffer_time of struct
private_alsa_data are only needed in alsa_init(), so make them
local. Rename buffer_frames to buffer_size since this is the value
returned by snd_pcm_hw_params_get_buffer_size().

alsa_write.c

index a7539ba4623f5352d5216cb0b73688acba8d7db6..2dab8fe1543f9205d8d12d7fa9db85be60768df6 100644 (file)
@@ -36,10 +36,6 @@ struct private_alsa_write_data {
        snd_pcm_t *handle;
        /** Determined and set by alsa_init(). */
        int bytes_per_frame;
-       /** The approximate maximum buffer duration in us. */
-       unsigned buffer_time;
-       /* Number of frames that fit into the buffer. */
-       snd_pcm_uframes_t buffer_frames;
        /**
         * The sample rate given by command line option or the decoder
         * of the writer node group.
@@ -76,8 +72,9 @@ static int alsa_init(struct private_alsa_write_data *pad,
        snd_pcm_hw_params_t *hwparams;
        snd_pcm_sw_params_t *swparams;
        snd_pcm_uframes_t start_threshold, stop_threshold;
-       snd_pcm_uframes_t period_size;
+       snd_pcm_uframes_t buffer_size, period_size;
        snd_output_t *log;
+       unsigned buffer_time;
        int err;
 
        PARA_INFO_LOG("opening %s\n", conf->device_arg);
@@ -103,29 +100,30 @@ static int alsa_init(struct private_alsa_write_data *pad,
                        &pad->sample_rate, NULL) < 0)
                return -E_SET_RATE;
        err = snd_pcm_hw_params_get_buffer_time_max(hwparams,
-               &pad->buffer_time, NULL);
-       if (err < 0 || !pad->buffer_time)
+               &buffer_time, NULL);
+       if (err < 0 || buffer_time == 0)
                return -E_GET_BUFFER_TIME;
        if (snd_pcm_hw_params_set_buffer_time_near(pad->handle, hwparams,
-                       &pad->buffer_time, NULL) < 0)
+                       &buffer_time, NULL) < 0)
                return -E_SET_BUFFER_TIME;
        if (snd_pcm_hw_params(pad->handle, hwparams) < 0)
                return -E_HW_PARAMS;
        snd_pcm_hw_params_get_period_size(hwparams, &period_size, NULL);
-       snd_pcm_hw_params_get_buffer_size(hwparams, &pad->buffer_frames);
-       if (period_size == pad->buffer_frames)
+       snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size);
+       if (period_size == buffer_size)
                return -E_BAD_PERIOD;
+       /* software parameter setup */
        snd_pcm_sw_params_current(pad->handle, swparams);
        snd_pcm_sw_params_set_avail_min(pad->handle, swparams, period_size);
-       if (pad->buffer_frames < 1)
+       if (buffer_size < 1)
                start_threshold = 1;
        else
-               start_threshold = PARA_MIN(pad->buffer_frames,
+               start_threshold = PARA_MIN(buffer_size,
                        (snd_pcm_uframes_t)pad->sample_rate);
        if (snd_pcm_sw_params_set_start_threshold(pad->handle, swparams,
                        start_threshold) < 0)
                return -E_START_THRESHOLD;
-       stop_threshold = pad->buffer_frames;
+       stop_threshold = buffer_size;
        if (snd_pcm_sw_params_set_stop_threshold(pad->handle, swparams,
                        stop_threshold) < 0)
                return -E_STOP_THRESHOLD;