/[svn]/linuxsampler/trunk/src/audioio.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/audioio.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by schoenebeck, Fri Nov 21 15:07:23 2003 UTC revision 18 by schoenebeck, Sun Dec 7 05:03:43 2003 UTC
# Line 84  int AudioIO::Initialize(uint channels, u Line 84  int AudioIO::Initialize(uint channels, u
84          return EXIT_FAILURE;          return EXIT_FAILURE;
85      }      }
86    
87        int dir = 0;
88    
89      /* Set sample rate. If the exact rate is not supported */      /* Set sample rate. If the exact rate is not supported */
90      /* by the hardware, use nearest possible rate.         */      /* by the hardware, use nearest possible rate.         */
91      if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, samplerate, 0)) < 0) {      #if ALSA_MAJOR > 0
92        if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &samplerate, &dir)) < 0) {
93        #else
94        if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, samplerate, &dir)) < 0) {
95        #endif
96          fprintf(stderr, "Error setting sample rate. : %s\n", snd_strerror(err));          fprintf(stderr, "Error setting sample rate. : %s\n", snd_strerror(err));
97          return EXIT_FAILURE;          return EXIT_FAILURE;
98      }      }
# Line 97  int AudioIO::Initialize(uint channels, u Line 103  int AudioIO::Initialize(uint channels, u
103      }      }
104    
105      /* Set number of periods. Periods used to be called fragments. */      /* Set number of periods. Periods used to be called fragments. */
106      if ((err = snd_pcm_hw_params_set_periods(pcm_handle, hwparams, numfragments, 0)) < 0) {      if ((err = snd_pcm_hw_params_set_periods(pcm_handle, hwparams, numfragments, dir)) < 0) {
107          fprintf(stderr, "Error setting number of periods. : %s\n", snd_strerror(err));          fprintf(stderr, "Error setting number of periods. : %s\n", snd_strerror(err));
108          return EXIT_FAILURE;          return EXIT_FAILURE;
109      }      }
# Line 170  bool AudioIO::HardwareParametersSupporte Line 176  bool AudioIO::HardwareParametersSupporte
176          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
177          return false;          return false;
178      }      }
179      if (snd_pcm_hw_params_test_rate(pcm_handle, hwparams, samplerate, 0) < 0) {      int dir = 0;
180        if (snd_pcm_hw_params_test_rate(pcm_handle, hwparams, samplerate, dir) < 0) {
181          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
182          return false;          return false;
183      }      }
# Line 178  bool AudioIO::HardwareParametersSupporte Line 185  bool AudioIO::HardwareParametersSupporte
185          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
186          return false;          return false;
187      }      }
188      if (snd_pcm_hw_params_test_periods(pcm_handle, hwparams, numfragments, 0) < 0) {      if (snd_pcm_hw_params_test_periods(pcm_handle, hwparams, numfragments, dir) < 0) {
189          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
190          return false;          return false;
191      }      }
# Line 191  bool AudioIO::HardwareParametersSupporte Line 198  bool AudioIO::HardwareParametersSupporte
198      return true;      return true;
199  }  }
200    
201    /**
202     *  Will be called by the audio engine after every audio fragment cycle, to
203     *  output the audio data of the current fragment to the soundcard.
204     *
205     *  @returns  0 on success
206     */
207  int AudioIO::Output() {  int AudioIO::Output() {
208      int err = snd_pcm_writei(pcm_handle, pOutputBuffer, FragmentSize);      int err = snd_pcm_writei(pcm_handle, pOutputBuffer, FragmentSize);
209      if (err < 0) {      if (err < 0) {

Legend:
Removed from v.13  
changed lines
  Added in v.18

  ViewVC Help
Powered by ViewVC