Mercurial > mplayer.hg
annotate libmpdemux/audio_in.c @ 7099:0b70f3dc34eb
Applied patch by Andras Mohari <mayday@varoshaza.nagyatad.hu>, with some
small additions.
* Replaced <UL> with <OL> where it made sense (to me :-)).
* Moved "Developer Cries" into the appendix (as Appendix F)
with s/Flame Wars/Developer Cries/ and
s/In medias res/Developer Cries/.
* Renamed "Appendix X" to "Appendix E".
* Put a "Hint" inside <BLOCKQUOTE>.
* Converted 3-pass encoding and mga_vid installation
instructions to lists.
* Converted options tables (video eq, SDL, fbdev, VESA, DXR3, TV input,
DivX4Linux, AAlib) to <DL> lists.
* The "sections" for MPsub and INSTALLING OSD are numbered and displayed
in the TOC now.
* Changed the text inside some <H4> tags.
author | diego |
---|---|
date | Tue, 27 Aug 2002 18:06:07 +0000 |
parents | aaac9080b8a3 |
children | 13fcab6fde41 |
rev | line source |
---|---|
7060
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
1 #include "config.h" |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
2 #include "audio_in.h" |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
3 #include "mp_msg.h" |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
4 #include <stdio.h> |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
5 #include <stdlib.h> |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
6 #include <string.h> |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
7 #include <errno.h> |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
8 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
9 // sanitizes ai structure before calling other functions |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
10 int audio_in_init(audio_in_t *ai, int type) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
11 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
12 ai->type = type; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
13 ai->setup = 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
14 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
15 ai->channels = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
16 ai->samplerate = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
17 ai->blocksize = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
18 ai->bytes_per_sample = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
19 ai->samplesize = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
20 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
21 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
22 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
23 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
24 ai->alsa.handle = NULL; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
25 ai->alsa.log = NULL; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
26 ai->alsa.device = strdup("default"); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
27 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
28 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
29 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
30 ai->oss.audio_fd = -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
31 ai->oss.device = strdup("/dev/dsp"); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
32 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
33 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
34 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
35 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
36 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
37 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
38 int audio_in_setup(audio_in_t *ai) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
39 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
40 int err; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
41 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
42 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
43 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
44 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
45 if (ai_alsa_init(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
46 ai->setup = 1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
47 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
48 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
49 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
50 if (ai_oss_init(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
51 ai->setup = 1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
52 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
53 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
54 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
55 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
56 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
57 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
58 int audio_in_set_samplerate(audio_in_t *ai, int rate) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
59 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
60 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
61 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
62 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
63 ai->req_samplerate = rate; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
64 if (!ai->setup) return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
65 if (ai_alsa_setup(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
66 return ai->samplerate; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
67 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
68 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
69 ai->req_samplerate = rate; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
70 if (!ai->setup) return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
71 if (ai_oss_set_samplerate(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
72 return ai->samplerate; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
73 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
74 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
75 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
76 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
77 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
78 int audio_in_set_channels(audio_in_t *ai, int channels) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
79 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
80 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
81 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
82 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
83 ai->req_channels = channels; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
84 if (!ai->setup) return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
85 if (ai_alsa_setup(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
86 return ai->channels; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
87 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
88 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
89 ai->req_channels = channels; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
90 if (!ai->setup) return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
91 if (ai_oss_set_channels(ai) < 0) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
92 return ai->channels; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
93 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
94 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
95 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
96 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
97 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
98 int audio_in_set_device(audio_in_t *ai, char *device) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
99 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
100 int i; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
101 if (ai->setup) return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
102 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
103 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
104 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
105 if (ai->alsa.device) free(ai->alsa.device); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
106 ai->alsa.device = strdup(device); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
107 /* mplayer cannot handle colons in arguments */ |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
108 for (i = 0; i < strlen(ai->alsa.device); i++) { |
7070
aaac9080b8a3
v4l capture update by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
7060
diff
changeset
|
109 if (ai->alsa.device[i] == '.') ai->alsa.device[i] = ':'; |
7060
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
110 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
111 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
112 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
113 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
114 if (ai->oss.device) free(ai->oss.device); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
115 ai->oss.device = strdup(device); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
116 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
117 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
118 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
119 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
120 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
121 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
122 int audio_in_uninit(audio_in_t *ai) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
123 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
124 if (ai->setup) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
125 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
126 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
127 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
128 if (ai->alsa.log) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
129 snd_output_close(ai->alsa.log); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
130 if (ai->alsa.handle) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
131 snd_pcm_close(ai->alsa.handle); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
132 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
133 ai->setup = 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
134 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
135 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
136 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
137 close(ai->oss.audio_fd); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
138 ai->setup = 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
139 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
140 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
141 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
142 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
143 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
144 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
145 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
146 int audio_in_start_capture(audio_in_t *ai) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
147 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
148 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
149 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
150 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
151 return snd_pcm_start(ai->alsa.handle); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
152 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
153 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
154 return 0; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
155 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
156 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
157 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
158 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
159 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
160 int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer) |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
161 { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
162 int ret; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
163 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
164 switch (ai->type) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
165 #ifdef HAVE_ALSA9 |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
166 case AUDIO_IN_ALSA: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
167 ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
168 if (ret != ai->alsa.chunk_size) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
169 if (ret < 0) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
170 mp_msg(MSGT_TV, MSGL_ERR, "\nerror reading audio: %s\n", snd_strerror(ret)); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
171 } else { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
172 mp_msg(MSGT_TV, MSGL_ERR, "\nnot enough audio samples!\n"); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
173 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
174 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
175 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
176 return ret; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
177 #endif |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
178 case AUDIO_IN_OSS: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
179 ret = read(ai->oss.audio_fd, buffer, ai->blocksize); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
180 if (ret != ai->blocksize) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
181 if (ret < 0) { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
182 mp_msg(MSGT_TV, MSGL_ERR, "\nerror reading audio: %s\n", strerror(errno)); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
183 } else { |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
184 mp_msg(MSGT_TV, MSGL_ERR, "\nnot enough audio samples!\n"); |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
185 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
186 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
187 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
188 return ret; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
189 default: |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
190 return -1; |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
191 } |
b14880a6cccb
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
diff
changeset
|
192 } |