summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-01 13:20:47 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-01 13:20:47 +0000
commit2c7563f0049c14506b778e6887810d1ef4662c37 (patch)
tree0bf9972a9045cf23a493302b0dcec9da18827442
parentc12e4c1bf19c4018a08d2637f4233d5c701f7e19 (diff)
downloadvdr-plugin-muggle-2c7563f0049c14506b778e6887810d1ef4662c37.tar.gz
vdr-plugin-muggle-2c7563f0049c14506b778e6887810d1ef4662c37.tar.bz2
Ogg integration continued
- in mgPCMPlayer/vdr_player.c: - pass m_playing to mp3/ogg decoder (instead of filename) - mgPCMPlayer::getSourceFile moved to abstract data layer (mgContentItem) and made concrete in subclasses (mgGdTrack) - decoder classes now initialized by mgContentItems instead of filenames - mgOggDecoder: obtain audio properties from DB (channels, sampling rate via mgContentItem) git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/branches/ogg_player@137 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--TODO34
-rw-r--r--gd_content_interface.c2
-rw-r--r--vdr_decoder.c35
-rw-r--r--vdr_decoder.h15
-rw-r--r--vdr_decoder_mp3.c21
-rw-r--r--vdr_decoder_mp3.h4
-rw-r--r--vdr_decoder_ogg.c13
-rw-r--r--vdr_decoder_ogg.h2
-rw-r--r--vdr_player.c43
9 files changed, 66 insertions, 103 deletions
diff --git a/TODO b/TODO
index b97182f..ba33335 100644
--- a/TODO
+++ b/TODO
@@ -2,15 +2,12 @@ TODO File for Muggle
====================
Ogg/Vorbis decoder integration
-==============================
-- mgPCMPlayer::getSourceFile to be moved to mgContentItem class (abstract)
- and made concrete in subclasses
-- in mgPCMPlayer/vdr_player.c:
- - pass m_playing to mp3/ogg decoder (instead of filename)
-- mgOggDecoder: obtain audio properties from DB (via mgContentItem)
+------------------------------
+- mgDecoders::findDecoder: extend decoder detection
+- Think, whether type (mp3, ogg, flac) should be stored in database
Deployment
-==========
+----------
- Script to publish a version
- Checkout
- make dist
@@ -22,13 +19,13 @@ Deployment
- How to track bugs and feature requests?
Testing/bugs
-============
+------------
- Test execution of playlist commands
- Keep this? Test mgPCMPlayer::getSourceFile() for GD case (find)
- Test saving/loading playlists to database
Import
-======
+------
- Album
- Cover text
- Cover images (based on filename or tag)
@@ -45,7 +42,12 @@ Import
- Playlist from m3u
Code polishing
-==============
+--------------
+- Check for unnecessary log commands
+- Generate HTML documentation using doxygen,
+ - use dotty/gv for state machines of player
+ - make available online
+- Clean up mugglei
- Check for memory leaks
- Why do filters use pointers?
- Check for (reasonably) consistent usage of char*/string
@@ -56,17 +58,10 @@ Code polishing
- mgPlayer used what for?
- Could save IP/host name and associate last playlist loaded
-- Check for unnecessary log commands
-- Generate HTML documentation using doxygen,
- - use dotty/gv for state machines of player
- - make available online
-
- Check compatibility for 1.3.12
Short term items
================
-- Import existing m3u playlists (in import)
-- Import genres
OSD in general
--------------
@@ -168,6 +163,11 @@ Already Done
(most notably samplerate, no. channels)
- Extended mgContentItem with audio properties
- Extended mgGdTrack with audio properties (bitrate, samplerate, channels)
+ - in mgPCMPlayer/vdr_player.c:
+ - pass m_playing to mp3/ogg decoder (instead of filename)
+ - mgOggDecoder: obtain audio properties from DB (channels, sampling rate via mgContentItem)
+ - mgPCMPlayer::getSourceFile moved to abstract data layer (mgContentItem)
+ and made concrete in subclasses (mgGdTrack)
************************************************************
*
diff --git a/gd_content_interface.c b/gd_content_interface.c
index 6a9bc32..6c2f496 100644
--- a/gd_content_interface.c
+++ b/gd_content_interface.c
@@ -321,7 +321,7 @@ bool mgGdTrack::readData()
m_artist = row[0];
m_album = row[1];
m_title = row[2];
- m_mp3file = row[3];
+ m_mp3file = string( the_setup.ToplevelDir ) + row[3];
m_genre = row[4];
if( sscanf( row[5], "%d", &m_year) != 1 )
diff --git a/vdr_decoder.c b/vdr_decoder.c
index 8b4cf70..099ce32 100644
--- a/vdr_decoder.c
+++ b/vdr_decoder.c
@@ -3,11 +3,11 @@
* \brief A generic decoder for a VDR media plugin (muggle)
*
* \version $Revision: 1.2 $
- * \date $Date: 2004/05/28 15:29:18 $
+ * \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
- * \author Responsible author: $Author: lvw $
+ * \author Responsible author: $Author$
*
- * $Id: vdr_decoder.c,v 1.2 2004/05/28 15:29:18 lvw Exp $
+ * $Id$
*
* Adapted from:
* MP3/MPlayer plugin to VDR (C++)
@@ -23,13 +23,6 @@
#include <videodir.h>
#include <interface.h>
-// #include "common.h"
-// #include "data-mp3.h"
-// #include "decoder-core.h"
-// #include "decoder-mp3-stream.h"
-// #include "decoder-snd.h"
-// #include "decoder-ogg.h"
-
#include "vdr_decoder.h"
#include "vdr_decoder_mp3.h"
@@ -43,27 +36,29 @@ mgMediaType mgDecoders::getMediaType( string s )
return MT_MP3;
}
-mgDecoder *mgDecoders::findDecoder( string filename )
+mgDecoder *mgDecoders::findDecoder( mgContentItem *item )
{
mgDecoder *decoder = 0;
+ string filename = item->getSourceFile();
+
switch( getMediaType( filename ) )
{
case MT_MP3:
{
- // prepend filename with path to music library?? TODO
- printf( "mp3 file detected, launching mgMP3Decoder\n" );
- decoder = new mgMP3Decoder(filename);
+ decoder = new mgMP3Decoder( item );
} break;
-
+ #ifdef HAVE_VORBISFILE
+ case MT_OGG:
+ {
+ decoder = new mgOggDecoder( item );
+ } break;
+ #endif
/*
case MT_MP3_STREAM: decoder = new mgMP3StreamDecoder(full); break;
#ifdef HAVE_SNDFILE
case MT_SND: decoder = new cSndDecoder(full); break;
#endif
- #ifdef HAVE_VORBISFILE
- case MT_OGG: decoder = new mgOggDecoder(full); break;
- #endif
*/
default:
{
@@ -85,9 +80,9 @@ mgDecoder *mgDecoders::findDecoder( string filename )
// --- mgDecoder ----------------------------------------------------------------
-mgDecoder::mgDecoder(string filename)
+mgDecoder::mgDecoder( mgContentItem *item )
{
- m_filename = filename;
+ m_item = item;
m_locked = 0;
m_urgentLock = false;
m_playing = false;
diff --git a/vdr_decoder.h b/vdr_decoder.h
index 74b200e..0c3b145 100644
--- a/vdr_decoder.h
+++ b/vdr_decoder.h
@@ -3,11 +3,11 @@
* \brief A generic decoder for a VDR media plugin (muggle)
*
* \version $Revision: 1.2 $
- * \date $Date: 2004/05/28 15:29:18 $
+ * \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
- * \author Responsible author: $Author: lvw $
+ * \author Responsible author: $Author$
*
- * $Id: vdr_decoder.h,v 1.2 2004/05/28 15:29:18 lvw Exp $
+ * $Id$
*
* Adapted from
* MP3/MPlayer plugin to VDR (C++)
@@ -24,6 +24,8 @@
#define DEC_ID(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d))
+class mgContentItem;
+
// --------From decoder_core.h ------------------------------------
/*!
@@ -74,6 +76,9 @@ class mgDecoder
{
protected:
+ /*! \brief database handle to the track being decoded */
+ mgContentItem *m_item;
+
/*! \brief The currently playing file */
std::string m_filename;
@@ -99,11 +104,13 @@ protected:
public:
+ //@{
/*! \brief The constructor */
- mgDecoder( std::string filename );
+ mgDecoder( mgContentItem *item );
/*! \brief The destructor */
virtual ~mgDecoder();
+ //@}
/*! \brief Whether a decoder instance is able to play the given file */
virtual bool valid() = 0;
diff --git a/vdr_decoder_mp3.c b/vdr_decoder_mp3.c
index 436d7b6..e0b3ba1 100644
--- a/vdr_decoder_mp3.c
+++ b/vdr_decoder_mp3.c
@@ -3,11 +3,11 @@
* \brief An mp3 decoder for a VDR media plugin (muggle)
*
* \version $Revision: 1.2 $
- * \date $Date: 2004/05/28 15:29:19 $
+ * \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
- * \author Responsible author: $Author: lvw $
+ * \author Responsible author: $Author$
*
- * $Id: vdr_decoder_mp3.c,v 1.2 2004/05/28 15:29:19 lvw Exp $
+ * $Id$
*
* Adapted from
* MP3/MPlayer plugin to VDR (C++)
@@ -52,17 +52,16 @@ int mgMadStream(struct mad_stream *stream, mgStream *str)
// --- mgMP3Decoder -------------------------------------------------------------
-mgMP3Decoder::mgMP3Decoder(string filename, bool preinit)
- : mgDecoder(filename)
+mgMP3Decoder::mgMP3Decoder( mgContentItem *item, bool preinit)
+ : mgDecoder(item)
{
- MGLOG( "mgMP3Decoder::mgMP3Decoder" );
-
m_stream = 0;
m_isStream = false;
+ m_filename = item->getSourceFile();
if( preinit )
{
- m_stream = new mgStream( filename );
+ m_stream = new mgStream( m_filename );
}
m_madframe = 0;
m_madsynth = 0;
@@ -181,8 +180,6 @@ mgPlayInfo *mgMP3Decoder::playInfo()
bool mgMP3Decoder::start()
{
- MGLOG( "mgMP3Decoder::start" );
-
lock(true);
init();
m_playing = true;
@@ -219,8 +216,6 @@ bool mgMP3Decoder::start()
bool mgMP3Decoder::stop(void)
{
- MGLOG( "mgMP3Decoder::stop" );
-
lock();
if( m_playing )
@@ -234,8 +229,6 @@ bool mgMP3Decoder::stop(void)
struct mgDecode *mgMP3Decoder::done(eDecodeStatus status)
{
- // MGLOG( "mgMP3Decoder::done" );
-
m_ds.status = status;
m_ds.index = mad_timer_count( m_playtime, MAD_UNITS_MILLISECONDS );
m_ds.pcm = &m_madsynth->pcm;
diff --git a/vdr_decoder_mp3.h b/vdr_decoder_mp3.h
index a90a2fe..a0e142f 100644
--- a/vdr_decoder_mp3.h
+++ b/vdr_decoder_mp3.h
@@ -55,7 +55,7 @@ private:
} *m_frameinfo;
int m_framenum, m_framemax, m_errcount, m_mute;
- //
+
void init();
void clean();
@@ -78,7 +78,7 @@ public:
/*!
* \brief construct a decoder from a filename
*/
- mgMP3Decoder( std::string filename, bool preinit = true );
+ mgMP3Decoder( mgContentItem *item, bool preinit = true );
/*!
* \brief the destructor
diff --git a/vdr_decoder_ogg.c b/vdr_decoder_ogg.c
index c5ae3a8..d58a718 100644
--- a/vdr_decoder_ogg.c
+++ b/vdr_decoder_ogg.c
@@ -188,10 +188,11 @@ int mgOggFile::stream( short *buffer, int samples )
// --- mgOggDecoder -------------------------------------------------------------
-mgOggDecoder::mgOggDecoder( string filename )
- : mgDecoder( filename )
+mgOggDecoder::mgOggDecoder( mgContentItem *item )
+ : mgDecoder( item )
{
- m_file = new mgOggFile( filename );
+ m_filename = item->getSourceFile;
+ m_file = new mgOggFile( m_filename );
m_pcm = 0;
init();
}
@@ -260,7 +261,7 @@ bool mgOggDecoder::start()
/* d(printf("ogg: open rate=%d channels=%d seek=%d\n",
info.SampleFreq,info.Channels,file.CanSeek()))
*/
- if( info.channels <= 2 )
+ if( m_item->channels() <= 2 )
{
unlock();
return true;
@@ -320,8 +321,8 @@ struct Decode *mgOggDecoder::Decode(void)
}
// TODO
- pcm->samplerate = info.SampleFreq; // from database
- pcm->channels = info.Channels; // from database
+ pcm->samplerate = m_item->getSampleRate(); // from database
+ pcm->channels = m_item->getChannels(); // from database
n /= pcm->channels;
pcm->length = n;
diff --git a/vdr_decoder_ogg.h b/vdr_decoder_ogg.h
index ce8fbee..d1bbc93 100644
--- a/vdr_decoder_ogg.h
+++ b/vdr_decoder_ogg.h
@@ -38,7 +38,7 @@ class mgOggDecoder : public mgDecoder
public:
- mgOggDecoder( std::string filename );
+ mgOggDecoder( mgContentItem *item );
~mgOggDecoder();
virtual mgPlayInfo *playInfo();
diff --git a/vdr_player.c b/vdr_player.c
index 105072b..5cde3fe 100644
--- a/vdr_player.c
+++ b/vdr_player.c
@@ -3,11 +3,11 @@
* \brief A generic PCM player for a VDR media plugin (muggle)
*
* \version $Revision: 1.7 $
- * \date $Date: 2004/07/27 20:50:54 $
+ * \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
- * \author Responsible author: $Author: lvw $
+ * \author Responsible author: $Author$
*
- * $Id: vdr_player.c,v 1.7 2004/07/27 20:50:54 lvw Exp $
+ * $Id$
*
* Adapted from
* MP3/MPlayer plugin to VDR (C++)
@@ -176,7 +176,6 @@ private:
void SetPlayMode(ePlayMode mode);
void WaitPlayMode(ePlayMode mode, bool inv);
- string getSourceFile();
protected:
virtual void Activate(bool On);
virtual void Action(void);
@@ -363,10 +362,10 @@ void mgPCMPlayer::Action(void)
m_index = 0;
m_playing = m_current;
- string filename = getSourceFile();
+ string filename = m_playing->getSourceFile();
mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() );
- if( ( m_decoder = mgDecoders::findDecoder( filename ) ) && m_decoder->start() )
+ if( ( m_decoder = mgDecoders::findDecoder( m_playing ) ) && m_decoder->start() )
{
levelgood = true;
haslevel = false;
@@ -671,38 +670,6 @@ void mgPCMPlayer::StopPlay()
}
}
-string mgPCMPlayer::getSourceFile()
-{
- string filename;
-
- if( !the_setup.GdCompatibility )
- { // use filename itself
- filename = string( the_setup.ToplevelDir ) + m_playing->getSourceFile();
- }
- else
- { // find the unique name within any directory, but what is top? video?
- char *cmd = NULL;
- asprintf( &cmd, "find %s -follow -type f -name '%s'|sort ",
- the_setup.ToplevelDir, m_playing->getSourceFile().c_str() );
-
- FILE *p = popen(cmd, "r");
- if (p)
- {
- char *s;
- if( (s = readline(p) ) != NULL )
- {
- filename = string( s );
- }
- }
- pclose( p );
- delete cmd;
- }
-
- cout << "mgPCMPlayer::getSourceFile: found filename " << filename << endl << flush;
- return filename;
- // return "/test.mp3";
-}
-
bool mgPCMPlayer::NextFile()
{
bool res = false;