You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.5 KiB
74 lines
1.5 KiB
/*
|
|
decoder interface for the splay mp3 decoder.
|
|
Copyright (C) 2001 Martin Vogt
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU Library General Public License as published by
|
|
the Free Software Foundation.
|
|
|
|
For more information look at the file COPYRIGHT in this package
|
|
|
|
*/
|
|
|
|
#define _FROM_SOURCE
|
|
#include "dxHead.h"
|
|
#include "splayDecoder.h"
|
|
#include "mpegsound.h"
|
|
|
|
|
|
|
|
SplayDecoder::SplayDecoder() {
|
|
header = new MpegAudioHeader();
|
|
stream = new MpegAudioStream();
|
|
server = new Mpegtoraw(stream,header);
|
|
|
|
xHeadData=new XHEADDATA();
|
|
xHeadData->toc=new unsigned char[101];
|
|
dump=new Dump();
|
|
}
|
|
|
|
|
|
SplayDecoder::~SplayDecoder() {
|
|
delete [] xHeadData->toc;
|
|
delete xHeadData;
|
|
|
|
delete server;
|
|
delete header;
|
|
delete stream;
|
|
delete dump;
|
|
}
|
|
|
|
|
|
|
|
int SplayDecoder::decode(unsigned char* ptr, int len,AudioFrame* dest) {
|
|
int back;
|
|
// fist setup the stream and the 4 bytes header info;
|
|
//dump->dump((char*)ptr,len);
|
|
if (header->parseHeader(ptr) == false) {
|
|
return false;
|
|
}
|
|
// maybe a Xing Header?
|
|
if (len >= 152+4) {
|
|
int lXing=GetXingHeader(xHeadData,(unsigned char*)ptr);
|
|
if (lXing) {
|
|
return false;
|
|
}
|
|
}
|
|
stream->setFrame(ptr+4,len-4);
|
|
back=server->decode(dest);
|
|
|
|
return back;
|
|
|
|
}
|
|
|
|
|
|
void SplayDecoder::config(const char* key,const char* val,void* ) {
|
|
if (strcmp(key,"2")==0) {
|
|
server->setDownSample(atoi(val));
|
|
}
|
|
if (strcmp(key,"m")==0) {
|
|
server->setStereo(atoi(val));
|
|
}
|
|
}
|
|
|