From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/decoder/cddaPlugin.cpp | 150 +++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 mpeglib/lib/decoder/cddaPlugin.cpp (limited to 'mpeglib/lib/decoder/cddaPlugin.cpp') diff --git a/mpeglib/lib/decoder/cddaPlugin.cpp b/mpeglib/lib/decoder/cddaPlugin.cpp new file mode 100644 index 00000000..fe84986b --- /dev/null +++ b/mpeglib/lib/decoder/cddaPlugin.cpp @@ -0,0 +1,150 @@ +/* + splay player plugin + Copyright (C) 1999 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 + + */ + + +#include "cddaPlugin.h" + +#ifdef CDDA_PARANOIA + +#include + +#include + +using namespace std; + +typedef int16_t size16; +typedef int32_t size32; + +extern "C" { +#include +#include +} + + +CDDAPlugin::CDDAPlugin() { +} + + +CDDAPlugin::~CDDAPlugin() { +} + + +// here we can config our decoder with special flags +void CDDAPlugin::config(const char* key,const char* value,void* user_data) { + DecoderPlugin::config(key,value,user_data); +} + + + +void CDDAPlugin::decoder_loop() { + + if (input == NULL) { + cout << "CDDAPlugin::decoder_loop input is NULL"<audioInit(); + TimeStamp* stamp; + char buf[CD_FRAMESIZE_RAW*4]; + int len=0; + // start decoding + while(runCheck()) { + + switch(streamState) { + case _STREAM_STATE_FIRST_INIT : + output->audioSetup(44100,1,0,0,16); + output->audioOpen(); + setStreamState(_STREAM_STATE_PLAY); + len=getTotalLength(); + pluginInfo->setLength(len); + output->writeInfo(pluginInfo); + break; + case _STREAM_STATE_INIT : + setStreamState(_STREAM_STATE_PLAY); + break; + case _STREAM_STATE_PLAY : { + // decode + int read=input->read(buf,2*CD_FRAMESIZE_RAW); + int pos=input->getBytePosition(); + stamp=input->getTimeStamp(pos); + output->audioPlay(stamp,stamp,buf,read); + break; + } + case _STREAM_STATE_WAIT_FOR_END: + // exit while loop + lDecoderLoop=false; + break; + default: + cout << "unknown stream state:"<audioFlush(); +} + +// splay can seek in streams +int CDDAPlugin::seek_impl(int second) { + int bytes_per_second; + int seconds; + int back; + float frequence=44100; + int bits=16; + int channels=2; + + bytes_per_second = (int)(frequence * channels * (bits / 8)); + + + + seconds = bytes_per_second * second; + cout << "seek to :"<seek(seconds); + + return true; +} + + +int CDDAPlugin::getTotalLength() { + shutdownLock(); + float wavfilesize; + int back=0; + float frequence=44100; + if (input == NULL) { + shutdownUnlock(); + return 0; + } + wavfilesize = input->getByteLength(); + int bits=16; + int channels=2; + if (bits == 16) { + wavfilesize=wavfilesize/2; + } + if (channels==2) { + wavfilesize=wavfilesize/2; + } + if (frequence != 0) { + back=(int)(wavfilesize/frequence); + } + shutdownUnlock(); + return back; +} + + + + +#endif +//CDDA_PARANOIA + -- cgit v1.2.1