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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 221 - (show annotations) (download) (as text)
Fri Aug 20 17:25:19 2004 UTC (19 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7133 byte(s)
* src/drivers/midi/MidiInputDeviceAlsa.cpp: implemented port parameter
 "NAME" which now updates the registered ALSA seq port name as well, fixed
  port parameter "ALSA_SEQ_BINDINGS" to allow more than one binding
* src/network/lscp.y: fixed symbol STRINGVAL (that is strings encapsulated
  into apostrophes) which didn't allow space characters
* changed all driver names and driver paramaters to upper case
* fixed typo in LSCP documentation
  (section 5.3.12, was: "SET MIDI_INPUT_PORT PARAMETER",
   should be: "SET MIDI_INPUT_PORT_PARAMETER")

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

  ViewVC Help
Powered by ViewVC