/[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 212 - (hide annotations) (download) (as text)
Wed Jul 28 14:17:29 2004 UTC (19 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6706 byte(s)
* introduced and implemented new LSCP command "RESET" which resets the
  whole sampler instance
* src/drivers/audio/AudioOutputDeviceAlsa.cpp: parameter 'card' now
  returns all available sound cards as possibility, added dependency to
  parameter 'card' to parameters 'fragments' and 'fragmentsize'
* src/drivers/DeviceParameter.cpp: fixed return value(s) for classes
  'DeviceCreationParameterString' and 'DeviceCreationParameterStrings'
  which returned the default value(s) not encapsulated into apostrophes
* src/network/lscpserver.cpp: fixed implementation of LSCP commands
  "GET MIDI_INPUT_DRIVER_PARAMETER INFO" and
  "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO"

1 schoenebeck 200 /***************************************************************************
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    
56     static String Name();
57    
58     static String Description();
59     static String Version();
60    
61     class ParameterCard : public DeviceCreationParameterString {
62     public:
63 schoenebeck 212 ParameterCard();
64     ParameterCard(String s) throw (LinuxSamplerException);
65     virtual String Description();
66     virtual bool Fix();
67     virtual bool Mandatory();
68     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
69     virtual optional<String> DefaultAsString(std::map<String,String> Parameters);
70     virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);
71     virtual void OnSetValue(String s) throw (LinuxSamplerException);
72     static String Name();
73 schoenebeck 200 };
74    
75     class ParameterFragments : public DeviceCreationParameterInt {
76     public:
77 schoenebeck 212 ParameterFragments();
78     ParameterFragments(String s) throw (LinuxSamplerException);
79     virtual String Description();
80     virtual bool Fix();
81     virtual bool Mandatory();
82     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
83     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
84     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
85     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
86     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
87     virtual void OnSetValue(int i) throw (LinuxSamplerException);
88     static String Name();
89 schoenebeck 200 };
90    
91     class ParameterFragmentSize : public DeviceCreationParameterInt {
92     public:
93 schoenebeck 212 ParameterFragmentSize();
94     ParameterFragmentSize(String s) throw (LinuxSamplerException);
95     virtual String Description();
96     virtual bool Fix();
97     virtual bool Mandatory();
98     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
99     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
100     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
101     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
102     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
103     virtual void OnSetValue(int i) throw (LinuxSamplerException);
104     static String Name();
105 schoenebeck 200 };
106    
107     protected:
108     int Main(); ///< Implementation of virtual method from class Thread
109    
110     private:
111     uint uiAlsaChannels;
112     uint uiSamplerate;
113     uint FragmentSize;
114     int16_t* pAlsaOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card
115     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.
116     snd_pcm_t* pcm_handle; ///< Handle for the PCM device
117     snd_pcm_stream_t stream;
118     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.
119     snd_pcm_sw_params_t* swparams;
120    
121     int Output();
122     bool HardwareParametersSupported(String card, uint channels, int samplerate, uint numfragments, uint fragmentsize);
123     };
124     }
125    
126     #endif // __LS_AUDIOOUTPUTDEVICEALSA_H__

  ViewVC Help
Powered by ViewVC