summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-01-16 21:41:00 +0000
committerLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-01-16 21:41:00 +0000
commitf3d430aa36ace2edfa471e8eeb541a46f9e9e2ea (patch)
treeebbe9a0059e84c0a927c701153318adb2c33f83e
parenta607bea23f0c6b34af9e8b0eb6e3c903432910d3 (diff)
downloadvdr-plugin-muggle-f3d430aa36ace2edfa471e8eeb541a46f9e9e2ea.tar.gz
vdr-plugin-muggle-f3d430aa36ace2edfa471e8eeb541a46f9e9e2ea.tar.bz2
Add GD compatibility for unique filenames
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@362 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--mg_db.c5
-rw-r--r--muggle.doxygen2
-rw-r--r--vdr_player.c6
-rw-r--r--vdr_setup.c60
-rw-r--r--vdr_setup.h3
5 files changed, 69 insertions, 7 deletions
diff --git a/mg_db.c b/mg_db.c
index e227b91..a310d51 100644
--- a/mg_db.c
+++ b/mg_db.c
@@ -839,7 +839,7 @@ mgSelection::tracks ()
MYSQL_ROW row;
while ((row = mysql_fetch_row (rows)) != NULL)
{
- m_tracks.push_back (mgContentItem (row, m_ToplevelDir));
+ m_tracks.push_back (mgContentItem (row, m_ToplevelDir));
}
mysql_free_result (rows);
}
@@ -878,7 +878,8 @@ mgContentItem::mgContentItem (const MYSQL_ROW row, const string ToplevelDir)
else
m_title = "NULL";
if (row[2])
- m_mp3file = ToplevelDir + row[2];
+ // m_mp3file = ToplevelDir + row[2];
+ m_mp3file = row[2];
else
m_mp3file = "NULL";
if (row[3])
diff --git a/muggle.doxygen b/muggle.doxygen
index 4e601ad..96a5394 100644
--- a/muggle.doxygen
+++ b/muggle.doxygen
@@ -23,7 +23,7 @@ PROJECT_NAME = Muggle media plugin
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 0.0.9
+PROJECT_NUMBER = 0.1.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
diff --git a/vdr_player.c b/vdr_player.c
index 68830b0..a62f9b5 100644
--- a/vdr_player.c
+++ b/vdr_player.c
@@ -409,9 +409,9 @@ mgPCMPlayer::Action (void)
if (m_playing)
{
- std::string filename = m_playing->getSourceFile ();
-mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() );
-
+ std::string filename = the_setup.getFilename( m_playing->getSourceFile () );
+ mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() );
+
if ((m_decoder = mgDecoders::findDecoder (m_playing))
&& m_decoder->start ())
{
diff --git a/vdr_setup.c b/vdr_setup.c
index 36a3b46..093cf98 100644
--- a/vdr_setup.c
+++ b/vdr_setup.c
@@ -14,13 +14,19 @@
* (C) 2001,2002 Stefan Huelswitt <huels@iname.com>
*/
-#include <string.h>
+#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <cstring>
#include "vdr_setup.h"
#include "i18n.h"
mgSetup the_setup;
+char *readline(FILE *f);
+std::string GdFindFile( std::string mp3file, std::string ToplevelDir );
+
// --- mgMenuSetup -----------------------------------------------------------
mgMenuSetup::mgMenuSetup ()
@@ -86,3 +92,55 @@ mgSetup::mgSetup ()
Only48kHz = 0;
ToplevelDir = "/mnt/music/";
}
+
+std::string
+mgSetup::getFilename( std::string basename )
+{
+ if( GdCompatibility )
+ {
+ return GdFindFile( basename, std::string( ToplevelDir ) );
+ }
+ else
+ {
+ return string( ToplevelDir ) + basename;
+ }
+}
+
+#define MAXPARSEBUFFER 1024
+
+char *readline(FILE *f)
+{
+ static char buffer[MAXPARSEBUFFER];
+ if (fgets(buffer, sizeof(buffer), f) > 0)
+ {
+ int l = strlen(buffer) - 1;
+ if (l >= 0 && buffer[l] == '\n')
+ buffer[l] = 0;
+ return buffer;
+ }
+ return NULL;
+}
+
+#define FINDCMD "cd '%s' && find -follow -name '%s' 2> /dev/null"
+
+std::string GdFindFile( std::string mp3file, std::string tld )
+{
+ std::string fullname = "";
+ char *cmd = NULL;
+ asprintf( &cmd, FINDCMD, ToplevelDir.c_str(), mp3file.c_str() );
+ FILE *p = popen( cmd, "r" );
+ if (p)
+ {
+ char *s;
+ while( (s = readline(p) ) != NULL)
+ {
+ // printf( "Found: %s", s );
+ fullname = std::string( tld ) + std::string( s );
+ }
+ pclose(p);
+ }
+
+ free( cmd );
+
+ return fullname;
+}
diff --git a/vdr_setup.h b/vdr_setup.h
index c21adb1..b820857 100644
--- a/vdr_setup.h
+++ b/vdr_setup.h
@@ -19,6 +19,7 @@
// #include <osd.h>
#include <menuitems.h>
+#include <string>
#define MAX_STRING_LEN 128
@@ -56,6 +57,8 @@ class mgSetup
public:
mgSetup (void);
+
+ std::string getFilename( std::string basename );
};
extern mgSetup the_setup;