aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Output/pulseaudio
Commit message (Expand)AuthorAgeFilesLines
* fixed translationtrialuser022009-10-041-0/+1
* removed obsolete qt macros, updated Russian translationtrialuser022009-09-191-1/+1
* updated Turkish translation (Bilgesu Güngör)trialuser022009-08-041-5/+5
* added Lithuanian translation (author: Algirdas Butkus)trialuser022009-07-273-1/+30
* updated Turkish translation (author: Bilgesu Güngör)trialuser022009-07-2311-33/+66
* added cygwin patches (yselkowitz AT gmail.com)trialuser022009-07-131-1/+1
* new decoder api, disabled broken pluginstrialuser022009-07-101-1/+0
* ported jack plugintrialuser022009-06-261-2/+2
* fixed pulse audio supporttrialuser022009-06-263-4/+5
* updated German translation (Panagiotis Papadopoulos)trialuser022009-05-301-5/+5
* fixed language detectiontrialuser022009-05-291-1/+1
* added Italian translation (author: Gian Paolo)trialuser022009-05-123-1/+30
* pulse audio plugin: 32-bit samples supporttrialuser022009-05-021-2/+15
* updated Polish translation (Grzegorz Gibas)trialuser022009-04-032-0/+28
* fixed pulse audio bugtrialuser022009-03-091-2/+8
* updated Czech translation (Karel Volný)trialuser022009-02-271-3/+3
* updated German translation (Panagiotis Papadopoulos)trialuser022008-12-251-3/+4
* output api changestrialuser022008-11-202-153/+31
* enabled pulse audio plugintrialuser022008-10-144-23/+26
* imported 0.2 fixestrialuser022008-09-021-2/+3
* fixed buildtrialuser022008-07-241-1/+1
* generate *.qm files by build scriptstrialuser022008-06-156-0/+0
* updated Ukrainian translation (author: Gennadi Motsyo)trialuser022008-06-154-1/+30
* updated Russian translationtrialuser022008-06-144-1/+29
* updated Chinese Traditional Translation (author: lon)trialuser022008-06-134-1/+29
* updated Chinese Simplified Translation (author: lon)trialuser022008-06-136-3/+29
* updated German translation (author: Stefan Koelling)trialuser022008-05-202-5/+6
* cmake 2.6 supporttrialuser022008-05-171-0/+4
* improved cmake scriptstrialuser022008-05-151-8/+6
* updated *.qm filestrialuser022008-05-142-0/+0
* updated Chezh translation (author: Karel Volny)trialuser022008-05-144-3/+38
* added *.ts filestrialuser022008-05-082-1/+27
* some cmake cleanuptrialuser022008-05-011-4/+0
* Pulse Audio output plugintrialuser022008-03-236-0/+510
s='alt'>
eb89e7912
d460e7652
eb89e7912

8d146b246

0391cde3e
eb89e7912



8d146b246

0391cde3e
8d146b246
362d4e2b4





eb89e7912


b917024aa
eb89e7912
8d146b246

362d4e2b4

8d146b246
362d4e2b4



8d146b246
d460e7652
4bb84c087
0391cde3e




3a2ef3199
0391cde3e





3a2ef3199
0391cde3e
997de8521















d460e7652

8d146b246
d460e7652
933204b47
d460e7652

4bb84c087
0391cde3e






































997de8521
0391cde3e
eb89e7912
362d4e2b4
eb89e7912

362d4e2b4


eb89e7912
362d4e2b4
5549fa67b
362d4e2b4



5549fa67b
362d4e2b4





845322411
362d4e2b4
845322411
b66a8c518



1d6f69e20
362d4e2b4
845322411
362d4e2b4
845322411
362d4e2b4
845322411
362d4e2b4



1d6f69e20
362d4e2b4







1d6f69e20
362d4e2b4








845322411
362d4e2b4








b66a8c518
b66a8c518

362d4e2b4









013ee07b5
362d4e2b4









013ee07b5
362d4e2b4




e6cdd7a53

362d4e2b4
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            

                                                                             
                  
                  


                           
                                     
                               
                        

                     
                                 

                              
                                                                        
                       
                                                         


                         
 
                  

                                  

                                         
     
 

                                                     

                                                                                                          
                                 
                   
     

                                                         

                                                                               
                         



                                                                  

                              
                                                        
     





                                       


                      
                         
     

                        

 
                                                 



                  
                                        
 
                       




                                                                      
     





                                                                                                                      
     
                     















                                                                                     

 
                                            
 
                                                              

 
                       






































                                                                            
      
 
                                                                                                                    
 

                  


                                         
  
 
                                        



                            
                                                           





                         
                                                
                      
                                                 



                                                          
                                                                                     
                     
                                                
                       
                                                  
                     
                                                



                                                       
                                                                                  







                                                         
                                                                                    








                                                                           
                                                 








                              
                           

                                                  









                               
                                               









                                         
                                                 




                               

                       
 
