aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/FileDialogs/QmmpFileDialog/qmmpfiledialogimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/FileDialogs/QmmpFileDialog/qmmpfiledialogimpl.h')
0 files changed, 0 insertions, 0 deletions
416f43607d83d518'>45117f6d2
5d057136d
d9d22bf78
45117f6d2

45117f6d2

40ee4f96d
45117f6d2



8ba3c4bc2

45117f6d2
095abc2e2
45117f6d2
5b5f8803d


8dd8b452d
45117f6d2


095abc2e2



5b5f8803d





8dd8b452d


095abc2e2
45117f6d2


1c8ce3f30
5b5f8803d
54e71369e
7acba956e
11b7655bb
54e71369e
5b5f8803d

095abc2e2
54e71369e
095abc2e2
11b7655bb
54e71369e
62904593c
54e71369e


11b7655bb
54e71369e
5b5f8803d

8dd8b452d





11b7655bb
8dd8b452d


095abc2e2
5c8df5c01
095abc2e2
11b7655bb
45117f6d2
095abc2e2
5c8df5c01
cb1f8ae27
79b25e9c3
5b5f8803d
49284bb0d
095abc2e2
136f634c6
49284bb0d
5b5f8803d
602a9f7bb
013ee07b5
45117f6d2

868b4f765
45117f6d2





095abc2e2

49284bb0d
45117f6d2

74fe5b8ff
fa722cca5
5b5f8803d
























fa722cca5
5b5f8803d

fa722cca5
5b5f8803d

c1d32fb90
5b5f8803d







45117f6d2

868b4f765
45117f6d2
095abc2e2
45117f6d2
5b5f8803d
d854da17a
5b5f8803d
232a83098
5b5f8803d












49284bb0d
602a9f7bb
5d057136d
5b5f8803d


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            

                                                                             
                
                      

                        

                                
                           



                        

                                          
 
                 
                  


                 
                


                         



                         





                        


                               
 


                             
                                     
                               
     
                                                 
                     
     

                                              
                               
     
                                                                              
                     
     
                                                         


                                                        
                     
     

                                         





                                                                                  
                         


                                            
                                
     
                                                   
                     
     
                              
 
                                            
                                                     
                                                      
                                                                    
                     
 
                                         
 
                                                     
                

 
                                    





                                    

                                                    
                                                             

 
                                                         
 
























                                                                
     

                            
     

                                                                  
                                                                   







                                            

 
                               
 
                                
 
 
                                         
 
                                                                                                         












                                                          
                                                                        
                                                         
                                                         


                         
/***************************************************************************
 *   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/fileinfo.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");
        return false;
    }
    m_length = m_parser->length(m_track);
    m_offset = m_parser->offset(m_track);
    if(!df->properties().noInput)
    {
        m_input = new QFile(m_path);
        if(!m_input->open(QIODevice::ReadOnly))
        {
            qWarning("DecoderCUE: error: %s", qPrintable(m_input->errorString()));
            return false;
        }
    }
    m_decoder = df->create(m_path, m_input);
    if(!m_decoder->initialize())
    {
        qWarning("DecoderCUE: invalid audio file");
        return false;
    }
    m_decoder->seek(m_offset);

    configure(m_decoder->audioParameters());
    setReplayGainInfo(m_parser->replayGain(m_track));
    length_in_bytes = audioParameters().sampleRate() *
                      audioParameters().frameSize() * m_length/1000;
    m_totalBytes = 0;

    m_sz = audioParameters().frameSize();

    addMetaData(m_parser->info(m_track)->metaData());
    return true;
}

qint64 DecoderCUE::totalTime() const
{
    return m_decoder ? m_length : 0;
}

void DecoderCUE::seek(qint64 pos)
{
     m_decoder->seek(m_offset + pos);
     m_totalBytes = audioParameters().sampleRate() *
                    audioParameters().frameSize() * pos/1000;
}

qint64 DecoderCUE::read(unsigned char *data, qint64 size)
{
    if(length_in_bytes - m_totalBytes < m_sz) //end of cue track
        return 0;

    qint64 len = 0;