2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "ASAPCodec.h"
22 #include "utils/URIUtils.h"
23 #include "filesystem/File.h"
25 ASAPCodec::ASAPCodec()
30 ASAPCodec::~ASAPCodec()
34 bool ASAPCodec::Init(const CStdString &strFile, unsigned int filecache)
39 CStdString strFileToLoad = strFile;
41 CStdString strExtension;
42 URIUtils::GetExtension(strFile, strExtension);
43 strExtension.MakeLower();
44 if (strExtension == ".asapstream")
46 CStdString strFileName = URIUtils::GetFileName(strFile);
47 int iStart = strFileName.ReverseFind('-') + 1;
48 song = atoi(strFileName.substr(iStart, strFileName.size() - iStart - 11).c_str()) - 1;
49 CStdString strPath = strFile;
50 URIUtils::GetDirectory(strPath, strFileToLoad);
51 URIUtils::RemoveSlashAtEnd(strFileToLoad);
55 if (!m_dll.asapLoad(strFileToLoad.c_str(), song, &m_Channels, &duration))
57 m_TotalTime = duration;
60 m_DataFormat = AE_FMT_S16NE;
64 void ASAPCodec::DeInit()
68 int64_t ASAPCodec::Seek(int64_t iSeekTime)
70 m_dll.asapSeek((int) iSeekTime);
74 int ASAPCodec::ReadPCM(BYTE *pBuffer, int size, int *actualsize)
76 *actualsize = m_dll.asapGenerate(pBuffer, size);
77 if (*actualsize < size)
82 bool ASAPCodec::CanInit()
84 return m_dll.CanLoad();
87 bool ASAPCodec::IsSupportedFormat(const CStdString &strExt)
91 CStdString ext = strExt;
95 || ext == "cmc" || ext == "cmr" || ext == "dmc"
96 || ext == "mpt" || ext == "mpd" || ext == "rmt"
97 || ext == "tmc" || ext == "tm8" || ext == "tm2"
98 || ext == "cms" || ext == "cm3" || ext == "dlt";