summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 19:21:08 (UTC)
committer llornkcor <llornkcor>2002-04-20 19:21:08 (UTC)
commit0169070eeca0ef41d33c4e8b2feee9c90f34f6ae (patch) (unidiff)
tree638ccb275c98056b4a9ca9ec09d15b1a7636bb6c
parentb8bdd6ceaab890f8b35492a11e13bcdb101b1220 (diff)
downloadopie-0169070eeca0ef41d33c4e8b2feee9c90f34f6ae.zip
opie-0169070eeca0ef41d33c4e8b2feee9c90f34f6ae.tar.gz
opie-0169070eeca0ef41d33c4e8b2feee9c90f34f6ae.tar.bz2
MediaPlayer to OpiePlayer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 0fcc230..7bb6541 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -56,129 +56,129 @@ extern "C" {
56 56
57 57
58#define MPEG_BUFFER_SIZE 65536 58#define MPEG_BUFFER_SIZE 65536
59//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 59//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192
60//#define debugMsg(a) qDebug(a) 60//#define debugMsg(a) qDebug(a)
61#define debugMsg(a) 61#define debugMsg(a)
62 62
63 63
64class Input { 64class Input {
65public: 65public:
66 char const *path; 66 char const *path;
67 int fd; 67 int fd;
68#if defined(HAVE_MMAP) 68#if defined(HAVE_MMAP)
69 void *fdm; 69 void *fdm;
70#endif 70#endif
71 unsigned char *data; 71 unsigned char *data;
72 unsigned long length; 72 unsigned long length;
73 int eof; 73 int eof;
74}; 74};
75 75
76 76
77class Output { 77class Output {
78public: 78public:
79 mad_fixed_t attenuate; 79 mad_fixed_t attenuate;
80 struct filter *filters; 80 struct filter *filters;
81 unsigned int channels_in; 81 unsigned int channels_in;
82 unsigned int channels_out; 82 unsigned int channels_out;
83 unsigned int speed_in; 83 unsigned int speed_in;
84 unsigned int speed_out; 84 unsigned int speed_out;
85 const char *path; 85 const char *path;
86}; 86};
87 87
88 88
89# if defined(HAVE_MMAP) 89# if defined(HAVE_MMAP)
90static void *map_file(int fd, unsigned long *length) 90static void *map_file(int fd, unsigned long *length)
91{ 91{
92 void *fdm; 92 void *fdm;
93 93
94 *length += MAD_BUFFER_GUARD; 94 *length += MAD_BUFFER_GUARD;
95 95
96 fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0); 96 fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0);
97 if (fdm == MAP_FAILED) 97 if (fdm == MAP_FAILED)
98 return 0; 98 return 0;
99 99
100# if defined(HAVE_MADVISE) 100# if defined(HAVE_MADVISE)
101 madvise(fdm, *length, MADV_SEQUENTIAL); 101 madvise(fdm, *length, MADV_SEQUENTIAL);
102# endif 102# endif
103 103
104 return fdm; 104 return fdm;
105} 105}
106 106
107 107
108static int unmap_file(void *fdm, unsigned long length) 108static int unmap_file(void *fdm, unsigned long length)
109{ 109{
110 if (munmap(fdm, length) == -1) 110 if (munmap(fdm, length) == -1)
111 return -1; 111 return -1;
112 112
113 return 0; 113 return 0;
114} 114}
115# endif 115# endif
116 116
117 117
118static inline QString tr( const char *str ) { 118static inline QString tr( const char *str ) {
119 // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin 119 // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin
120 return qApp->translate( "MediaPlayer", str, "libmad strings for mp3 file info" ); 120 return qApp->translate( "OpiePlayer", str, "libmad strings for mp3 file info" );
121} 121}
122 122
123 123
124class LibMadPluginData { 124class LibMadPluginData {
125public: 125public:
126 Input input; 126 Input input;
127 Output output; 127 Output output;
128 int bad_last_frame; 128 int bad_last_frame;
129 struct mad_stream stream; 129 struct mad_stream stream;
130 struct mad_frame frame; 130 struct mad_frame frame;
131 struct mad_synth synth; 131 struct mad_synth synth;
132 bool flush; 132 bool flush;
133}; 133};
134 134
135 135
136LibMadPlugin::LibMadPlugin() { 136LibMadPlugin::LibMadPlugin() {
137 d = new LibMadPluginData; 137 d = new LibMadPluginData;
138 d->input.fd = 0; 138 d->input.fd = 0;
139#if defined(HAVE_MMAP) 139#if defined(HAVE_MMAP)
140 d->input.fdm = 0; 140 d->input.fdm = 0;
141#endif 141#endif
142 d->input.data = 0; 142 d->input.data = 0;
143 d->flush = TRUE; 143 d->flush = TRUE;
144 info = tr( "No Song Open" ); 144 info = tr( "No Song Open" );
145} 145}
146 146
147 147
148LibMadPlugin::~LibMadPlugin() { 148LibMadPlugin::~LibMadPlugin() {
149 close(); 149 close();
150 delete d; 150 delete d;
151} 151}
152 152
153 153
154bool LibMadPlugin::isFileSupported( const QString& path ) { 154bool LibMadPlugin::isFileSupported( const QString& path ) {
155 debugMsg( "LibMadPlugin::isFileSupported" ); 155 debugMsg( "LibMadPlugin::isFileSupported" );
156 156
157 // Mpeg file extensions 157 // Mpeg file extensions
158 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3" 158 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3"
159 // Other media extensions 159 // Other media extensions
160 // "wav","mid","mod","s3m","ogg","avi","mov","sid" 160 // "wav","mid","mod","s3m","ogg","avi","mov","sid"
161 161
162 char *ext = strrchr( path.latin1(), '.' ); 162 char *ext = strrchr( path.latin1(), '.' );
163 163
164 // Test file extension 164 // Test file extension
165 if ( ext ) { 165 if ( ext ) {
166 if ( strncasecmp(ext, ".mp2", 4) == 0 ) 166 if ( strncasecmp(ext, ".mp2", 4) == 0 )
167 return TRUE; 167 return TRUE;
168 if ( strncasecmp(ext, ".mp3", 4) == 0 ) 168 if ( strncasecmp(ext, ".mp3", 4) == 0 )
169 return TRUE; 169 return TRUE;
170 } 170 }
171 // UGLY - just for fast testing 171 // UGLY - just for fast testing
172 if ( path.left(4) == "http") { 172 if ( path.left(4) == "http") {
173 return TRUE; 173 return TRUE;
174 } 174 }
175 175
176 176
177 return FALSE; 177 return FALSE;
178} 178}
179 179
180 180
181int LibMadPlugin::tcp_open(char *address, int port) { 181int LibMadPlugin::tcp_open(char *address, int port) {
182 struct sockaddr_in stAddr; 182 struct sockaddr_in stAddr;
183 struct hostent *host; 183 struct hostent *host;
184 int sock; 184 int sock;