/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceAlsa.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceAlsa.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1049 - (hide annotations) (download) (as text)
Wed Feb 28 06:53:42 2007 UTC (17 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8688 byte(s)
* the ALSA audio output driver parameters now reflect the correct
  parameter value ranges for the respective selected sound card
  (patch by Till Wimmer, a bit fixed and extended)
* bumped version to 0.4.0.4cvs

1 schoenebeck 200 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 1049 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 schoenebeck 200 * *
8     * This program is free software; you can redistribute it and/or modify *
9     * it under the terms of the GNU General Public License as published by *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifndef __LS_AUDIOOUTPUTDEVICEALSA_H__
25     #define __LS_AUDIOOUTPUTDEVICEALSA_H__
26    
27     #include <string.h>
28     #include <alsa/asoundlib.h>
29    
30     #include "../../common/global.h"
31     #include "../../common/Thread.h"
32     #include "AudioOutputDevice.h"
33     #include "AudioChannel.h"
34     #include "../DeviceParameter.h"
35    
36     namespace LinuxSampler {
37    
38     /** ALSA audio output driver
39     *
40     * Implements audio output to the Advanced Linux Sound Architecture (ALSA).
41     */
42     class AudioOutputDeviceAlsa : public AudioOutputDevice, protected Thread {
43     public:
44     AudioOutputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters);
45     ~AudioOutputDeviceAlsa();
46    
47     // derived abstract methods from class 'AudioOutputDevice'
48     virtual void Play();
49     virtual bool IsPlaying();
50     virtual void Stop();
51     virtual uint MaxSamplesPerCycle();
52     virtual uint SampleRate();
53 schoenebeck 226 virtual AudioChannel* CreateChannel(uint ChannelNr);
54 schoenebeck 200
55     virtual String Driver();
56 schoenebeck 221 static String Name();
57 schoenebeck 200 static String Description();
58     static String Version();
59    
60 schoenebeck 221 /** Device Parameter 'CARD'
61     *
62     * Used to select the desired ALSA sound card.
63     */
64 schoenebeck 200 class ParameterCard : public DeviceCreationParameterString {
65     public:
66 schoenebeck 212 ParameterCard();
67 schoenebeck 880 ParameterCard(String s) throw (Exception);
68 schoenebeck 212 virtual String Description();
69     virtual bool Fix();
70     virtual bool Mandatory();
71     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
72     virtual optional<String> DefaultAsString(std::map<String,String> Parameters);
73     virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);
74 schoenebeck 880 virtual void OnSetValue(String s) throw (Exception);
75 schoenebeck 212 static String Name();
76 schoenebeck 200 };
77    
78 schoenebeck 1049 /** Device Parameter 'SAMPLERATE'
79     *
80     * Used to set the sample rate of the audio output device.
81     */
82     class ParameterSampleRate : public AudioOutputDevice::ParameterSampleRate {
83     public:
84     ParameterSampleRate();
85     ParameterSampleRate(String s);
86     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
87     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
88     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
89     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
90     };
91    
92     /** Device Parameters 'CHANNELS'
93     *
94     * Used to increase / decrease the number of audio channels of
95     * audio output device.
96     */
97     class ParameterChannels : public AudioOutputDevice::ParameterChannels {
98     public:
99     ParameterChannels();
100     ParameterChannels(String s);
101     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
102     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
103     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
104     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
105     };
106    
107 schoenebeck 221 /** Device Parameter 'FRAGMENTS'
108     *
109     * Used to select the number of audio fragments / periods.
110     */
111 schoenebeck 200 class ParameterFragments : public DeviceCreationParameterInt {
112     public:
113 schoenebeck 212 ParameterFragments();
114 schoenebeck 880 ParameterFragments(String s) throw (Exception);
115 schoenebeck 212 virtual String Description();
116     virtual bool Fix();
117     virtual bool Mandatory();
118     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
119     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
120     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
121     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
122     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
123 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception);
124 schoenebeck 212 static String Name();
125 schoenebeck 200 };
126    
127 schoenebeck 221 /** Device Parameter 'FRAGMENTSIZE'
128     *
129     * Used to set the audio fragment size / period size.
130     */
131 schoenebeck 200 class ParameterFragmentSize : public DeviceCreationParameterInt {
132     public:
133 schoenebeck 212 ParameterFragmentSize();
134 schoenebeck 880 ParameterFragmentSize(String s) throw (Exception);
135 schoenebeck 212 virtual String Description();
136     virtual bool Fix();
137     virtual bool Mandatory();
138     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
139     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
140     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
141     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
142     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
143 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception);
144 schoenebeck 212 static String Name();
145 schoenebeck 200 };
146    
147     protected:
148     int Main(); ///< Implementation of virtual method from class Thread
149    
150     private:
151     uint uiAlsaChannels;
152     uint uiSamplerate;
153     uint FragmentSize;
154     int16_t* pAlsaOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card
155     String pcm_name; ///< Name of the PCM device, like plughw:0,0 the first number is the number of the soundcard, the second number is the number of the device.
156     snd_pcm_t* pcm_handle; ///< Handle for the PCM device
157     snd_pcm_stream_t stream;
158     snd_pcm_hw_params_t* hwparams; ///< This structure contains information about the hardware and can be used to specify the configuration to be used for the PCM stream.
159     snd_pcm_sw_params_t* swparams;
160    
161     int Output();
162 schoenebeck 485 bool HardwareParametersSupported(String card, uint channels, int samplerate, uint numfragments, uint fragmentsize) throw (AudioOutputException);
163 schoenebeck 200 };
164     }
165    
166     #endif // __LS_AUDIOOUTPUTDEVICEALSA_H__

  ViewVC Help
Powered by ViewVC