summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-06 06:28:44 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-06 06:28:44 +0000
commitebdf27d9e7c5d167101adf3c9df5efe3d7d52586 (patch)
tree6dd53ed3300743ebadc98c6cce602d946e45a5ab
parent05f0b754ac1e951a65f6301b2749025ebe5d5849 (diff)
downloadvdr-plugin-muggle-ebdf27d9e7c5d167101adf3c9df5efe3d7d52586.tar.gz
vdr-plugin-muggle-ebdf27d9e7c5d167101adf3c9df5efe3d7d52586.tar.bz2
Added more stuff to mg_database and added status display for gLCD
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@203 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--gd_content_interface.c2
-rw-r--r--mg_database.c33
-rw-r--r--mg_database.h33
-rw-r--r--mg_playlist.c8
-rw-r--r--mg_playlist.h5
-rw-r--r--vdr_player.c124
-rw-r--r--vdr_player.h36
7 files changed, 158 insertions, 83 deletions
diff --git a/gd_content_interface.c b/gd_content_interface.c
index 6fda5e4..e3ee5fc 100644
--- a/gd_content_interface.c
+++ b/gd_content_interface.c
@@ -73,7 +73,7 @@ int GdInitDatabase( MYSQL *db )
the_setup.DbPass,
the_setup.DbName,
the_setup.DbPort,
- "", 0 ) == NULL )
+ NULL, 0 ) == NULL )
{
return -2;
} // if mysql_real_connect
diff --git a/mg_database.c b/mg_database.c
index fa38e17..9dfa395 100644
--- a/mg_database.c
+++ b/mg_database.c
@@ -16,7 +16,7 @@ mgDB::mgDB()
mgDB::mgDB(std::string host, std::string name,
std::string user, std::string pass,
- int port)
+ int port)
{
}
@@ -41,3 +41,34 @@ std::string mgDB::escape_string( MYSQL *db, std::string s )
return r;
}
+
+MYSQL_RES* mgDB::read_query( const char *fmt, ...)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ vsnprintf( querybuf, MAX_QUERY_BUFLEN-1, fmt, ap );
+
+ if( mysql_query( &m_dbase, querybuf) )
+ {
+ mgError( "SQL error in MUGGLE:\n%s\n", querybuf );
+ }
+
+ MYSQL_RES *result = mysql_store_result( &m_dbase );
+
+ va_end(ap);
+ return result;
+}
+
+void mgDB::write_query( const char *fmt, ... )
+{
+ va_list ap;
+ va_start( ap, fmt );
+ vsnprintf( querybuf, MAX_QUERY_BUFLEN-1, fmt, ap );
+
+ if( mysql_query( &m_dbase, querybuf ) )
+ {
+ mgError( "SQL error in MUGGLE:\n%s\n", querybuf );
+ }
+
+ va_end(ap);
+}
diff --git a/mg_database.h b/mg_database.h
index 3f2c323..54baef1 100644
--- a/mg_database.h
+++ b/mg_database.h
@@ -35,22 +35,47 @@ class mgDB
* \param pass
* \param port
*/
- mgDB( std::string host, std::string name,
- std::string user, std::string pass,
- int port );
+ mgDB( std::string host, std::string name,
+ std::string user="", std::string pass="",
+ int port = 0 );
+
+ // add constructor for sockets
/*! \brief constructor */
~mgDB();
- /*! \brief obtain database handle*/
+ /*!
+ * \brief obtain database handle
+ */
MYSQL getDBHandle();
+ /*!
+ * \brief database initialization
+ */
+ // int initialize();
+
+ /*!
+ * \brief helper function to execute read queries
+ *
+ * \todo Could be a member of mgDatabase?
+ */
+ MYSQL_RES* read_query( const char *fmt, ... );
+
+ /*!
+ * \brief helper function to execute write queries
+ *
+ * \todo Could be a member of mgDatabase?
+ */
+ void write_query( const char *fmt, ... );
+
/*!
* \brief escape arguments to be contained in a query
*
* \todo use m_dbase member of this class
*/
static std::string escape_string( MYSQL *db, std::string s );
+
+
private:
MYSQL m_dbase;
diff --git a/mg_playlist.c b/mg_playlist.c
index a63519e..a0fbb0f 100644
--- a/mg_playlist.c
+++ b/mg_playlist.c
@@ -160,11 +160,17 @@ void mgPlaylist::setListname(std::string name)
}
// returns the count of items in the list
-int mgPlaylist::count()
+int mgPlaylist::getCount()
{
return m_list.size();
}
+// returns current index in the playlist
+int mgPlaylist::getIndex() const
+{
+ return m_current_idx;
+}
+
// returns the current item of the list
mgContentItem* mgPlaylist::getCurrent()
{
diff --git a/mg_playlist.h b/mg_playlist.h
index 30443f4..e7c428d 100644
--- a/mg_playlist.h
+++ b/mg_playlist.h
@@ -128,7 +128,10 @@ public:
virtual void setListname(std::string name);
//! \brief returns the count of items in the list
- int count();
+ int getCount();
+
+ //! \brief returns current index in the playlist
+ int getIndex() const;
/*! \brief returns the nth track from the playlist
*
diff --git a/vdr_player.c b/vdr_player.c
index 2ed1416..865353e 100644
--- a/vdr_player.c
+++ b/vdr_player.c
@@ -35,6 +35,7 @@
#include <ringbuffer.h>
#include <tools.h>
#include <recording.h>
+#include <status.h>
#include "vdr_player.h"
#include "vdr_decoder.h"
@@ -200,6 +201,7 @@ public:
void NewPlaylist(mgPlaylist *plist);
mgContentItem *GetCurrent () { return m_current; }
+ mgPlaylist *GetPlaylist () { return m_playlist; }
};
mgPCMPlayer::mgPCMPlayer(mgPlaylist *plist)
@@ -221,6 +223,7 @@ mgPCMPlayer::mgPCMPlayer(mgPlaylist *plist)
m_index = 0;
m_playing = 0;
+ m_current = 0;
}
mgPCMPlayer::~mgPCMPlayer()
@@ -370,7 +373,7 @@ void mgPCMPlayer::Action(void)
{
std::string filename = m_playing->getSourceFile();
// mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() );
-
+
if( ( m_decoder = mgDecoders::findDecoder( m_playing ) ) && m_decoder->start() )
{
levelgood = true;
@@ -853,11 +856,12 @@ void mgPCMPlayer::SkipSeconds(int secs)
bool mgPCMPlayer::GetIndex( int &current, int &total, bool snaptoiframe )
{
- bool res = false;
- current = SecondsToFrames( m_index );
- total = SecondsToFrames( m_current->getLength() );
-
- return res;
+ if(m_current) {
+ current = SecondsToFrames( m_index );
+ total = SecondsToFrames( m_current->getLength() );
+ return true;
+ }
+ return false;
}
// --- mgPlayerControl -------------------------------------------------------
@@ -872,10 +876,22 @@ mgPlayerControl::mgPlayerControl( mgPlaylist *plist )
#endif
m_visible = false;
m_has_osd = false;
+
+ m_szLastShowStatusMsg = NULL;
+ // Notity all cStatusMonitor
+ StatusMsgReplaying();
}
mgPlayerControl::~mgPlayerControl()
{
+ // Notify cleanup all cStatusMonitor
+ cStatus::MsgReplaying(this, NULL);
+ if( m_szLastShowStatusMsg )
+ {
+ free(m_szLastShowStatusMsg);
+ m_szLastShowStatusMsg = NULL;
+ }
+
Hide();
Stop();
}
@@ -970,6 +986,8 @@ void mgPlayerControl::NewPlaylist(mgPlaylist *plist)
void mgPlayerControl::ShowProgress()
{
+ StatusMsgReplaying();
+
if( m_visible )
{
if( !m_has_osd )
@@ -1113,47 +1131,53 @@ eOSState mgPlayerControl::ProcessKey(eKeys key)
return osContinue;
}
-/************************************************************
- *
- * $Log: vdr_player.c,v $
- * Revision 1.7 2004/07/27 20:50:54 lvw
- * Playlist indexing now working
- *
- * Revision 1.6 2004/07/26 22:20:55 lvw
- * Reworked playlist indexing
- *
- * Revision 1.5 2004/07/26 20:03:00 lvw
- * Bug in initalizing playlist removed
- *
- * Revision 1.4 2004/07/25 21:33:35 lvw
- * Removed bugs in finding track files and playlist indexing.
- *
- * Revision 1.3 2004/07/12 11:06:23 LarsAC
- * No longer skip first file on playlist when starting replay.
- *
- * Revision 1.2 2004/05/28 15:29:19 lvw
- * Merged player branch back on HEAD branch.
- *
- * Revision 1.1.2.19 2004/05/26 14:30:27 lvw
- * Removed bug in finding correct mp3 file in GD mode
- *
- * Revision 1.1.2.18 2004/05/25 06:48:24 lvw
- * Documentation and code polishing.
- *
- * Revision 1.1.2.17 2004/05/25 00:10:45 lvw
- * Code cleanup and added use of real database source files
- *
- * Revision 1.1.2.16 2004/05/24 11:48:52 lvw
- * Debugging info added to find deadlock
- *
- * Revision 1.1.2.15 2004/05/12 22:38:37 lvw
- * Some cleanup
- *
- * Revision 1.1.2.14 2004/05/11 06:35:16 lvw
- * Added debugging while hunting stop bug.
- *
- * Revision 1.1.2.13 2004/05/07 06:46:41 lvw
- * Removed a bug in playlist deallocation. Added infrastructure to display information while playing.
- *
- *
- ***********************************************************/
+void mgPlayerControl::StatusMsgReplaying()
+{
+ char *szBuf=NULL;
+ if(m_player
+ && m_player->GetCurrent()
+ && m_player->GetCurrent()->isValid()
+ && m_player->GetCurrent()->getContentType() == mgContentItem::GD_AUDIO
+ && m_player->GetPlaylist())
+ {
+ /*
+ if(m_player->GetCurrent()->getAlbum().length() > 0)
+ {
+ asprintf(&szBuf,"[%c%c] (%d/%d) %s - %s",
+ m_player->GetPlaylist()->isLoop()?'L':'.',
+ m_player->GetPlaylist()->isShuffle()'S':'.',
+ m_player->GetPlaylist()->getIndex() + 1,m_player->GetPlaylist()->getCount(),
+ m_player->GetCurrent()->getTitle().c_str(),
+ m_player->GetCurrent()->getAlbum().c_str());
+ }
+ else */
+ {
+ asprintf(&szBuf,"[%c%c] (%d/%d) %s",
+ /* TODO m_player->GetPlaylist()->isLoop()?'L':*/'.',
+ /* TODO m_player->GetPlaylist()->isShuffle()'S':*/'.',
+ m_player->GetPlaylist()->getIndex() + 1,m_player->GetPlaylist()->getCount(),
+ m_player->GetCurrent()->getTitle().c_str());
+ }
+ }
+ else
+ {
+ asprintf(&szBuf,"[muggle]");
+ }
+
+ if(szBuf
+ && ( m_szLastShowStatusMsg == NULL
+ || 0 != strcmp(szBuf,m_szLastShowStatusMsg) ) )
+ {
+ cStatus::MsgReplaying(this,szBuf);
+
+ if(m_szLastShowStatusMsg)
+ {
+ free(m_szLastShowStatusMsg);
+ }
+ m_szLastShowStatusMsg = szBuf;
+ }
+ else
+ {
+ free(szBuf);
+ }
+}
diff --git a/vdr_player.h b/vdr_player.h
index 1ab8d9e..92b9e25 100644
--- a/vdr_player.h
+++ b/vdr_player.h
@@ -15,8 +15,8 @@
*/
-#ifndef ___DVB_MP3_H
-#define ___DVB_MP3_H
+#ifndef ___VDR_PLAYER_H
+#define ___VDR_PLAYER_H
#include <player.h>
#if VDRVERSNUM >= 10307
@@ -40,7 +40,7 @@ class mgPlayerControl : public cControl
{
private:
- //! \brief the reference to the player
+ //! \brief the reference to the player , don't rename it see cControl
mgPCMPlayer *m_player;
//! \brief indicates, whether the osd should be visible
@@ -56,6 +56,9 @@ private:
const cFont *font;
#endif
+ //! \brief Last Message for Statusmonitor
+ char* m_szLastShowStatusMsg;
+
public:
/*! \brief construct a control with a playlist
@@ -121,27 +124,10 @@ public:
//! \brief process key events
eOSState ProcessKey(eKeys key);
-};
-#endif //___DVB_MP3_H
+protected:
+ //! \brief signal a played file to any cStatusMonitor inside vdr
+ void StatusMsgReplaying();
+};
-/************************************************************
- *
- * $Log: vdr_player.h,v $
- * Revision 1.2 2004/05/28 15:29:19 lvw
- * Merged player branch back on HEAD branch.
- *
- * Revision 1.1.2.9 2004/05/25 06:48:24 lvw
- * Documentation and code polishing.
- *
- * Revision 1.1.2.8 2004/05/25 00:10:45 lvw
- * Code cleanup and added use of real database source files
- *
- * Revision 1.1.2.7 2004/05/11 06:35:16 lvw
- * Added debugging while hunting stop bug.
- *
- * Revision 1.1.2.6 2004/05/07 06:46:41 lvw
- * Removed a bug in playlist deallocation. Added infrastructure to display information while playing.
- *
- *
- ***********************************************************/
+#endif //___VDR_PLAYER_H