gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
Software.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16 */
17 #ifndef SOFTWARE_H
18 #define SOFTWARE_H
19 
20 #include <ALSA/ALSA.H>
21 
22 namespace ALSA {
23  class Software : public Hardware {
24  snd_pcm_sw_params_t *sParams;
25 
26  public:
27  Software(void){
28  sParams=NULL;
29  snd_pcm_sw_params_malloc(&sParams);
30  if (!sParams)
31  assert("Couldn't malloc SW params");
32  }
33 
34  virtual ~Software(void){
35  if (sParams)
36  snd_pcm_sw_params_free(sParams);
37  sParams=NULL;
38  }
39 
43  int getSWParams() {
44  PCM_NOT_OPEN_CHECK(getPCM()) // check pcm is open
45  return snd_pcm_sw_params_current(getPCM(), sParams);
46  }
47 
51  int setSWParams() {
52  PCM_NOT_OPEN_CHECK(getPCM()) // check pcm is open
53  return snd_pcm_sw_params(getPCM(), sParams);
54  }
55 
60  int setSWThreshold(snd_pcm_uframes_t thresh) {
61  PCM_NOT_OPEN_CHECK(getPCM()) // check pcm is open
62  return snd_pcm_sw_params_set_start_threshold(getPCM(), sParams, thresh);
63  }
64 
69  int setAvailMin(snd_pcm_uframes_t cnt) {
70  PCM_NOT_OPEN_CHECK(getPCM()) // check pcm is open
71  return snd_pcm_sw_params_set_avail_min(getPCM(), sParams, cnt);
72  }
73 
78  void *getAddress(const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset) const {
79  return (void*)((char*)(areas->addr)+(areas->first+offset*areas->step)/8);
80  }
81 
87  template<typename SAMPLE_TYPE>
88  int getChannelCount(const snd_pcm_channel_area_t *areas) const {
89  return areas->step/sizeof(SAMPLE_TYPE)/8;;
90  }
91 
92  int dumpSWParams(){
93  int ret=0;
94  if (!logEnabled())
95  return ret;
96  return snd_pcm_sw_params_dump(sParams, log);
97  }
98 
99  };
100 }
101 #endif //SOFTWARE_H
int setSWParams()
Definition: Software.H:51
virtual ~Software(void)
Definition: Software.H:34
virtual snd_pcm_t * getPCM()
Definition: PCM.H:42
void * getAddress(const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset) const
Definition: Software.H:78
Definition: ALSA.H:26
int getChannelCount(const snd_pcm_channel_area_t *areas) const
Definition: Software.H:88
#define PCM_NOT_OPEN_CHECK(pcm)
Definition: ALSA.H:30
int setSWThreshold(snd_pcm_uframes_t thresh)
Definition: Software.H:60
snd_output_t * log
The log stream if enabled.
Definition: PCM.H:28
Software(void)
Definition: Software.H:27
int getSWParams()
Definition: Software.H:43
int setAvailMin(snd_pcm_uframes_t cnt)
Definition: Software.H:69
snd_pcm_sw_params_t * sParams
PCM software params.
Definition: Software.H:24
int logEnabled()
Definition: PCM.H:113
int dumpSWParams()
Definition: Software.H:92
gtkIOStream: /tmp/gtkiostream/include/ALSA/Software.H Source File
GTK+ IOStream  Beta