/***************************************************************************
 *   Copyright (C) 2009-2019 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 <QPixmap>
#include <QBuffer>
#include <taglib/tag.h>
#include <taglib/fileref.h>
#include <taglib/tmap.h>
#include <taglib/id3v2framefactory.h>
#include <taglib/flacpicture.h>
#ifndef HAS_PICTURE_LIST
#include <FLAC/all.h>
#endif
#include <qmmp/metadatamanager.h>
#include "flacmetadatamodel.h"

FLACMetaDataModel::FLACMetaDataModel(const QString &path, bool readOnly)
#ifdef HAS_PICTURE_LIST
    : MetaDataModel(true, MetaDataModel::IsCoverEditable)
#else
    : MetaDataModel(true)
#endif
{
    m_path = path;
    if(path.startsWith("flac://"))
    {
        m_path.remove("flac://");
        m_path.remove(QRegExp("#\\d+$"));
    }

    if(m_path.endsWith(".flac", Qt::CaseInsensitive))
    {
        m_stream = new TagLib::FileStream(QStringToFileName(m_path), readOnly);
        TagLib::FLAC::File *f = new TagLib::FLAC::File(m_stream, TagLib::ID3v2::FrameFactory::instance());
        m_tag = f->xiphComment();
        m_file = f;
    }
    else if(m_path.endsWith(".oga", Qt::CaseInsensitive))
    {
        m_stream = new TagLib::FileStream(QStringToFileName(m_path), readOnly);
        TagLib::Ogg::FLAC::File *f = new TagLib::Ogg::FLAC::File(m_stream);
        m_tag = f->tag();
        m_file = f;
    }

    if(m_file && m_file->isValid() && !path.startsWith("flac://"))
    {
        setReadOnly(readOnly);
        m_tags << new VorbisCommentModel(m_tag, m_file);
    }
}

FLACMetaDataModel::~FLACMetaDataModel()
{
    while(!m_tags.isEmpty())
        delete m_tags.takeFirst();
    if(m_file)
    {
        delete m_file;
        m_file = nullptr;
    }
    if(m_stream)
        delete m_stream;
}

QList<TagModel* > FLACMetaDataModel::tags() const
{
    return m_tags;
}

QPixmap FLACMetaDataModel::cover() const
{
#ifdef HAS_PICTURE_LIST
    if(!m_tag || m_tag->isEmpty())
        return QPixmap();

    TagLib::List<TagLib::FLAC::Picture *> list = m_tag->pictureList();
    for(uint i = 0; i < list.size(); ++i)
    {
        if(list[i]->type() == TagLib::FLAC::Picture::FrontCover)
        {
            QPixmap cover;
            cover.loadFromData(QByteArray(list[i]->data().data(), list[i]->data().size())); //read binary picture data
            return cover;
        }
    }
    return QPixmap();
#else
    //embedded cover
     QPixmap cover;
     FLAC__StreamMetadata *metadata;
     FLAC__metadata_get_picture (qPrintable(m_path),
                                 &metadata,
                                 FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER,
                                 0,0, -1,-1,-1,-1);
     if(metadata)
     {
         FLAC__StreamMetadata_Picture *pict = &metadata->data.picture;
         cover.loadFromData(QByteArray((char *)pict->data, (int) pict->data_length));
         FLAC__metadata_object_delete(metadata);
     }
     return cover;
#endif
}

QString FLACMetaDataModel::coverPath() const
{
    return MetaDataManager::instance()->findCoverFile(m_path);
}

#ifdef HAS_PICTURE_LIST
void FLACMetaDataModel::setCover(const QPixmap &pix)
{
    removeCover();
    if(m_tag && !m_tag->isEmpty())
    {
        TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture();
        picture->setType(TagLib::FLAC::Picture::FrontCover);

        QByteArray data;
        QBuffer buffer(&data);
        buffer.open(QIODevice::WriteOnly);
        pix.save(&buffer, "JPEG");
        picture->setMimeType("image/jpeg");
        picture->setData(TagLib::ByteVector(data.constData(), data.size()));
        m_tag->addPicture(picture);
        m_file->save();
    }
}

void FLACMetaDataModel::removeCover()
{
    if(m_tag && !m_tag->isEmpty())
    {
        bool save = false;
        TagLib::List<TagLib::FLAC::Picture *> list = m_tag->pictureList();
        for(uint i = 0; i < list.size(); ++i)
        {
            if(list[i]->type() == TagLib::FLAC::Picture::FrontCover)
            {
                m_tag->removePicture(list[i], false);
                save = true;
            }
        }