2
The mediastreamer library aims at providing modular media processing and I/O
3
for linphone, but also for any telephony application.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include "msossread.h"
26
#include <sys/types.h>
28
MSFilterInfo oss_read_info={
36
static MSOssReadClass *msossreadclass=NULL;
38
MSFilter * ms_oss_read_new()
42
if (msossreadclass==NULL)
44
msossreadclass=g_new(MSOssReadClass,1);
45
ms_oss_read_class_init( msossreadclass );
49
MS_FILTER(w)->klass=MS_FILTER_CLASS(msossreadclass);
56
void ms_oss_read_init(MSOssRead *w)
58
ms_sound_read_init(MS_SOUND_READ(w));
59
MS_FILTER(w)->outfifos=w->f_outputs;
60
MS_FILTER(w)->outfifos[0]=NULL;
66
gint ms_oss_read_set_property(MSOssRead *f,MSFilterProperty prop, void *value)
69
case MS_FILTER_PROPERTY_FREQ:
70
f->freq=((gint*)value)[0];
75
void ms_oss_read_class_init(MSOssReadClass *klass)
77
ms_sound_read_class_init(MS_SOUND_READ_CLASS(klass));
78
MS_FILTER_CLASS(klass)->max_foutputs=1; /* one fifo output only */
79
MS_FILTER_CLASS(klass)->setup=(MSFilterSetupFunc)ms_oss_read_setup;
80
MS_FILTER_CLASS(klass)->unsetup=(MSFilterSetupFunc)ms_oss_read_stop;
81
MS_FILTER_CLASS(klass)->process= (MSFilterProcessFunc)ms_oss_read_process;
82
MS_FILTER_CLASS(klass)->set_property=(MSFilterPropertyFunc)ms_oss_read_set_property;
83
MS_FILTER_CLASS(klass)->destroy= (MSFilterDestroyFunc)ms_oss_read_destroy;
84
MS_FILTER_CLASS(klass)->w_maxgran=MS_OSS_READ_MAX_GRAN;
85
MS_FILTER_CLASS(klass)->info=&oss_read_info;
86
MS_SOUND_READ_CLASS(klass)->set_device=(gint (*)(MSSoundRead*,gint))ms_oss_read_set_device;
87
MS_SOUND_READ_CLASS(klass)->start=(void (*)(MSSoundRead*))ms_oss_read_start;
88
MS_SOUND_READ_CLASS(klass)->stop=(void (*)(MSSoundRead*))ms_oss_read_stop;
89
ms_filter_class_set_name(MS_FILTER_CLASS(klass),"OssRead");
90
//ms_filter_class_set_attr( MS_FILTER_CLASS(klass),FILTER_CAN_SYNC|FILTER_IS_SOURCE);
93
void ms_oss_read_destroy( MSOssRead *obj)
98
void ms_oss_read_process(MSOssRead *f)
102
fifo=f->f_outputs[0];
104
g_return_if_fail(f->sndcard!=NULL);
105
g_return_if_fail(f->gran>0);
107
if (snd_card_can_read(f->sndcard)){
108
ms_fifo_get_write_ptr(fifo,f->gran,(void**)&p);
109
g_return_if_fail(p!=NULL);
110
snd_card_read(f->sndcard,p,f->gran);
115
void ms_oss_read_start(MSOssRead *r)
117
g_return_if_fail(r->devid!=-1);
118
r->sndcard=snd_card_manager_get_card(snd_card_manager,r->devid);
119
g_return_if_fail(r->sndcard!=NULL);
120
/* open the device for an audio telephony signal with minimum latency */
121
snd_card_open_r(r->sndcard,16,0,r->freq);
122
r->gran=(512*r->freq)/8000;
126
void ms_oss_read_stop(MSOssRead *w)
128
g_return_if_fail(w->devid!=-1);
129
g_return_if_fail(w->sndcard!=NULL);
130
snd_card_close_r(w->sndcard);
135
void ms_oss_read_setup(MSOssRead *f, MSSync *sync)
138
ms_oss_read_start(f);
142
gint ms_oss_read_set_device(MSOssRead *r,gint devid)