bool CAudioDecoder::Create(const CFileItem &file, __int64 seekOffset, unsigned int nBufferSize) { Destroy(); CSingleLock lock(m_critSection); // create our pcm buffer m_pcmBuffer.Create((int)std::max<unsigned int>(2, nBufferSize) * INTERNAL_BUFFER_LENGTH); // reset our playback timing variables m_eof = false; // get correct cache size unsigned int filecache = g_guiSettings.GetInt("cacheaudio.lan"); if ( file.IsHD() ) filecache = g_guiSettings.GetInt("cache.harddisk"); else if ( file.IsOnDVD() ) filecache = g_guiSettings.GetInt("cacheaudio.dvdrom"); else if ( file.IsInternetStream() ) filecache = g_guiSettings.GetInt("cacheaudio.internet"); // create our codec bool codecInitialized = false; m_codec=CodecFactory::CreateCodecDemux(file.m_strPath, file.GetContentType(), filecache * 1024, codecInitialized); if (!m_codec || (!codecInitialized && !m_codec->Init(file.m_strPath, filecache * 1024))) { CLog::Log(LOGERROR, "CAudioDecoder: Unable to Init Codec while loading file %s", file.m_strPath.c_str()); Destroy(); return false; } m_blockSize = m_codec->m_Channels * m_codec->m_BitsPerSample / 8; if( m_codec->UseHWDecoding() || m_codec->UsePassthrough() ) m_outputUnitSize = sizeof(char); else m_outputUnitSize = sizeof(float); if (seekOffset) m_codec->Seek(seekOffset); m_status = STATUS_QUEUING; return true; }
bool CAudioDecoder::Create(const CFileItem &file, __int64 seekOffset, unsigned int nBufferSize) { Destroy(); CSingleLock lock(m_critSection); // create our pcm buffer m_pcmBuffer.Create((int)std::max<unsigned int>(2, nBufferSize) * INTERNAL_BUFFER_LENGTH); // reset our playback timing variables m_eof = false; // get correct cache size unsigned int filecache = g_guiSettings.GetInt("cacheaudio.internet"); if ( file.IsHD() ) filecache = g_guiSettings.GetInt("cache.harddisk"); else if ( file.IsOnDVD() ) filecache = g_guiSettings.GetInt("cacheaudio.dvdrom"); else if ( file.IsOnLAN() ) filecache = g_guiSettings.GetInt("cacheaudio.lan"); // create our codec m_codec=CodecFactory::CreateCodecDemux(file.GetPath(), file.GetMimeType(), filecache * 1024); if (!m_codec || !m_codec->Init(file.GetPath(), filecache * 1024)) { CLog::Log(LOGERROR, "CAudioDecoder: Unable to Init Codec while loading file %s", file.GetPath().c_str()); Destroy(); return false; } m_blockSize = m_codec->m_Channels * m_codec->m_BitsPerSample / 8; // set total time from the given tag if (file.HasMusicInfoTag() && file.GetMusicInfoTag()->GetDuration()) m_codec->SetTotalTime(file.GetMusicInfoTag()->GetDuration()); if (seekOffset) m_codec->Seek(seekOffset); m_status = STATUS_QUEUING; return true; }
void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str()); if (m_bStreamDetails && !item.HasVideoInfoTag()) return; if (m_tAudio >= 0 && (m_tAudio > 0) != item.IsAudio()) return; if (m_tVideo >= 0 && (m_tVideo > 0) != item.IsVideo()) return; if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != item.IsInternetStream()) return; if (m_tRemote >= 0 && (m_tRemote > 0) != item.IsRemote()) return; if (m_tBD >= 0 && (m_tBD > 0) != (item.IsBDFile() && item.IsOnDVD())) return; if (m_tDVD >= 0 && (m_tDVD > 0) != item.IsDVD()) return; if (m_tDVDFile >= 0 && (m_tDVDFile > 0) != item.IsDVDFile()) return; if (m_tDVDImage >= 0 && (m_tDVDImage > 0) != item.IsDVDImage()) return; CRegExp regExp(false, CRegExp::autoUtf8); if (m_bStreamDetails) { if (!item.GetVideoInfoTag()->HasStreamDetails()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: cannot check rule: %s, no StreamDetails", m_name.c_str()); return; } CStreamDetails streamDetails = item.GetVideoInfoTag()->m_streamDetails; if (CompileRegExp(m_audioCodec, regExp) && !MatchesRegExp(streamDetails.GetAudioCodec(), regExp)) return; std::stringstream itoa; itoa << streamDetails.GetAudioChannels(); std::string audioChannelsstr = itoa.str(); if (CompileRegExp(m_audioChannels, regExp) && !MatchesRegExp(audioChannelsstr, regExp)) return; if (CompileRegExp(m_videoCodec, regExp) && !MatchesRegExp(streamDetails.GetVideoCodec(), regExp)) return; if (CompileRegExp(m_videoResolution, regExp) && !MatchesRegExp(CStreamDetails::VideoDimsToResolutionDescription(streamDetails.GetVideoWidth(), streamDetails.GetVideoHeight()), regExp)) return; if (CompileRegExp(m_videoAspect, regExp) && !MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return; } CURL url(item.GetPath()); if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return; if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return; if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return; if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return; CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str()); for (unsigned int i = 0; i < vecSubRules.size(); i++) vecSubRules[i]->GetPlayers(item, vecCores); PLAYERCOREID playerCoreId = GetPlayerCore(); if (playerCoreId != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s (%d) for rule: %s", m_playerName.c_str(), playerCoreId, m_name.c_str()); vecCores.push_back(GetPlayerCore()); } }