2
* mpc123 - Musepack Console audio player
3
* Copyright (C) 2005 Fernando Vezzosi <fvezzosi at masobit.net>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
#include <mpcdec/config_types.h>
26
#include <mpcdec/mpcdec.h>
29
static mpc_int32_t mpc123_file_read(void *t, void *ptr, mpc_int32_t size){
30
reader_data *data=(reader_data*) t;
31
return read(data->fd, ptr, size);
35
static mpc_bool_t mpc123_file_seek(void *t, mpc_int32_t offset){
36
reader_data *data=(reader_data*) t;
37
lseek(data->fd, offset, SEEK_SET);
41
static mpc_int32_t mpc123_file_tell(void *t){
42
reader_data *data=(reader_data*) t;
43
return lseek(data->fd, 0, SEEK_CUR);
47
static mpc_int32_t mpc123_file_get_size(void *t){
48
reader_data *data=(reader_data*) t;
49
off_t old_offset=lseek(data->fd, 0, SEEK_CUR); /* save old pos */
50
mpc_int32_t toret=lseek(data->fd, 0, SEEK_END);
52
/* restore old situation */
53
lseek(data->fd, old_offset, SEEK_SET);
58
/* on an empty disk, you can seek() forever */
59
static mpc_bool_t mpc123_file_canseek(void *t){
64
* this provides raw data to the decoder library
67
mpc_reader mpc123_file_reader={
68
.read=mpc123_file_read,
69
.seek=mpc123_file_seek,
70
.tell=mpc123_file_tell,
71
.get_size=mpc123_file_get_size,
72
.canseek=mpc123_file_canseek,
73
.data=NULL /* reader_data * data */