本文整理汇总了C++中metadb_handle_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ metadb_handle_ptr类的具体用法?C++ metadb_handle_ptr怎么用?C++ metadb_handle_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了metadb_handle_ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LRCTitleFormatCallback
std::wstring LyricSourceLRC::getSavePath(const metadb_handle_ptr &track)
{
std::string path = track->get_path();
std::wstring wpath = EncodingFunc::ToUTF16(path.substr(boost::find_last(path, "://").end() - path.begin()));
wpath = wpath.substr(0, wpath.find_last_of(L"."));
if(track->get_subsong_index() != 0)
wpath += boost::lexical_cast<std::wstring>(track->get_subsong_index());
wpath += L".lrc";
if(m_config["lrcsavepath"].length())
{
class LRCTitleFormatCallback : public main_thread_callback
{
private:
HANDLE m_event;
std::string *m_out;
const std::string &m_format;
const metadb_handle_ptr &m_track;
public:
LRCTitleFormatCallback(HANDLE event, std::string *out, const std::string &format, const metadb_handle_ptr &track) : m_event(event), m_format(format), m_out(out), m_track(track) {}
virtual void callback_run()
{
core_api::ensure_main_thread();
pfc::string8 out;
service_ptr_t<titleformat_object> script;
static_api_ptr_t<titleformat_compiler>()->compile(script, m_format.c_str());
m_track->format_title(NULL, out, script, NULL);
m_out->assign(out.get_ptr());
SetEvent(m_event);
}
};
std::wstring dirname = wpath.substr(0, wpath.find_last_of(L'\\') + 1);
std::wstring filename = wpath.substr(wpath.find_last_of(L"\\") + 1);
HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL);
std::string out;
std::string pathtmp = m_config["lrcsavepath"];
if(pathtmp.at(pathtmp.length() - 1) != '\\')
pathtmp += '\\';
service_ptr_t<LRCTitleFormatCallback> p_callback = new service_impl_t<LRCTitleFormatCallback>(event, &out, pathtmp, track);
static_api_ptr_t<main_thread_callback_manager>()->add_callback(p_callback);
p_callback.release();
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
wpath = EncodingFunc::ToUTF16(out);
if(PathIsRelative(wpath.c_str()))
wpath = dirname + wpath;
if(GetFileAttributes(wpath.c_str()) & FILE_ATTRIBUTE_DIRECTORY && (GetLastError() != ERROR_FILE_NOT_FOUND && GetLastError() != ERROR_PATH_NOT_FOUND))
wpath += filename;
return wpath;
}
if(path.find_first_of("file://") == std::string::npos)
return std::wstring(L"");
if(path.find_first_of("unpack://") == std::string::npos)
return std::wstring(L"");
return wpath;
}
示例2: update_metadata
void stream_encoders::update_metadata(metadb_handle_ptr p_track){
if(p_track!=0){
p_track->metadb_lock();
const file_info*p_info;
if(p_track->get_info_async_locked(p_info))
update_metadata(*p_info);
p_track->metadb_unlock();
}
}
示例3: query_scale
audio_sample t_replaygain_config::query_scale(const metadb_handle_ptr & p_object) const
{
audio_sample rv = 1.0;
p_object->metadb_lock();
const file_info * info;
if (p_object->get_info_async_locked(info))
rv = query_scale(*info);
p_object->metadb_unlock();
return rv;
}
示例4: isTrackByArtist
inline bool isTrackByArtist(const std::string& artist, const metadb_handle_ptr& track)
{
// todo: ignore slight differences, e.g. in punctuation
service_ptr_t<metadb_info_container> outInfo;
if(track->get_async_info_ref(outInfo))
{
const file_info& fileInfo = outInfo->info();
for(t_size j = 0; j < fileInfo.meta_get_count_by_name("artist"); j++)
{
if(stricmp_utf8(fileInfo.meta_get("artist", j), artist.c_str()) == 0)
{
return true;
}
}
for(t_size j = 0; j < fileInfo.meta_get_count_by_name("album artist"); j++)
{
if(stricmp_utf8(fileInfo.meta_get("album artist", j), artist.c_str()) == 0)
{
return true;
}
}
}
return false;
}
示例5: playlist_get_item_handle
bool playlist_manager::playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item)
{
enum_items_callback_retrieve_item callback;
playlist_enum_items(p_playlist,callback,bit_array_one(p_item));
p_out = callback.get_item();
return p_out.is_valid();
}
示例6: doesTrackHaveSimilarTitle
bool doesTrackHaveSimilarTitle(const std::string& title, const metadb_handle_ptr& track)
{
// todo: ignore slight differences, e.g. in punctuation
service_ptr_t<metadb_info_container> outInfo;
if (!track->get_async_info_ref(outInfo))
{
return false;
}
const file_info& fileInfo = outInfo->info();
if(!fileInfo.meta_exists("title"))
{
return false;
}
const std::string fileTitle = fileInfo.meta_get("title", 0);
if(stricmp_utf8(fileTitle.c_str(), title.c_str()) == 0)
{
return true;
}
else if(fileTitlesMatchExcludingBracketsOnLhs(fileTitle, title))
{
return true;
}
return false;
}
示例7: format_filename
void create_directory_helper::format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string8 & out)
{
pfc::string8 temp;
handle->format_title_legacy(p_hook,temp,spec,&titleformat_text_filter_impl_createdir());
temp.replace_char('/','\\');
temp.fix_filename_chars('_','\\');
out = temp;
}
示例8: replaceTrackInActivePlaylist
void replaceTrackInActivePlaylist(const metadb_handle_ptr& trackToReplace, const metadb_handle_ptr& replacement)
{
t_size index = 0;
static_api_ptr_t<playlist_manager> pm;
if(!pm->activeplaylist_find_item(trackToReplace, index))
{
console::printf("Couldn't find track in active playlist to replace it: %s", trackToReplace->get_path());
return;
}
if(!pm->activeplaylist_replace_item(index, replacement))
{
console::printf("Couldn't replace track in active playlist: %s", trackToReplace->get_path());
return;
}
}
示例9: getTitle
std::string getTitle(metadb_handle_ptr track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
return "";
}
const file_info& fileInfo = outInfo->info();
const bool has_title_tag = fileInfo.meta_exists("title");
if(!has_title_tag)
{
return "";
}
const char* title = fileInfo.meta_get("title", 0);
return title;
}
示例10: getArtist
std::string getArtist(metadb_handle_ptr track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
return "";
}
const file_info& fileInfo = outInfo->info();
const bool has_artist_tag = fileInfo.meta_exists("artist");
const bool has_album_artist_tag = fileInfo.meta_exists("album artist");
if(!(has_artist_tag || has_album_artist_tag))
{
return "";
}
const char* artistName = has_artist_tag ? fileInfo.meta_get("artist", 0) : fileInfo.meta_get("album artist", 0);
return artistName;
}
示例11: get_track_info
pfc::string8 get_track_info(const metadb_handle_ptr track, abort_callback &p_abort) {
pfc::string8 api_key = "803d3cbea0bbe50c61ab81c4fe5fe20f";
pfc::string8 url, page, artist_enc, title_enc;
const file_info *file_info;
const char *artist;
const char *title;
bool meta;
static_api_ptr_t<metadb> db;
db->database_lock();
meta = track->get_info_async_locked(file_info);
db->database_unlock();
if (meta && file_info->meta_exists("artist") &&
file_info->meta_exists("title")) {
artist = file_info->meta_get("artist", 0);
title = file_info->meta_get("title", 0);
} else {
throw pfc::exception("Unknown track");
}
pfc::urlEncode(artist_enc, artist);
pfc::urlEncode(title_enc, title);
url << "http://ws.audioscrobbler.com/2.0/?method=track.getInfo"
<< "&api_key=" << api_key << "&artist=" << artist_enc << "&track=" << title_enc;
console::print(url);
page = get_url(url, p_abort);
if (page.get_length() < 10) {
throw pfc::exception("Last.fm returned an empty page");
}
return page;
}
示例12: print_location
void console::print_location(const metadb_handle_ptr & src)
{
print_location(src->get_location());
}
示例13: calculateTrackRating
float calculateTrackRating(const std::string& title, const metadb_handle_ptr& track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
// Don't pick it we can't get any info.
return -1.0f;
}
const file_info& fileInfo = outInfo->info();
if (!fileInfo.meta_exists("title"))
{
// Don't pick it if it doesn't have a title.
return -1.0f;
}
float totalRating = 0.0f;
const std::string fileTitle = fileInfo.meta_get("title", 0);
// Assume title is already roughly correct.
if(stricmp_utf8(fileTitle.c_str(), title.c_str()) == 0)
{
static const float ratingForExactTitleMatch = 2.0f;
totalRating += ratingForExactTitleMatch;
}
else
{
static const float ratingForTitleMatchWithBrackets = 1.0f;
totalRating += ratingForTitleMatchWithBrackets;
}
if(fileInfo.meta_exists("PLAY_COUNTER"))
{
const int playCount = atoi(fileInfo.meta_get("PLAY_COUNTER",0));
static const float lowPlayCount = 0.0f;
static const float highPlayCount = 10.0f;
static const float lowPlayCountRating = 0.0f;
static const float highPlayCountRating = 0.5f;
const float playCountRating = maths::map(static_cast<float>(playCount), lowPlayCount, highPlayCount, lowPlayCountRating, highPlayCountRating);
totalRating += playCountRating;
}
const auto bitrate = fileInfo.info_get_bitrate();
static const float lowBitrate = 0.0f;
static const float highBitrate = 1000.0f;
static const float lowBitrateRating = 0.0f;
static const float highBitrateRating = 2.0f;
const float bitrateRating = maths::map(static_cast<float>(bitrate), lowBitrate, highBitrate, lowBitrateRating, highBitrateRating);
totalRating += bitrateRating;
static const float releaseTypeWeighting = 3.0f;
float releaseTypeRating = 0.55f; // Default for if nothing is set; assume it's somewhere between a live album and a soundtrack.
if(fileInfo.meta_exists("musicbrainz album type") || fileInfo.meta_exists("releasetype"))
{
const std::string albumType = fileInfo.meta_exists("musicbrainz album type") ? fileInfo.meta_get("musicbrainz album type", 0) : fileInfo.meta_get("releasetype", 0);
if(albumType == "album")
{
releaseTypeRating = 1.0f;
}
else if(albumType == "single")
{
releaseTypeRating = 0.9f;
}
else if(albumType == "compilation")
{
releaseTypeRating = 0.8f;
}
else if(albumType == "ep")
{
releaseTypeRating = 0.7f;
}
else if(albumType == "soundtrack")
{
releaseTypeRating = 0.6f;
}
else if(albumType == "live")
{
releaseTypeRating = 0.5f;
}
else if(albumType == "other")
{
releaseTypeRating = 0.4f;
}
else if(albumType == "remix")
{
releaseTypeRating = 0.3f;
//.........这里部分代码省略.........
示例14: on_playback_new_track
void SmoothArtUIE::on_playback_new_track(metadb_handle_ptr p_track)
{
GetArt(p_track->get_path());
}
示例15: handle_create_replace_path_canonical
void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) {
handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index()));
}