MP3 Player without external hardware MP3 Player without external hardware. A software based MP3 player based on a modified version of libmad. Mono output (at the moment) via AnalogOut. Files are read from an USB drive. This is a demo program, it plays only one file at the moment. Documentation is in "main.cpp" and "config.h"
decoder.h@0:7627c79db971, 2010-11-26 (annotated)
- Committer:
- Gruenfrosch
- Date:
- Fri Nov 26 12:18:30 2010 +0000
- Revision:
- 0:7627c79db971
- Child:
- 2:f28cf0afd021
First Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gruenfrosch | 0:7627c79db971 | 1 | /* |
Gruenfrosch | 0:7627c79db971 | 2 | * libmad - MPEG audio decoder library |
Gruenfrosch | 0:7627c79db971 | 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
Gruenfrosch | 0:7627c79db971 | 4 | * |
Gruenfrosch | 0:7627c79db971 | 5 | * This program is free software; you can redistribute it and/or modify |
Gruenfrosch | 0:7627c79db971 | 6 | * it under the terms of the GNU General Public License as published by |
Gruenfrosch | 0:7627c79db971 | 7 | * the Free Software Foundation; either version 2 of the License, or |
Gruenfrosch | 0:7627c79db971 | 8 | * (at your option) any later version. |
Gruenfrosch | 0:7627c79db971 | 9 | * |
Gruenfrosch | 0:7627c79db971 | 10 | * This program is distributed in the hope that it will be useful, |
Gruenfrosch | 0:7627c79db971 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Gruenfrosch | 0:7627c79db971 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Gruenfrosch | 0:7627c79db971 | 13 | * GNU General Public License for more details. |
Gruenfrosch | 0:7627c79db971 | 14 | * |
Gruenfrosch | 0:7627c79db971 | 15 | * You should have received a copy of the GNU General Public License |
Gruenfrosch | 0:7627c79db971 | 16 | * along with this program; if not, write to the Free Software |
Gruenfrosch | 0:7627c79db971 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Gruenfrosch | 0:7627c79db971 | 18 | * |
Gruenfrosch | 0:7627c79db971 | 19 | * $Id: decoder.h,v 1.1 2010/11/23 20:12:57 andy Exp $ |
Gruenfrosch | 0:7627c79db971 | 20 | */ |
Gruenfrosch | 0:7627c79db971 | 21 | |
Gruenfrosch | 0:7627c79db971 | 22 | # ifndef LIBMAD_DECODER_H |
Gruenfrosch | 0:7627c79db971 | 23 | # define LIBMAD_DECODER_H |
Gruenfrosch | 0:7627c79db971 | 24 | |
Gruenfrosch | 0:7627c79db971 | 25 | # include "stream.h" |
Gruenfrosch | 0:7627c79db971 | 26 | # include "frame.h" |
Gruenfrosch | 0:7627c79db971 | 27 | # include "synth.h" |
Gruenfrosch | 0:7627c79db971 | 28 | |
Gruenfrosch | 0:7627c79db971 | 29 | enum mad_decoder_mode { |
Gruenfrosch | 0:7627c79db971 | 30 | MAD_DECODER_MODE_SYNC = 0, |
Gruenfrosch | 0:7627c79db971 | 31 | MAD_DECODER_MODE_ASYNC |
Gruenfrosch | 0:7627c79db971 | 32 | }; |
Gruenfrosch | 0:7627c79db971 | 33 | |
Gruenfrosch | 0:7627c79db971 | 34 | enum mad_flow { |
Gruenfrosch | 0:7627c79db971 | 35 | MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ |
Gruenfrosch | 0:7627c79db971 | 36 | MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ |
Gruenfrosch | 0:7627c79db971 | 37 | MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ |
Gruenfrosch | 0:7627c79db971 | 38 | MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ |
Gruenfrosch | 0:7627c79db971 | 39 | }; |
Gruenfrosch | 0:7627c79db971 | 40 | |
Gruenfrosch | 0:7627c79db971 | 41 | struct mad_sync_s { |
Gruenfrosch | 0:7627c79db971 | 42 | struct mad_stream stream; |
Gruenfrosch | 0:7627c79db971 | 43 | struct mad_frame frame; |
Gruenfrosch | 0:7627c79db971 | 44 | struct mad_synth *synth; |
Gruenfrosch | 0:7627c79db971 | 45 | }; |
Gruenfrosch | 0:7627c79db971 | 46 | |
Gruenfrosch | 0:7627c79db971 | 47 | struct mad_decoder { |
Gruenfrosch | 0:7627c79db971 | 48 | enum mad_decoder_mode mode; |
Gruenfrosch | 0:7627c79db971 | 49 | |
Gruenfrosch | 0:7627c79db971 | 50 | int options; |
Gruenfrosch | 0:7627c79db971 | 51 | |
Gruenfrosch | 0:7627c79db971 | 52 | struct { |
Gruenfrosch | 0:7627c79db971 | 53 | long pid; |
Gruenfrosch | 0:7627c79db971 | 54 | int in; |
Gruenfrosch | 0:7627c79db971 | 55 | int out; |
Gruenfrosch | 0:7627c79db971 | 56 | } async; |
Gruenfrosch | 0:7627c79db971 | 57 | |
Gruenfrosch | 0:7627c79db971 | 58 | struct mad_sync_s *sync; |
Gruenfrosch | 0:7627c79db971 | 59 | |
Gruenfrosch | 0:7627c79db971 | 60 | void *cb_data; |
Gruenfrosch | 0:7627c79db971 | 61 | |
Gruenfrosch | 0:7627c79db971 | 62 | enum mad_flow (*input_func)(void *, struct mad_stream *); |
Gruenfrosch | 0:7627c79db971 | 63 | enum mad_flow (*header_func)(void *, struct mad_header const *); |
Gruenfrosch | 0:7627c79db971 | 64 | enum mad_flow (*filter_func)(void *, |
Gruenfrosch | 0:7627c79db971 | 65 | struct mad_stream const *, struct mad_frame *); |
Gruenfrosch | 0:7627c79db971 | 66 | enum mad_flow (*output_func)(void *, |
Gruenfrosch | 0:7627c79db971 | 67 | struct mad_header const *, struct mad_pcm *); |
Gruenfrosch | 0:7627c79db971 | 68 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); |
Gruenfrosch | 0:7627c79db971 | 69 | enum mad_flow (*message_func)(void *, void *, unsigned int *); |
Gruenfrosch | 0:7627c79db971 | 70 | }; |
Gruenfrosch | 0:7627c79db971 | 71 | |
Gruenfrosch | 0:7627c79db971 | 72 | void mad_decoder_init(struct mad_decoder *, void *, |
Gruenfrosch | 0:7627c79db971 | 73 | enum mad_flow (*)(void *, struct mad_stream *), |
Gruenfrosch | 0:7627c79db971 | 74 | enum mad_flow (*)(void *, struct mad_header const *), |
Gruenfrosch | 0:7627c79db971 | 75 | enum mad_flow (*)(void *, |
Gruenfrosch | 0:7627c79db971 | 76 | struct mad_stream const *, |
Gruenfrosch | 0:7627c79db971 | 77 | struct mad_frame *), |
Gruenfrosch | 0:7627c79db971 | 78 | enum mad_flow (*)(void *, |
Gruenfrosch | 0:7627c79db971 | 79 | struct mad_header const *, |
Gruenfrosch | 0:7627c79db971 | 80 | struct mad_pcm *), |
Gruenfrosch | 0:7627c79db971 | 81 | enum mad_flow (*)(void *, |
Gruenfrosch | 0:7627c79db971 | 82 | struct mad_stream *, |
Gruenfrosch | 0:7627c79db971 | 83 | struct mad_frame *), |
Gruenfrosch | 0:7627c79db971 | 84 | enum mad_flow (*)(void *, void *, unsigned int *)); |
Gruenfrosch | 0:7627c79db971 | 85 | int mad_decoder_finish(struct mad_decoder *); |
Gruenfrosch | 0:7627c79db971 | 86 | |
Gruenfrosch | 0:7627c79db971 | 87 | # define mad_decoder_options(decoder, opts) \ |
Gruenfrosch | 0:7627c79db971 | 88 | ((void) ((decoder)->options = (opts))) |
Gruenfrosch | 0:7627c79db971 | 89 | |
Gruenfrosch | 0:7627c79db971 | 90 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); |
Gruenfrosch | 0:7627c79db971 | 91 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); |
Gruenfrosch | 0:7627c79db971 | 92 | |
Gruenfrosch | 0:7627c79db971 | 93 | # endif |