Esempio n. 1
0
SoundSourceProxy::SoundSourceProxy(const TrackPointer& pTrack)
    : m_pTrack(pTrack),
      m_url(getCanonicalUrlForTrack(pTrack.data())),
      m_soundSourceProviderRegistrations(findSoundSourceProviderRegistrations(m_url)),
      m_soundSourceProviderRegistrationIndex(0) {
    initSoundSource();
}
Esempio n. 2
0
SoundSourceProxy::SoundSourceProxy(
        const QUrl& url)
    : m_url(url),
      m_soundSourceProviderRegistrations(findSoundSourceProviderRegistrations(m_url)),
      m_soundSourceProviderRegistrationIndex(0) {
    initSoundSource();
}
SoundSourceProxy::SoundSourceProxy(const TrackPointer& pTrack)
    : m_pTrack(pTrack),
      m_url(QUrl::fromLocalFile(pTrack->getCanonicalLocation())),
      m_soundSourceProviderRegistrations(findSoundSourceProviderRegistrations(m_url)),
      m_soundSourceProviderRegistrationIndex(0) {
    initSoundSource();
}
Esempio n. 4
0
SoundSourceProxy::SoundSourceProxy(
        TrackPointer pTrack)
    : m_pTrack(std::move(pTrack)),
      m_url(getCanonicalUrlForTrack(m_pTrack.get())),
      m_soundSourceProviderRegistrations(findSoundSourceProviderRegistrations(m_url)),
      m_soundSourceProviderRegistrationIndex(0) {
    initSoundSource();
}
Esempio n. 5
0
mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(const mixxx::AudioSourceConfig& audioSrcCfg) {
    DEBUG_ASSERT(m_pTrack);
    while (!m_pAudioSource) {
        if (!m_pSoundSource) {
            qWarning() << "Failed to open AudioSource for file"
                       << getUrl().toString();
            return m_pAudioSource; // failure -> exit loop
        }
        const mixxx::SoundSource::OpenResult openResult = m_pSoundSource->open(audioSrcCfg);
        if (mixxx::SoundSource::OpenResult::UNSUPPORTED_FORMAT != openResult) {
            qDebug() << "Opened AudioSource for file"
                     << getUrl().toString()
                     << "with provider"
                     << getSoundSourceProvider()->getName();
            if ((mixxx::SoundSource::OpenResult::SUCCEEDED == openResult) && m_pSoundSource->verifyReadable()) {
                m_pAudioSource =
                        AudioSourceProxy::create(m_pTrack, m_pSoundSource);
                if (m_pAudioSource->isEmpty()) {
                    qWarning() << "Empty audio data in file"
                               << getUrl().toString();
                }
                // Overwrite metadata with actual audio properties
                if (m_pTrack) {
                    m_pTrack->setChannels(m_pAudioSource->getChannelCount());
                    m_pTrack->setSampleRate(m_pAudioSource->getSamplingRate());
                    if (m_pAudioSource->hasDuration()) {
                        m_pTrack->setDuration(m_pAudioSource->getDuration());
                    }
                    if (m_pAudioSource->hasBitrate()) {
                        m_pTrack->setBitrate(m_pAudioSource->getBitrate());
                    }
                }
                return m_pAudioSource; // success -> exit loop
            } else {
                qWarning() << "Invalid audio data in file"
                           << getUrl().toString();
                // Do NOT retry with the next SoundSource provider if
                // the file itself is malformed!
                m_pSoundSource->close();
                break; // exit loop
            }
        }
        qWarning() << "Failed to open AudioSource for file"
                   << getUrl().toString()
                   << "with provider"
                   << getSoundSourceProvider()->getName();
        // Continue with the next SoundSource provider
        nextSoundSourceProvider();
        initSoundSource();
    }
    // m_pSoundSource might be invalid when reaching this point
    qWarning() << "Failed to open AudioSource for file"
               << getUrl().toString();
    return m_pAudioSource;
}
Mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(const Mixxx::AudioSourceConfig& audioSrcCfg) {
    DEBUG_ASSERT(!m_pTrack.isNull());
    while (m_pAudioSource.isNull()) {
        if (m_pSoundSource.isNull()) {
            qWarning() << "Failed to open AudioSource for file"
                    << getUrl();
            return m_pAudioSource; // failure -> exit loop
        }
        if (OK == m_pSoundSource->open(audioSrcCfg)) {
            qDebug() << "Opened AudioSource for file"
                    << getUrl()
                    << "with provider"
                    << getSoundSourceProvider()->getName();
            if (m_pSoundSource->isValid()) {
                m_pAudioSource =
                        AudioSourceProxy::create(m_pTrack, m_pSoundSource);
                if (m_pAudioSource->isEmpty()) {
                    qWarning() << "Empty audio data in file"
                            << getUrl();
                }
                // Overwrite metadata with actual audio properties
                if (!m_pTrack.isNull()) {
                    m_pTrack->setChannels(m_pAudioSource->getChannelCount());
                    m_pTrack->setSampleRate(m_pAudioSource->getSamplingRate());
                    if (m_pAudioSource->hasDuration()) {
                        m_pTrack->setDuration(m_pAudioSource->getDuration());
                    }
                    if (m_pAudioSource->hasBitrate()) {
                        m_pTrack->setBitrate(m_pAudioSource->getBitrate());
                    }
                }
                return m_pAudioSource; // success -> exit loop
            } else {
                qWarning() << "Invalid audio data in file"
                        << getUrl();
                // Do NOT retry with the next SoundSource provider if
                // only the file itself is malformed!
                m_pSoundSource->close();
                break; // exit loop
            }
        }
        qWarning() << "Failed to open AudioSource for file"
                << getUrl()
                << "with provider"
                << getSoundSourceProvider()->getName();
        // Continue with the next SoundSource provider
        nextSoundSourceProvider();
        initSoundSource();
    }
    // m_pSoundSource might be invalid when reaching this point
    qWarning() << "Failed to open AudioSource for file"
            << getUrl();
    return m_pAudioSource;
}
Esempio n. 7
0
mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(const mixxx::AudioSource::OpenParams& params) {
    DEBUG_ASSERT(m_pTrack);
    auto openMode = mixxx::SoundSource::OpenMode::Strict;
    while (m_pSoundSource && !m_pAudioSource) {
        // NOTE(uklotzde): Log unconditionally (with debug level) to
        // identify files in the log file that might have caused a
        // crash while importing metadata or decoding audio subsequently.
        kLogger.debug() << "Opening file"
                << getUrl().toString()
                << "with provider"
                << getSoundSourceProvider()->getName()
                << "using mode"
                << openMode;
        const mixxx::SoundSource::OpenResult openResult =
                m_pSoundSource->open(openMode, params);
        if ((openResult == mixxx::SoundSource::OpenResult::Aborted) ||
                ((openMode == mixxx::SoundSource::OpenMode::Strict) && (openResult == mixxx::SoundSource::OpenResult::Failed))) {
            kLogger.warning() << "Unable to open file"
                    << getUrl().toString()
                    << "with provider"
                    << getSoundSourceProvider()->getName()
                    << "using mode"
                    << openMode;
            // Continue with the next SoundSource provider
            nextSoundSourceProvider();
            if (!getSoundSourceProvider() && (openMode == mixxx::SoundSource::OpenMode::Strict)) {
                // No provider was able to open the source in Strict mode.
                // Retry to open the file in Permissive mode starting with
                // the first provider...
                m_soundSourceProviderRegistrationIndex = 0;
                openMode = mixxx::SoundSource::OpenMode::Permissive;
            }
            initSoundSource();
            continue; // try again
        }
        if ((openResult == mixxx::SoundSource::OpenResult::Succeeded) && m_pSoundSource->verifyReadable()) {
            m_pAudioSource = mixxx::AudioSourceTrackProxy::create(m_pTrack, m_pSoundSource);
            DEBUG_ASSERT(m_pAudioSource);
            if (m_pAudioSource->frameIndexRange().empty()) {
                kLogger.warning() << "File is empty"
                           << getUrl().toString();
            }
            // Overwrite metadata with actual audio properties
            if (m_pTrack) {
                DEBUG_ASSERT(m_pAudioSource->channelCount().valid());
                m_pTrack->setChannels(m_pAudioSource->channelCount());
                DEBUG_ASSERT(m_pAudioSource->sampleRate().valid());
                m_pTrack->setSampleRate(m_pAudioSource->sampleRate());
                if (m_pAudioSource->hasDuration()) {
                    // optional property
                    m_pTrack->setDuration(m_pAudioSource->getDuration());
                }
                if (m_pAudioSource->bitrate() != mixxx::AudioSource::Bitrate()) {
                    // optional property
                    m_pTrack->setBitrate(m_pAudioSource->bitrate());
                }
            }
        } else {
            kLogger.warning() << "Failed to open file"
                       << getUrl().toString()
                       << "with provider"
                       << getSoundSourceProvider()->getName();
            if (openResult == mixxx::SoundSource::OpenResult::Succeeded) {
                m_pSoundSource->close(); // cleanup
            }
            // Do NOT retry with the next SoundSource provider if the file
            // itself is the cause!
            DEBUG_ASSERT(!m_pAudioSource);
        }
        return m_pAudioSource; // either success or failure
    }
    // All available providers have returned OpenResult::Aborted when
    // getting here. m_pSoundSource might already be invalid/null!
    kLogger.warning() << "Unable to decode file"
            << getUrl().toString();
    DEBUG_ASSERT(!m_pAudioSource);
    return m_pAudioSource;
}