4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "audiompeg.h"
23 #include "condition.h"
24 #include "devicempeginput.h"
29 AudioMPEG::AudioMPEG(AudioDevice *device)
30 : AudioLowLevel(device)
36 AudioMPEG::~AudioMPEG()
42 int AudioMPEG::open_input()
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. */
50 mpeg_input = get_mpeg_input();
51 if( !mpeg_input ) return 1;
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);
60 mpeg_input->src_unlock();
66 int AudioMPEG::close_all()
70 mpeg_input->put_mpeg_audio();
76 int AudioMPEG::write_buffer(char *buffer, int size)
78 printf("AudioMPEG::write_position 10\n");
82 int AudioMPEG::read_buffer(char *buffer, int size)
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);
90 double AudioMPEG::device_timestamp()
92 if( !audio_open || !mpeg_input ) return -1.;
93 return mpeg_input->audio_timestamp();
96 int AudioMPEG::start_toc(const char *path, const char *toc_path)
98 int result = mpeg_input ? mpeg_input->start_toc(path, toc_path) : -1;
102 int AudioMPEG::start_record(int fd, int bsz)
104 int result = mpeg_input ? mpeg_input->start_record(fd, bsz) : -1;
108 int AudioMPEG::stop_record()
110 int result = mpeg_input ? mpeg_input->stop_record() : -1;
114 int AudioMPEG::total_audio_channels()
116 int result = mpeg_input ? mpeg_input->total_audio_channels() : 0;
120 int64_t AudioMPEG::device_position()
122 printf("AudioMPEG::device_position 10\n");
126 int AudioMPEG::flush_device()
128 printf("AudioMPEG::flush_device 10\n");
132 int AudioMPEG::interrupt_playback()
134 printf("AudioMPEG::interrupt_playback 10\n");