rework proxy scaler, fix crop-gui coord, video_data tweak for proxy_format
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / audiompeg.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "audiompeg.h"
23 #include "condition.h"
24 #include "devicempeginput.h"
25
26
27
28
29 AudioMPEG::AudioMPEG(AudioDevice *device)
30  : AudioLowLevel(device)
31 {
32         audio_open = 0;
33         mpeg_input = 0;
34 }
35
36 AudioMPEG::~AudioMPEG()
37 {
38         close_all();
39 }
40
41
42 int AudioMPEG::open_input()
43 {
44         /* this is more like - try to open, since a broadcast signal may */
45         /*  take time to lock, or not even be there at all.  On success, */
46         /*  it may update the input config with the actual stream config. */
47         int ret = 1;
48         if( !mpeg_input )
49         {
50                 mpeg_input = get_mpeg_input();
51                 if( !mpeg_input ) return 1;
52         }
53         device->in_samplerate = device->in_channels = device->in_bits = 0;
54         if( !mpeg_input->src_stream() ) {
55                 int samplerate = mpeg_input->audio_sample_rate();
56                 int channels = mpeg_input->audio_channels();
57                 int bits = mpeg_input->audio_sample_bits();
58                 device->auto_update(channels, samplerate, bits);
59                 audio_open = 1;
60                 mpeg_input->src_unlock();
61                 ret = 0;
62         }
63         return ret;
64 }
65
66 int AudioMPEG::close_all()
67 {
68         audio_open = 0;
69         if( mpeg_input ) {
70                 mpeg_input->put_mpeg_audio();
71                 mpeg_input = 0;
72         }
73         return 0;
74 }
75
76 int AudioMPEG::write_buffer(char *buffer, int size)
77 {
78         printf("AudioMPEG::write_position 10\n");
79         return 0;
80 }
81
82 int AudioMPEG::read_buffer(char *buffer, int size)
83 {
84         if( !audio_open ) { open_input(); return -1; }
85         int result = mpeg_input->read_audio(buffer,size);
86 //printf("AudioMPEG::read_buffer(%p,%d) = %d\n", buffer, size, result);
87         return result;
88 }
89
90 double AudioMPEG::device_timestamp()
91 {
92         if( !audio_open || !mpeg_input ) return -1.;
93         return mpeg_input->audio_timestamp();
94 }
95
96 int AudioMPEG::start_toc(const char *path, const char *toc_path)
97 {
98         int result = mpeg_input ? mpeg_input->start_toc(path, toc_path) : -1;
99         return result;
100 }
101
102 int AudioMPEG::start_record(int fd, int bsz)
103 {
104         int result = mpeg_input ? mpeg_input->start_record(fd, bsz) : -1;
105         return result;
106 }
107
108 int AudioMPEG::stop_record()
109 {
110         int result = mpeg_input ? mpeg_input->stop_record() : -1;
111         return result;
112 }
113
114 int AudioMPEG::total_audio_channels()
115 {
116         int result = mpeg_input ? mpeg_input->total_audio_channels() : 0;
117         return result;
118 }
119
120 int64_t AudioMPEG::device_position()
121 {
122         printf("AudioMPEG::device_position 10\n");
123         return 0;
124 }
125
126 int AudioMPEG::flush_device()
127 {
128         printf("AudioMPEG::flush_device 10\n");
129         return 0;
130 }
131
132 int AudioMPEG::interrupt_playback()
133 {
134         printf("AudioMPEG::interrupt_playback 10\n");
135         return 0;
136 }
137
138
139
140
141