atches
aboutsummaryrefslogblamecommitdiff
path: root/src/plugins/Input/cue/decoder_cue.cpp
blob: e21dfdca52f5c259dd8ebcb768307dc8eaf31130 (plain) (tree)
1
2
3
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            

                                                                             
                
                      

                        
                           
                                
                           



                        

                                          
 
                 
                  


                 
                


                         



                         





                        


                               
 


                             
                                     
                               
     
                                                 
                     
     

                                              
                               
     
                                                                              
                     
     
                                                         


                                                        
                     
     
                                           
                                         





                                                                                  
                         


                                            
                                
     
                                                   
                     
     
                              
 
                                            
                                                     
                                                      
                                                                    
                     
 
                                         
 
                                                     
                

 
                                    





                                    

                                                    
                                                             

 
                                                         
 
























                                                                
     

                            
     

                                                                  
                                                                   







                                            

 
                               
 
                                
 
 
                                         
 
                                                                                                         









                                               
                                               

                                                          
                                                                        
                                                         
                                                         


                         
/***************************************************************************
 *   Copyright (C) 2008-2017 by Ilya Kotov                                 *
 *   forkotov02@ya.ru                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QFile>
#include <QStringList>
#include <qmmp/buffer.h>
#include <qmmp/output.h>
#include <qmmp/trackinfo.h>
#include <qmmp/decoderfactory.h>
#include <qmmp/soundcore.h>
#include "cueparser.h"
#include "decoder_cue.h"


DecoderCUE::DecoderCUE(const QString &url)
        : Decoder()
{
    m_path = url;
    m_decoder = 0;
    m_parser = 0;
    m_track = 0;
    m_buf = 0;
    m_input = 0;
}

DecoderCUE::~DecoderCUE()
{
    if(m_decoder)
        delete m_decoder;
    m_decoder = 0;
    if(m_parser)
        delete m_parser;
    m_parser = 0;
    if(m_buf)
        delete [] m_buf;
    m_buf = 0;
    if(m_input)
        m_input->deleteLater();
    m_input = 0;
}

bool DecoderCUE::initialize()
{
    m_parser = new CUEParser(m_path);
    if (m_parser->count() == 0)
    {
        qWarning("DecoderCUE: invalid cue file");
        return false;
    }
    m_track = m_path.section("#", -1).toInt();
    m_path = m_parser->filePath(m_track);
    if (!QFile::exists(m_path))
    {
        qWarning("DecoderCUE: file \"%s\" doesn't exist", qPrintable(m_path));
        return false;
    }
    DecoderFactory *df = Decoder::findByFilePath(m_path);
    if (!df)
    {
        qWarning("DecoderCUE: unsupported file format");