Merge remote-tracking branch 'check/next-cc'

untested, probably needs some buildfixing
This commit is contained in:
Stefan Seyfried
2013-12-22 21:25:05 +01:00
67 changed files with 1637 additions and 894 deletions

View File

@@ -80,21 +80,10 @@ extern CPictureViewer * g_PicViewer;
#include <sstream>
#include <unistd.h>
#if 0
#ifdef ENABLE_LIRC
#include <irsend/irsend.h>
#endif
#if 1
#include <linux/dvb/audio.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/video.h>
#define ADAP "/dev/dvb/adapter0"
#define ADEC ADAP "/audio0"
#define VDEC ADAP "/video0"
#define DMX ADAP "/demux0"
#define DVR ADAP "/dvr0"
#endif
#include <curl/curl.h>
#include <curl/easy.h>
#if LIBCURL_VERSION_NUM < 0x071507
#include <curl/types.h>
#endif
#include <video.h>
@@ -103,7 +92,7 @@ extern cVideo * videoDecoder;
#define AUDIOPLAYERGUI_SMSKEY_TIMEOUT 1000
#define SHOW_FILE_LOAD_LIMIT 50
//#define AUDIOPLAYER_TIME_DEBUG
#define AUDIOPLAYER_TIME_DEBUG
// check if files to be added are already in the playlist
#define AUDIOPLAYER_CHECK_FOR_DUPLICATES
@@ -136,17 +125,6 @@ void CAudiofileExt::operator=(const CAudiofileExt& src)
firstChar = src.firstChar;
}
//------------------------------------------------------------------------
#include <curl/curl.h>
#include <curl/easy.h>
#if LIBCURL_VERSION_NUM < 0x071507
#include <curl/types.h>
#endif
struct MemoryStruct {
char *memory;
size_t size;
@@ -221,28 +199,26 @@ void CAudioPlayerGui::Init(void)
audiofilefilter.addFilter("m3u");
audiofilefilter.addFilter("ogg");
audiofilefilter.addFilter("wav");
#ifdef ENABLE_FLAC
audiofilefilter.addFilter("flac");
#ifdef ENABLE_FFMPEGDEC
audiofilefilter.addFilter("aac");
audiofilefilter.addFilter("dts");
audiofilefilter.addFilter("m4a");
#endif
}
m_SMSKeyInput.setTimeout(AUDIOPLAYERGUI_SMSKEY_TIMEOUT);
}
//------------------------------------------------------------------------
CAudioPlayerGui::~CAudioPlayerGui()
{
m_playlist.clear();
m_radiolist.clear();
m_filelist.clear();
m_title2Pos.clear();
// g_Zapit->setStandby (false);
// g_Sectionsd->setPauseScanning (false);
delete dline;
delete ibox;
}
//------------------------------------------------------------------------
int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
{
@@ -300,9 +276,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
m_screensaver=false;
if (parent)
{
parent->hide();
}
bool usedBackground = m_frameBuffer->getuseBackground();
if (usedBackground)
@@ -349,8 +323,6 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
return res;
}
//------------------------------------------------------------------------
int CAudioPlayerGui::show()
{
neutrino_msg_t msg;
@@ -377,11 +349,10 @@ int CAudioPlayerGui::show()
updateTimes();
// stop if mode was changed in another thread
if (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_audio)
{
// stop if mode was changed in another thread
loop = false;
}
if ((m_state != CAudioPlayerGui::STOP) &&
(CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) &&
(!m_playlist.empty()))
@@ -468,9 +439,7 @@ int CAudioPlayerGui::show()
else if (!m_playlist.empty())
{
if (m_selected < m_listmaxshow)
{
m_selected = m_playlist.size()-1;
}
else
m_selected -= m_listmaxshow;
m_liststart = (m_selected / m_listmaxshow) * m_listmaxshow;
@@ -518,17 +487,7 @@ int CAudioPlayerGui::show()
m_selected -= step;
if ((prevselected-step) < 0)
m_selected = m_playlist.size()-1;
#if 0
if (m_selected == 0)
{
m_selected = m_playlist.size()-1;
}
else
{
m_selected--;
}
#endif
paintItem(prevselected - m_liststart);
unsigned int oldliststart = m_liststart;
m_liststart = (m_selected/m_listmaxshow)*m_listmaxshow;
if (oldliststart != m_liststart)
@@ -537,6 +496,7 @@ int CAudioPlayerGui::show()
}
else
{
paintItem(prevselected - m_liststart);
paintItem(m_selected - m_liststart);
}
}
@@ -557,7 +517,6 @@ int CAudioPlayerGui::show()
}
//m_selected = (m_selected + 1) % m_playlist.size();
paintItem(prevselected - m_liststart);
unsigned int oldliststart = m_liststart;
m_liststart = (m_selected/m_listmaxshow)*m_listmaxshow;
if (oldliststart != m_liststart)
@@ -566,6 +525,7 @@ int CAudioPlayerGui::show()
}
else
{
paintItem(prevselected - m_liststart);
paintItem(m_selected - m_liststart);
}
}
@@ -585,13 +545,10 @@ int CAudioPlayerGui::show()
{
if (!m_playlist.empty())
{
//xx CPlayList::iterator p = m_playlist.begin()+selected;
removeFromPlaylist(m_selected);
if ((int)m_selected == m_current)
{
m_current--;
//stop(); // Stop if song is deleted, next song will be startet automat.
}
if (m_selected >= m_playlist.size())
m_selected = m_playlist.empty() ? m_playlist.size() : m_playlist.size() - 1;
update = true;
@@ -708,9 +665,9 @@ int CAudioPlayerGui::show()
//InputSelector.addItem(GenericMenuSeparator);
hide();
InputSelector.exec(NULL, "");
delete InetRadioInputChanger;
if (select >= 0)
old_select = select;
switch (select) {
@@ -863,9 +820,6 @@ int CAudioPlayerGui::show()
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
paintLCD();
update = true;
//pushback key if...
//g_RCInput->postMsg( msg, data );
//loop = false;
}
#endif
else if (msg == NeutrinoMessages::CHANGEMODE)
@@ -880,13 +834,13 @@ int CAudioPlayerGui::show()
msg == NeutrinoMessages::ZAPTO ||
msg == NeutrinoMessages::STANDBY_ON ||
msg == NeutrinoMessages::SHUTDOWN ||
msg == NeutrinoMessages::SLEEPTIMER)
((msg == NeutrinoMessages::SLEEPTIMER) && !data))
{
if(msg != NeutrinoMessages::RECORD_START )
ret = menu_return::RETURN_EXIT_ALL;
// Exit for Record/Zapto Timers
loop = false;
g_RCInput->postMsg(msg, data);
}
else if (msg == NeutrinoMessages::EVT_TIMER)
@@ -966,8 +920,11 @@ bool CAudioPlayerGui::clearPlaylist(void)
bool result = false;
CAudioPlayList::const_iterator it;
for (it = m_playlist.begin(); it!=m_playlist.end(); ++it)
#if 0
for (it = m_playlist.begin(); it!=m_playlist.end(); ++it) {
unlink(it->MetaData.cover.c_str());
}
#endif
if (!(m_playlist.empty()))
{
@@ -994,9 +951,8 @@ bool CAudioPlayerGui::shufflePlaylist(void)
std::random_shuffle((m_current != 0) ? m_playlist.begin() : m_playlist.begin() + 1, m_playlist.end(), rnd);
if (m_select_title_by_name)
{
buildSearchTree();
}
m_playlistHasChanged = true;
m_selected = 0;
@@ -1005,7 +961,8 @@ bool CAudioPlayerGui::shufflePlaylist(void)
return(result);
}
void CAudioPlayerGui::addUrl2Playlist(const char *url, const char *name, const time_t bitrate) {
void CAudioPlayerGui::addUrl2Playlist(const char *url, const char *name, const time_t bitrate)
{
CAudiofileExt mp3( url, CFile::STREAM_AUDIO );
// tmp = tmp.substr(0,tmp.length()-4); //remove .url
//printf("[addUrl2Playlist], name = %s, url = %s\n", name, url);
@@ -1020,12 +977,12 @@ void CAudioPlayerGui::addUrl2Playlist(const char *url, const char *name, const t
else
mp3.MetaData.total_time = 0;
if (url[0] != '#') {
if (url[0] != '#')
addToPlaylist(mp3);
}
}
void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, const time_t tim) {
void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, const time_t tim)
{
CURL *curl_handle;
struct MemoryStruct chunk;
const long int GET_PLAYLIST_TIMEOUT = 2;
@@ -1111,7 +1068,6 @@ void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, cons
curl_global_cleanup();
}
void CAudioPlayerGui::readDir_ic(void)
{
const std::string icecasturl = "http://dir.xiph.org/yp.xml";
@@ -1306,9 +1262,10 @@ bool CAudioPlayerGui::openFilebrowser(void)
|| (files->getType() == CFile::FILE_OGG)
|| (files->getType() == CFile::FILE_MP3)
|| (files->getType() == CFile::FILE_WAV)
#ifdef ENABLE_FLAC
|| (files->getType() == CFile::FILE_FLAC)
#ifdef ENABLE_FFMPEGDEC
|| (files->getType() == CFile::FILE_AAC)
#endif
|| (files->getType() == CFile::FILE_FLAC)
)
{
CAudiofileExt audiofile(files->Name,
@@ -1399,9 +1356,7 @@ bool CAudioPlayerGui::openFilebrowser(void)
|| fileType == CFile::FILE_MP3
|| fileType == CFile::FILE_OGG
|| fileType == CFile::FILE_WAV
#ifdef ENABLE_FLAC
|| fileType == CFile::FILE_FLAC
#endif
)
{
CAudiofileExt audioFile(filename,fileType);
@@ -1422,21 +1377,22 @@ bool CAudioPlayerGui::openFilebrowser(void)
else if (files->getType() == CFile::FILE_XML)
{
if (!files->Name.empty())
{
scanXmlFile(files->Name);
}
}
}
if (m_select_title_by_name)
{
buildSearchTree();
}
#ifdef AUDIOPLAYER_TIME_DEBUG
timeval end;
gettimeofday(&end,NULL);
printf("adding %ld files took: ",maxProgress+1);
printTimevalDiff(start,end);
#endif
//store last dir
if( (sizeof(g_settings.network_nfs_audioplayerdir)) > m_Path.size() && (strcmp(g_settings.network_nfs_audioplayerdir,m_Path.c_str()) != 0))
strcpy(g_settings.network_nfs_audioplayerdir,m_Path.c_str());
result = true;
}
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
@@ -1448,8 +1404,6 @@ bool CAudioPlayerGui::openFilebrowser(void)
return ( result);
}
//------------------------------------------------------------------------
bool CAudioPlayerGui::openSCbrowser(void)
{
bool result = false;
@@ -1503,9 +1457,7 @@ bool CAudioPlayerGui::openSCbrowser(void)
g_RCInput->getMsg(&msg, &data, 0);
}
if (m_select_title_by_name)
{
buildSearchTree();
}
#ifdef AUDIOPLAYER_TIME_DEBUG
timeval end;
gettimeofday(&end,NULL);
@@ -1523,9 +1475,6 @@ bool CAudioPlayerGui::openSCbrowser(void)
return ( result);
}
//------------------------------------------------------------------------
void CAudioPlayerGui::hide()
{
// printf("hide(){\n");
@@ -1539,8 +1488,6 @@ void CAudioPlayerGui::hide()
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::paintItem(int pos)
{
if (!m_show_playlist)
@@ -1602,14 +1549,6 @@ void CAudioPlayerGui::paintItem(int pos)
if ((pos + m_liststart) < m_playlist.size())
{
if (m_playlist[pos + m_liststart].FileType != CFile::STREAM_AUDIO &&
!m_playlist[pos + m_liststart].MetaData.bitrate)
{
// id3tag noch nicht geholt
GetMetaData(m_playlist[pos + m_liststart]);
if (m_state != CAudioPlayerGui::STOP && !g_settings.audioplayer_highprio)
usleep(100*1000);
}
char sNr[20];
sprintf(sNr, "%2d : ", pos + m_liststart + 1);
std::string tmp = sNr;
@@ -1629,17 +1568,13 @@ void CAudioPlayerGui::paintItem(int pos)
if ((pos + m_liststart) == m_selected)
{
if (m_state == CAudioPlayerGui::STOP)
{
CVFD::getInstance()->showAudioTrack(m_playlist[pos + m_liststart].MetaData.artist,
m_playlist[pos + m_liststart].MetaData.title,
m_playlist[pos + m_liststart].MetaData.album);
}
}
}
}
//--------------playlist----------------------------------------------------------
void CAudioPlayerGui::paintHead()
{
if (!m_show_playlist || m_screensaver)
@@ -1659,7 +1594,6 @@ void CAudioPlayerGui::paintHead()
header.paint(CC_SAVE_SCREEN_NO);
}
//------------------------------------------------------------------------
const struct button_label AudioPlayerButtons[][4] =
{
{
@@ -1705,19 +1639,18 @@ const struct button_label AudioPlayerButtons[][4] =
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_INETRADIO_NAME },
},
};
//------------------------------------------------------------------------
void CAudioPlayerGui::paintFoot()
{
if (m_screensaver)
return;
const struct button_label ScondLineButtons[3] =
{
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY },
{ NEUTRINO_ICON_BUTTON_HELP , LOCALE_AUDIOPLAYER_KEYLEVEL },
{ NEUTRINO_ICON_BUTTON_INFO , LOCALE_PICTUREVIEWER_HEAD},
};
const struct button_label ScondLineButtons[3] =
{
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY },
{ NEUTRINO_ICON_BUTTON_HELP , LOCALE_AUDIOPLAYER_KEYLEVEL },
{ NEUTRINO_ICON_BUTTON_INFO , LOCALE_PICTUREVIEWER_HEAD},
};
int top;
int c_rad_mid = RADIUS_MID;
@@ -1726,8 +1659,6 @@ const struct button_label ScondLineButtons[3] =
else
top = m_y + (m_height - 2 * m_buttonHeight);
//int ButtonWidth = (m_width - 20) / 5;
m_frameBuffer->paintBoxRel(m_x, top, m_width, 2 * m_buttonHeight, COL_INFOBAR_SHADOW_PLUS_1, c_rad_mid, (m_show_playlist ? CORNER_BOTTOM : CORNER_ALL));
// why? m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_1);
@@ -1774,7 +1705,24 @@ const struct button_label ScondLineButtons[3] =
}
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::paintCover()
{
int c_rad_mid = RADIUS_MID;
int title_height = m_title_height;
const CAudioMetaData meta = CAudioPlayer::getInstance()->getMetaData();
if (!m_show_playlist) // no playlist -> smaller Info-Box
title_height -= m_fheight;
std::string cover = m_curr_audiofile.Filename.substr(0, m_curr_audiofile.Filename.rfind('/')) + "/folder.jpg";
if (!meta.cover.empty())
cover = meta.cover;
if (access(cover.c_str(), F_OK) == 0)
g_PicViewer->DisplayImage(cover, m_x + 2 + c_rad_mid/2, m_y + 2 + c_rad_mid/2, title_height - 14 - c_rad_mid, title_height - 14 - c_rad_mid, m_frameBuffer->TM_NONE);
}
void CAudioPlayerGui::paintInfo()
{
if (m_screensaver)
@@ -1793,13 +1741,7 @@ void CAudioPlayerGui::paintInfo()
m_frameBuffer->paintBoxRel(m_x + 1, m_y + 1 , m_width - 2, title_height - 12, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid);
m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, title_height - 10, 2, COL_MENUCONTENT_PLUS_6, c_rad_mid);
std::string cover = m_curr_audiofile.Filename.substr(0, m_curr_audiofile.Filename.rfind('/')) + "/folder.jpg";
if (!m_curr_audiofile.MetaData.cover.empty())
cover = m_curr_audiofile.MetaData.cover;
if (access(cover.c_str(), F_OK) == 0)
g_PicViewer->DisplayImage(cover, m_x + 2 + c_rad_mid/2, m_y + 2 + c_rad_mid/2, title_height - 14 - c_rad_mid, title_height - 14 - c_rad_mid, m_frameBuffer->TM_NONE);
paintCover();
// first line (Track number)
std::string tmp;
@@ -1820,11 +1762,7 @@ void CAudioPlayerGui::paintInfo()
tmp, COL_MENUCONTENTSELECTED_TEXT, 0, true); // UTF-8
// second line (Artist/Title...)
if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO &&
!m_curr_audiofile.MetaData.bitrate)
{
GetMetaData(m_curr_audiofile);
}
GetMetaData(m_curr_audiofile);
if (m_curr_audiofile.MetaData.title.empty())
tmp = m_curr_audiofile.MetaData.artist;
@@ -1857,7 +1795,6 @@ void CAudioPlayerGui::paintInfo()
updateTimes(true);
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::paint()
{
@@ -1866,9 +1803,7 @@ void CAudioPlayerGui::paint()
m_liststart = (m_selected / m_listmaxshow) * m_listmaxshow;
paintHead();
for (unsigned int count=0; count<m_listmaxshow; count++)
{
paintItem(count);
}
int ypos = m_y + m_title_height + m_theight;
int sb = m_fheight * m_listmaxshow;
@@ -1885,16 +1820,12 @@ void CAudioPlayerGui::paint()
paintInfo();
paintFoot();
m_visible = true;
}
//------------------------------------------------------------------------
void CAudioPlayerGui::clearItemID3DetailsLine ()
{
paintItemID3DetailsLine(-1);
}
//------------------------------------------------------------------------
void CAudioPlayerGui::paintItemID3DetailsLine (int pos)
{
@@ -1906,11 +1837,11 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos)
// clear details line
if (dline != NULL)
dline->hide();
dline->kill();
// clear infobox
if (ibox != NULL)
ibox->hide();
ibox->kill();
// paint Line if detail info (and not valid list pos) and info box
if (!m_playlist.empty() && (pos >= 0))
@@ -1919,7 +1850,7 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos)
if (dline == NULL)
dline = new CComponentsDetailLine(xpos, ypos1a, ypos2a, m_fheight/2+1, m_fheight);
dline->setYPos(ypos1a);
dline->paint();
dline->paint(false);
// paint id3 infobox
if (ibox == NULL)
@@ -1958,12 +1889,11 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos)
else
{
if (dline != NULL)
dline->hide();
dline->kill();
if (ibox != NULL)
ibox->hide();
ibox->kill();
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::stop()
{
@@ -1983,7 +1913,6 @@ void CAudioPlayerGui::stop()
if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
CAudioPlayer::getInstance()->stop();
}
//------------------------------------------------------------------------
void CAudioPlayerGui::pause()
{
@@ -2001,7 +1930,6 @@ void CAudioPlayerGui::pause()
}
paintLCD();
}
//------------------------------------------------------------------------
void CAudioPlayerGui::ff(unsigned int seconds)
{
@@ -2019,7 +1947,6 @@ void CAudioPlayerGui::ff(unsigned int seconds)
}
paintLCD();
}
//------------------------------------------------------------------------
void CAudioPlayerGui::rev(unsigned int seconds)
{
@@ -2037,7 +1964,6 @@ void CAudioPlayerGui::rev(unsigned int seconds)
}
paintLCD();
}
//------------------------------------------------------------------------
void CAudioPlayerGui::play(unsigned int pos)
{
@@ -2081,13 +2007,8 @@ void CAudioPlayerGui::play(unsigned int pos)
}
}
if (m_playlist[pos].FileType != CFile::STREAM_AUDIO &&
!m_playlist[pos].MetaData.bitrate)
{
// id3tag noch nicht geholt
//printf("play: need getMetaData\n");
GetMetaData(m_playlist[pos]);
}
GetMetaData(m_playlist[pos]);
m_metainfo.clear();
m_time_played = 0;
m_time_total = m_playlist[m_current].MetaData.total_time;
@@ -2106,7 +2027,6 @@ void CAudioPlayerGui::play(unsigned int pos)
paintFoot();
}
}
//------------------------------------------------------------------------
int CAudioPlayerGui::getNext()
{
@@ -2122,7 +2042,7 @@ int CAudioPlayerGui::getNext()
}
return ret;
}
//------------------------------------------------------------------------
void CAudioPlayerGui::updateMetaData(bool screen_saver)
{
bool updateMeta = false;
@@ -2159,37 +2079,38 @@ void CAudioPlayerGui::updateMetaData(bool screen_saver)
{
m_curr_audiofile.MetaData.artist = meta.artist;
if ( !screen_saver)
if ( !screen_saver)
updateScreen = true;
updateLcd = true;
}
if (!meta.title.empty() && meta.title != m_curr_audiofile.MetaData.title)
{
m_curr_audiofile.MetaData.title = meta.title;
if ( !screen_saver)
if ( !screen_saver)
updateScreen = true;
updateLcd = true;
}
if (!meta.sc_station.empty() && meta.sc_station != m_curr_audiofile.MetaData.album)
{
m_curr_audiofile.MetaData.album = meta.sc_station;
updateLcd = true;
}
paintCover();
}
//if (CAudioPlayer::getInstance()->getScBuffered() != 0)
if (CAudioPlayer::getInstance()->hasMetaDataChanged() != 0)
updateLcd = true;
//printf("CAudioPlayerGui::updateMetaData: updateLcd %d\n", updateLcd);
if (updateLcd)
paintLCD();
if (updateScreen)
paintInfo();
if (updateMeta || updateScreen)
{
m_frameBuffer->paintBoxRel(m_x + 10 + m_title_height, m_y + 4 + 2*m_fheight, m_width - 20 - m_title_height, m_sheight, COL_MENUCONTENTSELECTED_PLUS_0);
@@ -2199,7 +2120,6 @@ void CAudioPlayerGui::updateMetaData(bool screen_saver)
m_width- 2*xstart, m_metainfo, COL_MENUCONTENTSELECTED_TEXT);
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::updateTimes(const bool force)
{
@@ -2265,8 +2185,6 @@ void CAudioPlayerGui::updateTimes(const bool force)
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::paintLCD()
{
switch (m_state)
@@ -2305,7 +2223,6 @@ void CAudioPlayerGui::paintLCD()
break;
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::screensaver(bool on)
{
@@ -2325,14 +2242,12 @@ void CAudioPlayerGui::screensaver(bool on)
m_idletime = time(NULL);
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::GetMetaData(CAudiofileExt &File)
{
// printf("GetMetaData\n");
bool ret = 1;
if (CFile::STREAM_AUDIO != File.FileType)
if (File.FileType != CFile::STREAM_AUDIO && !File.MetaData.bitrate)
ret = CAudioPlayer::getInstance()->readMetaData( &File,
m_state != CAudioPlayerGui::STOP &&
!g_settings.audioplayer_highprio);
@@ -2363,7 +2278,6 @@ void CAudioPlayerGui::GetMetaData(CAudiofileExt &File)
File.MetaData.title = FILESYSTEM_ENCODING_TO_UTF8_STRING(File.MetaData.title );
}
}
//------------------------------------------------------------------------
bool CAudioPlayerGui::getNumericInput(neutrino_msg_t& msg, int& val) {
@@ -2396,12 +2310,9 @@ bool CAudioPlayerGui::getNumericInput(neutrino_msg_t& msg, int& val) {
return (msg == CRCInput::RC_ok);
}
//------------------------------------------------------------------------
void CAudioPlayerGui::getFileInfoToDisplay(std::string &info, CAudiofileExt &file)
void CAudioPlayerGui::getFileInfoToDisplay(std::string &fileInfo, CAudiofileExt &file)
{
std::string fileInfo;
//std::string fileInfo;
std::string artist;
std::string title;
@@ -2410,10 +2321,7 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &info, CAudiofileExt &fil
title = "Title?";
}
if (!file.MetaData.bitrate)
{
GetMetaData(file);
}
GetMetaData(file);
if (!file.MetaData.artist.empty())
artist = file.MetaData.artist;
@@ -2445,35 +2353,30 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &info, CAudiofileExt &fil
fileInfo += "Unknown";
}
file.firstChar = tolower(fileInfo[0]);
info += fileInfo;
//info += fileInfo;
}
//------------------------------------------------------------------------
void CAudioPlayerGui::addToPlaylist(CAudiofileExt &file)
{
//printf("add2Playlist: %s\n", file.Filename.c_str());
if (m_select_title_by_name)
{
if (!file.MetaData.bitrate)
{
std::string t = "";
getFileInfoToDisplay(t,file);
}
}
if (m_select_title_by_name) {
std::string t = "";
getFileInfoToDisplay(t,file);
} else
GetMetaData(file);
m_playlist.push_back(file);
m_playlistHasChanged = true;
}
//------------------------------------------------------------------------
void CAudioPlayerGui::removeFromPlaylist(long pos)
{
unsigned char firstChar = ' ';
// must be called before m_playlist.erase()
if (m_select_title_by_name)
{
// must be called before m_playlist.erase()
firstChar = getFirstChar(m_playlist[pos]);
}
unlink(m_playlist[pos].MetaData.cover.c_str());
//unlink(m_playlist[pos].MetaData.cover.c_str());
m_playlist.erase(m_playlist.begin() + pos);
m_playlistHasChanged = true;
@@ -2489,14 +2392,11 @@ void CAudioPlayerGui::removeFromPlaylist(long pos)
CTitle2Pos::iterator item = m_title2Pos.find(firstChar);
if (item != m_title2Pos.end())
{
//const CPosList::size_type del =
item->second.erase(pos);
// delete empty entries
if (item->second.empty())
{
m_title2Pos.erase(item);
}
}
else
{
@@ -2518,7 +2418,6 @@ void CAudioPlayerGui::removeFromPlaylist(long pos)
// old list is sorted so we can give a hint to insert at the end
newList.insert(newList.end(), p);
}
//title->second.clear();
title->second = newList;
}
#ifdef AUDIOPLAYER_TIME_DEBUG
@@ -2527,14 +2426,9 @@ void CAudioPlayerGui::removeFromPlaylist(long pos)
printf("delete took: ");
printTimevalDiff(start,end);
#endif
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::selectTitle(unsigned char selectionChar)
{
unsigned long i;
@@ -2574,7 +2468,6 @@ void CAudioPlayerGui::selectTitle(unsigned char selectionChar)
int prevselected = m_selected;
m_selected = i;
paintItem(prevselected - m_liststart);
unsigned int oldliststart = m_liststart;
m_liststart = (m_selected / m_listmaxshow)*m_listmaxshow;
//printf("before paint\n");
@@ -2584,10 +2477,10 @@ void CAudioPlayerGui::selectTitle(unsigned char selectionChar)
}
else
{
paintItem(prevselected - m_liststart);
paintItem(m_selected - m_liststart);
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::printSearchTree()
{
@@ -2608,8 +2501,6 @@ void CAudioPlayerGui::printSearchTree()
}
}
//------------------------------------------------------------------------
void CAudioPlayerGui::buildSearchTree()
{
@@ -2633,11 +2524,8 @@ void CAudioPlayerGui::buildSearchTree()
for (CAudioPlayList::iterator it=m_playlist.begin();
it!=m_playlist.end(); ++it)
{
// if (m_state == CAudioPlayerGui::PLAY)
// usleep(10*1000);
listPos++;
progress.showGlobalStatus(100*listPos / maxProgress);
//std::string info;
progress.showStatusMessageUTF(it->Filename);
unsigned char firstChar = getFirstChar(*it);
const std::pair<CTitle2Pos::iterator,bool> item =
@@ -2657,8 +2545,6 @@ void CAudioPlayerGui::buildSearchTree()
//printSearchTree();
}
//------------------------------------------------------------------------
unsigned char CAudioPlayerGui::getFirstChar(CAudiofileExt &file)
{
if (file.firstChar == '\0')
@@ -2670,8 +2556,6 @@ unsigned char CAudioPlayerGui::getFirstChar(CAudiofileExt &file)
return file.firstChar;
}
//------------------------------------------------------------------------
#ifdef AUDIOPLAYER_TIME_DEBUG
void CAudioPlayerGui::printTimevalDiff(timeval &start, timeval &end)
{
@@ -2687,8 +2571,6 @@ void CAudioPlayerGui::printTimevalDiff(timeval &start, timeval &end)
}
#endif
//------------------------------------------------------------------------
void CAudioPlayerGui::savePlaylist()
{
const char *path;
@@ -2719,9 +2601,8 @@ void CAudioPlayerGui::savePlaylist()
// add a trailing slash if necessary
if ((absPlaylistDir.empty()) || ((*(absPlaylistDir.rbegin()) != '/')))
{
absPlaylistDir += '/';
}
absPlaylistDir += file->getFileName();
const int filenamesize = 30;
@@ -2735,9 +2616,8 @@ void CAudioPlayerGui::savePlaylist()
name += file->getFileName();
bool overwrite = askToOverwriteFile(name);
if (!overwrite)
{
return;
}
snprintf(filename, name.size(), "%s", name.c_str());
}
else if (file->getType() == CFile::FILE_DIR)
@@ -2764,9 +2644,7 @@ void CAudioPlayerGui::savePlaylist()
{
bool overwrite = askToOverwriteFile(name);
if (!overwrite)
{
return;
}
}
input.close();
}
@@ -2816,9 +2694,9 @@ void CAudioPlayerGui::savePlaylist()
}
this->paint();
}
//------------------------------------------------------------------------
bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) {
bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename)
{
char msg[filename.length() + 127];
snprintf(msg,
@@ -2832,10 +2710,10 @@ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) {
this->paint();
return res;
}
//------------------------------------------------------------------------
std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir,
const std::string& absFilename) {
const std::string& absFilename)
{
std::string res = "";
int length = fromDir.length() < absFilename.length() ? fromDir.length() : absFilename.length();
@@ -2849,9 +2727,7 @@ std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir,
if (fromDir[i] == absFilename[i])
{
if (fromDir[i] == '/')
{
lastSlash = i;
}
}
else
{
@@ -2871,9 +2747,7 @@ std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir,
for (unsigned int i=0; i<relFromDir.size(); i++)
{
if (relFromDir[i] == '/')
{
res = res + "../";
}
}
res = res + relFilepath;