Mercurial > pidgin.yaz
annotate src/mediastreamer/msossread.c @ 12301:39fca2edf7da
[gaim-migrate @ 14605]
I only caught this as I was committing, and besides I forgot to mention what
sadrul's patch did. It puts the emblem for the active status on the accounts
in the Accounts menu (he put them in the Remove menu as well but that felt
wrong to me.)
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Sat, 03 Dec 2005 06:50:41 +0000 |
parents | 1c771536a032 |
children |
rev | line source |
---|---|
12024 | 1 /* |
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 | |
5 | |
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. | |
10 | |
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. | |
15 | |
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 | |
19 */ | |
20 | |
21 #include "msossread.h" | |
22 #include "mssync.h" | |
23 #include <unistd.h> | |
24 #include <errno.h> | |
25 #include <sys/time.h> | |
26 #include <sys/types.h> | |
27 | |
28 MSFilterInfo oss_read_info={ | |
29 "OSS read", | |
30 0, | |
31 MS_FILTER_AUDIO_IO, | |
32 ms_oss_read_new, | |
33 NULL | |
34 }; | |
35 | |
36 static MSOssReadClass *msossreadclass=NULL; | |
37 | |
38 MSFilter * ms_oss_read_new() | |
39 { | |
40 MSOssRead *w; | |
41 | |
42 if (msossreadclass==NULL) | |
43 { | |
44 msossreadclass=g_new(MSOssReadClass,1); | |
45 ms_oss_read_class_init( msossreadclass ); | |
46 } | |
47 | |
48 w=g_new(MSOssRead,1); | |
49 MS_FILTER(w)->klass=MS_FILTER_CLASS(msossreadclass); | |
50 ms_oss_read_init(w); | |
51 | |
52 return(MS_FILTER(w)); | |
53 } | |
54 | |
55 /* FOR INTERNAL USE*/ | |
56 void ms_oss_read_init(MSOssRead *w) | |
57 { | |
58 ms_sound_read_init(MS_SOUND_READ(w)); | |
59 MS_FILTER(w)->outfifos=w->f_outputs; | |
60 MS_FILTER(w)->outfifos[0]=NULL; | |
61 w->devid=0; | |
62 w->sndcard=NULL; | |
63 w->freq=8000; | |
64 } | |
65 | |
66 gint ms_oss_read_set_property(MSOssRead *f,MSFilterProperty prop, void *value) | |
67 { | |
68 switch(prop){ | |
69 case MS_FILTER_PROPERTY_FREQ: | |
70 f->freq=((gint*)value)[0]; | |
71 break; | |
12029
1c771536a032
[gaim-migrate @ 14322]
Gary Kramlich <grim@reaperworld.com>
parents:
12024
diff
changeset
|
72 case MS_FILTER_PROPERTY_BITRATE: |
1c771536a032
[gaim-migrate @ 14322]
Gary Kramlich <grim@reaperworld.com>
parents:
12024
diff
changeset
|
73 case MS_FILTER_PROPERTY_CHANNELS: |
1c771536a032
[gaim-migrate @ 14322]
Gary Kramlich <grim@reaperworld.com>
parents:
12024
diff
changeset
|
74 case MS_FILTER_PROPERTY_FMTP: |
1c771536a032
[gaim-migrate @ 14322]
Gary Kramlich <grim@reaperworld.com>
parents:
12024
diff
changeset
|
75 default: |
1c771536a032
[gaim-migrate @ 14322]
Gary Kramlich <grim@reaperworld.com>
parents:
12024
diff
changeset
|
76 break; |
12024 | 77 } |
78 return 0; | |
79 } | |
80 void ms_oss_read_class_init(MSOssReadClass *klass) | |
81 { | |
82 ms_sound_read_class_init(MS_SOUND_READ_CLASS(klass)); | |
83 MS_FILTER_CLASS(klass)->max_foutputs=1; /* one fifo output only */ | |
84 MS_FILTER_CLASS(klass)->setup=(MSFilterSetupFunc)ms_oss_read_setup; | |
85 MS_FILTER_CLASS(klass)->unsetup=(MSFilterSetupFunc)ms_oss_read_stop; | |
86 MS_FILTER_CLASS(klass)->process= (MSFilterProcessFunc)ms_oss_read_process; | |
87 MS_FILTER_CLASS(klass)->set_property=(MSFilterPropertyFunc)ms_oss_read_set_property; | |
88 MS_FILTER_CLASS(klass)->destroy= (MSFilterDestroyFunc)ms_oss_read_destroy; | |
89 MS_FILTER_CLASS(klass)->w_maxgran=MS_OSS_READ_MAX_GRAN; | |
90 MS_FILTER_CLASS(klass)->info=&oss_read_info; | |
91 MS_SOUND_READ_CLASS(klass)->set_device=(gint (*)(MSSoundRead*,gint))ms_oss_read_set_device; | |
92 MS_SOUND_READ_CLASS(klass)->start=(void (*)(MSSoundRead*))ms_oss_read_start; | |
93 MS_SOUND_READ_CLASS(klass)->stop=(void (*)(MSSoundRead*))ms_oss_read_stop; | |
94 ms_filter_class_set_name(MS_FILTER_CLASS(klass),"OssRead"); | |
95 //ms_filter_class_set_attr( MS_FILTER_CLASS(klass),FILTER_CAN_SYNC|FILTER_IS_SOURCE); | |
96 } | |
97 | |
98 void ms_oss_read_destroy( MSOssRead *obj) | |
99 { | |
100 g_free(obj); | |
101 } | |
102 | |
103 void ms_oss_read_process(MSOssRead *f) | |
104 { | |
105 MSFifo *fifo; | |
106 char *p; | |
107 fifo=f->f_outputs[0]; | |
108 | |
109 g_return_if_fail(f->sndcard!=NULL); | |
110 g_return_if_fail(f->gran>0); | |
111 | |
112 if (snd_card_can_read(f->sndcard)){ | |
113 int got; | |
114 ms_fifo_get_write_ptr(fifo,f->gran,(void**)&p); | |
115 g_return_if_fail(p!=NULL); | |
116 got=snd_card_read(f->sndcard,p,f->gran); | |
117 if (got>=0 && got!=f->gran) ms_fifo_update_write_ptr(fifo,got); | |
118 } | |
119 } | |
120 | |
121 | |
122 void ms_oss_read_start(MSOssRead *r) | |
123 { | |
124 g_return_if_fail(r->devid!=-1); | |
125 r->sndcard=snd_card_manager_get_card(snd_card_manager,r->devid); | |
126 g_return_if_fail(r->sndcard!=NULL); | |
127 /* open the device for an audio telephony signal with minimum latency */ | |
128 snd_card_open_r(r->sndcard,16,0,r->freq); | |
129 r->gran=(512*r->freq)/8000; | |
130 | |
131 } | |
132 | |
133 void ms_oss_read_stop(MSOssRead *w) | |
134 { | |
135 g_return_if_fail(w->devid!=-1); | |
136 g_return_if_fail(w->sndcard!=NULL); | |
137 snd_card_close_r(w->sndcard); | |
138 w->sndcard=NULL; | |
139 } | |
140 | |
141 | |
142 void ms_oss_read_setup(MSOssRead *f, MSSync *sync) | |
143 { | |
144 f->sync=sync; | |
145 ms_oss_read_start(f); | |
146 } | |
147 | |
148 | |
149 gint ms_oss_read_set_device(MSOssRead *r,gint devid) | |
150 { | |
151 r->devid=devid; | |
152 return 0; | |
153 } |