/[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 880 - (hide annotations) (download) (as text)
Tue Jun 27 22:57:37 2006 UTC (17 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7175 byte(s)
just some refactoring work:
- renamed class LinuxSamplerException -> Exception
- encapsulated LS API relevant files into LS namespace
- removed unnecessary header inclusions

1 schoenebeck 200 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 880 * Copyright (C) 2005, 2006 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 221 /** Device Parameter 'FRAGMENTS'
79     *
80     * Used to select the number of audio fragments / periods.
81     */
82 schoenebeck 200 class ParameterFragments : public DeviceCreationParameterInt {
83     public:
84 schoenebeck 212 ParameterFragments();
85 schoenebeck 880 ParameterFragments(String s) throw (Exception);
86 schoenebeck 212 virtual String Description();
87     virtual bool Fix();
88     virtual bool Mandatory();
89     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
90     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
91     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
92     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
93     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
94 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception);
95 schoenebeck 212 static String Name();
96 schoenebeck 200 };
97    
98 schoenebeck 221 /** Device Parameter 'FRAGMENTSIZE'
99     *
100     * Used to set the audio fragment size / period size.
101     */
102 schoenebeck 200 class ParameterFragmentSize : public DeviceCreationParameterInt {
103     public:
104 schoenebeck 212 ParameterFragmentSize();
105 schoenebeck 880 ParameterFragmentSize(String s) throw (Exception);
106 schoenebeck 212 virtual String Description();
107     virtual bool Fix();
108     virtual bool Mandatory();
109     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
110     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
111     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
112     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
113     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
114 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception);
115 schoenebeck 212 static String Name();
116 schoenebeck 200 };
117    
118     protected:
119     int Main(); ///< Implementation of virtual method from class Thread
120    
121     private:
122     uint uiAlsaChannels;
123     uint uiSamplerate;
124     uint FragmentSize;
125     int16_t* pAlsaOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card
126     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.
127     snd_pcm_t* pcm_handle; ///< Handle for the PCM device
128     snd_pcm_stream_t stream;
129     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.
130     snd_pcm_sw_params_t* swparams;
131    
132     int Output();
133 schoenebeck 485 bool HardwareParametersSupported(String card, uint channels, int samplerate, uint numfragments, uint fragmentsize) throw (AudioOutputException);
134 schoenebeck 200 };
135     }
136    
137     #endif // __LS_AUDIOOUTPUTDEVICEALSA_H__

  ViewVC Help
Powered by ViewVC