17 #ifndef ALSAEXTERNALPLUGIN_H 18 #define ALSAEXTERNALPLUGIN_H 21 #include <alsa/pcm_external.h> 22 #include <alsa/pcm_plugin.h> 30 #define STATICFNNAME(name) name##_static 31 #define STATICFNDEF(retType, name) static retType STATICFNNAME(name) (snd_pcm_extplug_t *extplug) 32 #define STATICFNDEF2(retType, name, arg1_type, arg1) static retType STATICFNNAME(name) (snd_pcm_extplug_t *extplug, arg1_type arg1) 33 #define STATICFNBODY(name) {std::cout<<__func__<<std::endl; return static_cast<ALSAExternalPlugin*>(extplug->private_data)->name();} 34 #define STATICFNBODY2(name, arg1) {std::cout<<__func__<<std::endl; return static_cast<ALSAExternalPlugin*>(extplug->private_data)->name(arg1);} 35 #define STATICFN(retType, name) STATICFNDEF(retType, name) STATICFNBODY(name) 36 #define STATICFN2(retType, name, arg1_type, arg1) STATICFNDEF2(retType, name, arg1_type, arg1) STATICFNBODY2(name, arg1) 50 static snd_pcm_sframes_t
transfer_static(snd_pcm_extplug_t *
extplug, const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t
size){
68 std::cout<<__func__<<std::endl;
70 extplug.version = SND_PCM_EXTPLUG_VERSION;
71 setName(
"ALSAExternalPlugin default name");
73 extplug.private_data=
this;
89 std::cout<<__func__<<std::endl;
105 std::cout<<__func__<<std::endl;
107 std::cout<<
"channels : "<<
getChannels()<<std::endl;
109 std::cout<<
"period sz: "<<
getPeriodSize()<<
" frames"<<std::endl;
129 virtual void dump(snd_output_t *out){
141 snd_pcm_sframes_t
doTransfer(
const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t
size){
142 return transfer(dst_areas, dst_offset, src_areas, src_offset, size);
147 virtual snd_pcm_sframes_t
transfer(
const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t
size){
154 int create(
const char *name, snd_config_t * root, snd_pcm_stream_t stream,
int mode){
156 std::ostringstream oss;
157 oss<<
"No slave configuration for "<<name<<
" : "<<extplug.name<<
" external plugin";
158 SNDERR(oss.str().c_str());
161 return snd_pcm_extplug_create(&extplug, name, root, slaveConf, stream, mode);
167 virtual int parseConfig(
const char *name, snd_config_t *conf, snd_pcm_stream_t stream,
int mode){
169 snd_config_iterator_t i, next;
170 snd_config_for_each(i, next, conf) {
171 snd_config_t *n = snd_config_iterator_entry(i);
173 if (snd_config_get_id(n, &
id) < 0)
175 if (strcmp(
id,
"comment") == 0 || strcmp(
id,
"type") == 0 || strcmp(
id,
"hint") == 0)
177 if (strcmp(
id,
"slave") == 0) {
181 SNDERR(
"Unknown field %s",
id);
186 std::ostringstream oss;
187 oss<<
"No slave configuration for "<<name<<
" : "<<extplug.name<<
" external plugin";
188 SNDERR(oss.str().c_str());
198 std::cout<<
'\t'<<__func__<<
'\t'<<__LINE__<<std::endl;
204 #endif // ALSAEXTERNALPLUGIN_H void copyFrom(snd_pcm_hw_params_t *hParamsIn)
int getPeriodSize(snd_pcm_uframes_t *p, int *dir=NULL)
snd_pcm_extplug_t extplug
#define STATICFNNAME(name)
#define STATICFN2(retType, name, arg1_type, arg1)
virtual snd_pcm_t * getPCM()
virtual ~ALSAExternalPlugin()
#define STATICFN(retType, name)
void setName(const char *name)
The slave to use.
virtual snd_pcm_sframes_t transfer(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t size)
int getSampleRate(int dir=0)
virtual int specifyHWParams()=0
virtual void dump(snd_output_t *out)
snd_pcm_sframes_t doTransfer(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t size)
int create(const char *name, snd_config_t *root, snd_pcm_stream_t stream, int mode)
virtual int parseConfig(const char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode)
static snd_pcm_sframes_t transfer_static(snd_pcm_extplug_t *extplug, const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, snd_pcm_uframes_t size)
The callback functions.
snd_pcm_extplug_callback_t callbacks
virtual int hwParams(snd_pcm_hw_params_t *params)
snd_config_t * slaveConf
The ALSA plugin.