aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/vorbis/decoder_vorbis.cpp
Commit message (Expand)AuthorAgeFilesLines
* fixed build with -Werror=zero-as-null-pointer-constanttrialuser022019-01-031-2/+2
* removed unused codetrialuser022018-05-271-2/+1
* enabled vorbis plugintrialuser022018-05-131-2/+0
* fixed memory leak; fixed other potential problemstrialuser022017-10-261-0/+2
* coding style fixestrialuser022016-10-291-0/+1
* changed decoder apitrialuser022016-09-141-2/+2
* removed useless codetrialuser022016-08-011-10/+0
* using float output in the mpeg and vorbis pluginstrialuser022015-12-271-25/+14
* using unsigned char for raw datatrialuser022015-12-061-2/+2
* fixed vorbis plugintrialuser022014-10-061-1/+72
* fixed gcc 4.8 supporttrialuser022013-10-231-1/+1
* vorbis: added peak overflow supporttrialuser022013-10-161-0/+29
* fixed build regression (thanks to Motsyo Gennadi)trialuser022013-05-191-0/+1
* marking recycler as private apitrialuser022012-12-071-2/+1
* decoder api changes: removed StateHandler usagetrialuser022011-09-171-2/+1
* reapplied previous patchtrialuser022010-03-111-5/+5
* removed obsolete memberstrialuser022010-03-111-2/+2
* updated audio enginetrialuser022010-01-161-1/+1
* fixed vorbis stream metadatatrialuser022010-01-071-2/+3
* ogg vorbis plugin: added replay gain supporttrialuser022009-12-271-7/+1
* enabled vorbis plugin, fixed translationtrialuser022009-09-191-6/+6
* vorbis plugin: added support for composer and disc number tagstrialuser022009-08-081-0/+8
* fixed problem with qt4.4trialuser022009-08-041-2/+2
* mpeg plugin: fixed problem with small filestrialuser022009-07-191-3/+2
* new decoder api, disabled broken pluginstrialuser022009-07-101-177/+30
* fixed buildtrialuser022009-05-141-1/+1
* improved seeking accuracytrialuser022009-03-071-8/+8
* removed unused codetrialuser022008-11-231-31/+2
* cue sheet supporttrialuser022008-10-101-1/+1
* some api changes; enabled ogg vorbis plugintrialuser022008-09-261-63/+50
* include path changestrialuser022008-02-081-7/+7
* new directory structurevovanec2008-02-071-0/+425
/qmmp/commit/src/display.cpp?id=2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12'>2d622fd9b
0bea3c894
0e860ae0b
85cd9c127
0bea3c894
0e860ae0b
85cd9c127
2d622fd9b
0bea3c894
0e860ae0b
2d622fd9b
85cd9c127
0bea3c894
0e860ae0b
85cd9c127
2d622fd9b
0bea3c894

0bea3c894
97c98d9d5
0bea3c894
2d622fd9b
2d622fd9b

85cd9c127
d7149af86

09d1eb079
2d622fd9b

85cd9c127
d7149af86

09d1eb079

30e11dd37




2d622fd9b
bfe01d737
01235bdb7


a915b21a9
01235bdb7

d7149af86

97c98d9d5
d7149af86




92f1159a1


97c98d9d5

2d622fd9b

2d622fd9b

ae75e5707
fa1e4194b
3f108f4f4
2d622fd9b

97c98d9d5























bfe01d737
97c98d9d5

0e860ae0b
2d622fd9b
97c98d9d5
0b46e2db0
2d622fd9b
0e860ae0b
2d622fd9b
30e11dd37
0b46e2db0
2d622fd9b

0e860ae0b




0e860ae0b
013ee07b5
0b46e2db0
0e860ae0b
0e860ae0b
0e860ae0b

0e860ae0b
0e860ae0b

11b7655bb
97c98d9d5
30e11dd37
97c98d9d5
0e860ae0b

080507d3a
2d622fd9b

0bea3c894
97c98d9d5
26da2f9c1
97c98d9d5



























2d622fd9b

a915b21a9
0e860ae0b
a915b21a9
0e860ae0b
2295f52f6
0bea3c894
2d622fd9b

38c7065ba
2295f52f6




d0e1f9e4e
2295f52f6




2d622fd9b

0bea3c894
2d622fd9b

38c7065ba
2295f52f6




d0e1f9e4e
2295f52f6


1e7a7fdfd

2d622fd9b

2d622fd9b









d7149af86
2d622fd9b
09d1eb079










2d622fd9b

30e11dd37


178b0feca
30e11dd37










2d622fd9b

d7149af86
2d622fd9b













38c7065ba
2d622fd9b



38c7065ba
2d622fd9b

080507d3a

0bea3c894
080507d3a
bfe01d737

080507d3a

97c98d9d5
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
                                                                            
                                                                            














                                                                            
                                                                            
                                                                             

                       
                    
                
                           
                               
                                   
                                  














                          
                          

                    
                                             
                               
 
                     
                              
                                  
                                                   
                  

                                    
                                
















                                                                                               

                                                                   
                                                                        
                                  
 
                                                                          
                                                                        
                                            
                                                                          
                                                                        
                                           
 
                                                                                
                                                                              
                                                                                       
                                                      
                                                                                   
                                                                                 
                                               
                                                                                     

                                       
                                       
                                     
                                       
                                        

                                      
                                          

                                                                         
                                                                        

                                        
                                            

                                                                          

                                                                         




                                                                        
                                              
                                      


                                                                             
                                                                                     

                                                                                      

                                                                                    
                                                                                      




                                                                                   


                                                                                                      

                      

 

                           
                                                                  
                                                                     
                                                                     

 























                                        
                                                     

 
                                    
 
                           
                                     
 
                                       
 
                             
                                             

 




                                             
                                                  
                                                 
                                         
              
                      

                                                   
                       

                                                  
                                                  
                               
                                 
                                

     
 

                              
                                  
                         
                                                   



























                                                                                    

 
                                             
 
                                     
 
                                
                                    

                   
                                                     




                                                                               
                                                   




                                                                                      

 
                                    

                   
                                                     




                                                                              
                                                   


                                                                            

                                                                                        

 









                                            
                                 
 










                                                                                 

 


                                       
                   










                                                                                                  

                                             
                                        













                                           
                                    



                                        
                                     

 

                                                 
                                       
                                           

                                                                         

                                     
 
/***************************************************************************
 *   Copyright (C) 2006-2014 by Ilya Kotov                                 *
 *   forkotov02@hotmail.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 <QApplication>
#include <QSettings>
#include <QMenu>
#include <qmmp/soundcore.h>
#include <qmmpui/mediaplayer.h>
#include <qmmpui/playlistmanager.h>
#include <qmmpui/qmmpuisettings.h>
#include "skin.h"
#include "mainvisual.h"
#include "button.h"
#include "titlebar.h"
#include "positionbar.h"
#include "number.h"
#include "togglebutton.h"
#include "symboldisplay.h"
#include "textscroller.h"
#include "monostereo.h"
#include "playstatus.h"
#include "volumebar.h"
#include "balancebar.h"
#include "mainwindow.h"
#include "timeindicator.h"
#include "actionmanager.h"
#include "display.h"

MainDisplay::MainDisplay (MainWindow *parent)
        : PixmapWidget (parent)
{
    m_shaded = false;
    m_skin = Skin::instance();
    setPixmap (m_skin->getMain());
    setCursor(m_skin->getCursor(Skin::CUR_NORMAL));
    m_mw = parent;
    m_titlebar = new TitleBar(this);
    m_titlebar->move(0,0);
    m_titlebar->setActive(true);
    m_previous = new Button (this, Skin::BT_PREVIOUS_N, Skin::BT_PREVIOUS_P, Skin::CUR_NORMAL);
    m_previous->setToolTip(tr("Previous"));
    connect (m_previous, SIGNAL (clicked()), parent, SLOT (previous()));

    m_play = new Button (this, Skin::BT_PLAY_N, Skin::BT_PLAY_P, Skin::CUR_NORMAL);
    m_play->setToolTip(tr("Play"));
    connect (m_play, SIGNAL (clicked()),parent,SLOT (play()));
    m_pause = new Button (this, Skin::BT_PAUSE_N,Skin::BT_PAUSE_P, Skin::CUR_NORMAL);
    m_pause->setToolTip(tr("Pause"));
    connect (m_pause,SIGNAL (clicked()),parent,SLOT (pause()));
    m_stop = new Button (this, Skin::BT_STOP_N,Skin::BT_STOP_P, Skin::CUR_NORMAL);
    m_stop->setToolTip(tr("Stop"));
    connect (m_stop,SIGNAL (clicked()),parent,SLOT (stop()));
    m_next = new Button (this, Skin::BT_NEXT_N,Skin::BT_NEXT_P, Skin::CUR_NORMAL);
    m_next->setToolTip(tr("Next"));
    connect (m_next,SIGNAL (clicked()),parent,SLOT (next()));
    m_eject = new Button (this, Skin::BT_EJECT_N,Skin::BT_EJECT_P, Skin::CUR_NORMAL);
    m_eject->setToolTip(tr("Play files"));
    connect (m_eject,SIGNAL (clicked()),parent, SLOT(playFiles()));
    connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin()));
    m_vis = new MainVisual (this);

    m_eqButton = new ToggleButton (this,Skin::BT_EQ_ON_N,Skin::BT_EQ_ON_P,
                                   Skin::BT_EQ_OFF_N,Skin::BT_EQ_OFF_P);
    m_eqButton->setToolTip(tr("Equalizer"));
    m_plButton = new ToggleButton (this,Skin::BT_PL_ON_N,Skin::BT_PL_ON_P,
                                   Skin::BT_PL_OFF_N,Skin::BT_PL_OFF_P);
    m_plButton->setToolTip(tr("Playlist"));

    m_repeatButton = new ToggleButton (this,Skin::REPEAT_ON_N,Skin::REPEAT_ON_P,
                                       Skin::REPEAT_OFF_N,Skin::REPEAT_OFF_P);
    connect(m_repeatButton,SIGNAL(clicked(bool)),this,SIGNAL(repeatableToggled(bool)));
    m_repeatButton->setToolTip(tr("Repeat playlist"));
    m_shuffleButton = new ToggleButton (this,Skin::SHUFFLE_ON_N,Skin::SHUFFLE_ON_P,
                                        Skin::SHUFFLE_OFF_N,Skin::SHUFFLE_OFF_P);
    m_shuffleButton->setToolTip(tr("Shuffle"));
    connect(m_shuffleButton,SIGNAL(clicked(bool)),this,SIGNAL(shuffleToggled(bool)));

    m_kbps = new SymbolDisplay(this,3);
    m_freq = new SymbolDisplay(this,2);
    m_text = new TextScroller (this);
    m_monoster = new MonoStereo (this);
    m_playstatus = new PlayStatus(this);

    m_volumeBar = new VolumeBar(this);
    m_volumeBar->setToolTip(tr("Volume"));
    connect(m_volumeBar, SIGNAL(sliderMoved(int)),SLOT(displayVolume()));
    connect(m_volumeBar, SIGNAL(sliderPressed()),SLOT(displayVolume()));
    connect(m_volumeBar, SIGNAL(sliderReleased()),m_text,SLOT(clear()));

    m_balanceBar = new BalanceBar(this);
    m_balanceBar->setToolTip(tr("Balance"));
    connect(m_balanceBar, SIGNAL(sliderMoved(int)),SLOT(displayVolume()));
    connect(m_balanceBar, SIGNAL(sliderPressed()),SLOT(displayVolume()));
    connect(m_balanceBar, SIGNAL(sliderReleased()),m_text,SLOT(clear()));

    m_posbar = new PositionBar(this);
    connect(m_posbar, SIGNAL(sliderPressed()),SLOT(showPosition()));
    connect(m_posbar, SIGNAL(sliderMoved(qint64)),SLOT(showPosition()));
    connect(m_posbar, SIGNAL(sliderReleased()),SLOT(updatePosition()));

    m_timeIndicator = new TimeIndicator(this);
    m_aboutWidget = new QWidget(this);
    m_core = SoundCore::instance();
    connect(m_core, SIGNAL(elapsedChanged(qint64)), SLOT(setTime(qint64)));
    connect(m_core, SIGNAL(bitrateChanged(int)), m_kbps, SLOT(display(int)));
    connect(m_core, SIGNAL(frequencyChanged(quint32)), SLOT(setSampleRate(quint32)));
    connect(m_core, SIGNAL(channelsChanged(int)), m_monoster, SLOT(setChannels(int)));
    connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(setState(Qmmp::State)));
    connect(m_core, SIGNAL(volumeChanged(int)), m_volumeBar, SLOT(setValue(int)));
    connect(m_core, SIGNAL(balanceChanged(int)), m_balanceBar, SLOT(setValue(int)));
    connect(m_core, SIGNAL(elapsedChanged(qint64)),m_titlebar, SLOT(setTime(qint64)));
    connect(m_balanceBar, SIGNAL(sliderMoved(int)), m_core, SLOT(setBalance(int)));
    connect(m_volumeBar, SIGNAL(sliderMoved(int)), m_core, SLOT(setVolume(int)));
    m_volumeBar->setValue(m_core->volume());
    m_balanceBar->setValue(m_core->balance());

    QmmpUiSettings *ui_settings = QmmpUiSettings::instance();
    connect(ui_settings, SIGNAL(repeatableListChanged(bool)), m_repeatButton, SLOT(setChecked(bool)));
    connect(ui_settings, SIGNAL(shuffleChanged(bool)), m_shuffleButton, SLOT(setChecked(bool)));
    updatePositions();
    updateMask();
}

MainDisplay::~MainDisplay()
{
    QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
    settings.setValue ("Skinned/pl_visible",m_plButton->isChecked());
    settings.setValue ("Skinned/eq_visible",m_eqButton->isChecked());
}

void MainDisplay::updatePositions()
{
    int r = m_skin->ratio();
    m_previous->move (r*16, r*88);
    m_play->move (r*39,  r*88);
    m_pause->move (r*62,  r*88);
    m_vis->move(r*24,  r*43);
    m_stop->move (r*85,  r*88);
    m_next->move (r*108, r*88);
    m_eject->move (r*136, r*89);
    m_posbar->move (r*16, r*72);
    m_eqButton->move (r*219, r*58);
    m_plButton->move (r*241, r*58);
    m_repeatButton->move (r*210, r*89);
    m_shuffleButton->move (r*164, r*89);
    m_kbps->move (r*111, r*43);
    m_freq->move (r*156, r*43);
    m_text->resize (r*154, r*15);
    m_text->move (r*109, r*23);
    m_monoster->move (r*212, r*41);
    m_playstatus->move(r*24, r*28);
    m_volumeBar->move(r*107, r*57);
    m_balanceBar->move(r*177, r*57);
    m_timeIndicator->move(r*34, r*26);
    m_aboutWidget->setGeometry(r*247,r*83,r*20,r*25);
}

void MainDisplay::setTime (qint64 t)
{
    m_posbar->setValue (t);
    m_timeIndicator->setTime(t/1000);
}
void MainDisplay::setDuration(qint64 t)
{
    m_posbar->setMaximum (t);
    m_timeIndicator->setSongDuration(t/1000);
}

void MainDisplay::setState(Qmmp::State state)
{
    switch ((int) state)
    {
    case Qmmp::Playing:
        m_playstatus->setStatus(PlayStatus::PLAY);
        m_timeIndicator->setNeedToShowTime(true);
        setDuration(m_core->totalTime());
        break;
    case Qmmp::Paused:
        m_playstatus->setStatus(PlayStatus::PAUSE);
        break;
    case Qmmp::Stopped:
        m_playstatus->setStatus(PlayStatus::STOP);
        m_monoster->setChannels (0);
        m_timeIndicator->setNeedToShowTime(false);
        m_posbar->setValue (0);
        m_posbar->setMaximum (0);
        m_titlebar->setTime(-1);
    }
}

void MainDisplay::updateSkin()
{
    setPixmap (m_skin->getMain());
    m_mw->resize(size());
    setCursor(m_skin->getCursor(Skin::CUR_NORMAL));
    setMinimalMode(m_shaded);
    updatePositions();
}

void MainDisplay::updateMask()
{
    m_mw->clearMask();
    m_mw->setMask(QRegion(0,0,m_mw->width(),m_mw->height()));
    QRegion region = m_skin->getRegion(m_shaded? Skin::WINDOW_SHADE : Skin::NORMAL);
    if (!region.isEmpty())
        m_mw->setMask(region);
}

void MainDisplay::setMinimalMode(bool b)
{
    m_shaded = b;
    int r = m_skin->ratio();

    if(m_shaded)
         m_mw->resize(r*275,r*14);
    else
         m_mw->resize(r*275,r*116);
    updateMask();
}

void MainDisplay::setActive(bool b)
{
    m_titlebar->setActive(b);
}

void MainDisplay::setSampleRate(quint32 rate)
{
    m_freq->display((int) rate/1000);
}
//TODO optimize this connections
void MainDisplay::setEQ (QWidget* w)
{
    m_equlizer = w;
    m_eqButton->setChecked (m_equlizer->isVisible());
    ACTION(ActionManager::SHOW_EQUALIZER)->setChecked(m_equlizer->isVisible());

    connect (ACTION(ActionManager::SHOW_EQUALIZER), SIGNAL(triggered(bool)),
             m_equlizer, SLOT (setVisible (bool)));
    connect (ACTION(ActionManager::SHOW_EQUALIZER), SIGNAL(triggered(bool)),
             m_eqButton, SLOT (setChecked (bool)));

    connect (m_eqButton, SIGNAL(clicked(bool)),
             ACTION(ActionManager::SHOW_EQUALIZER), SLOT(setChecked (bool)));
    connect (m_eqButton, SIGNAL(clicked(bool)), m_equlizer, SLOT (setVisible (bool)));
    connect (m_equlizer, SIGNAL(closed ()), m_eqButton, SLOT (click()));
}

void MainDisplay::setPL (QWidget* w)
{
    m_playlist = w;
    m_plButton->setChecked (m_playlist->isVisible());
    ACTION(ActionManager::SHOW_PLAYLIST)->setChecked(m_playlist->isVisible());

    connect (ACTION(ActionManager::SHOW_PLAYLIST), SIGNAL(triggered(bool)),
             m_playlist, SLOT (setVisible (bool)));
    connect (ACTION(ActionManager::SHOW_PLAYLIST), SIGNAL(triggered(bool)),
             m_plButton, SLOT (setChecked (bool)));

    connect (m_plButton, SIGNAL(clicked(bool)),
             ACTION(ActionManager::SHOW_PLAYLIST), SLOT(setChecked (bool)));
    connect (m_plButton, SIGNAL (clicked (bool)), m_playlist, SLOT (setVisible (bool)));
    connect (m_playlist, SIGNAL (closed ()), m_plButton, SLOT (click()));
}

bool MainDisplay::isPlaylistVisible() const
{
    return m_plButton->isChecked();
}

bool MainDisplay::isEqualizerVisible() const
{
    return m_eqButton->isChecked();
}

void MainDisplay::displayVolume()
{
    if(sender() == m_volumeBar)
        m_text->setText(tr("Volume: %1%").arg(m_volumeBar->value()));
    if(sender() == m_balanceBar)
    {
        if(m_balanceBar->value() > 0)
            m_text->setText(tr("Balance: %1% right").arg(m_balanceBar->value()));
        else if(m_balanceBar->value() < 0)
            m_text->setText(tr("Balance: %1% left").arg(-m_balanceBar->value()));
        else
            m_text->setText(tr("Balance: center"));
    }
}

void MainDisplay::showPosition()
{
    int sec = m_posbar->value() / 1000;
    if(sec >= 3600)
        sec /= 60;
    QString time = QString("%1:%2").arg(sec/60, 2, 10, QChar('0')).arg(sec%60, 2, 10, QChar('0'));
    m_text->setText(tr("Seek to: %1").arg(time));
}

void MainDisplay::updatePosition()
{
    m_text->clear();
    m_core->seek(m_posbar->value());
}

void MainDisplay::wheelEvent (QWheelEvent *e)
{
    m_core->changeVolume(e->delta()/10);
}

bool MainDisplay::isRepeatable() const
{
    return m_repeatButton->isChecked();
}

bool MainDisplay::isShuffle() const
{
    return m_shuffleButton->isChecked();
}

void MainDisplay::setIsRepeatable(bool yes)
{
    m_repeatButton->setChecked(yes);
}

void MainDisplay::setIsShuffle(bool yes)
{
    m_shuffleButton->setChecked(yes);
}

void MainDisplay::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::RightButton)
        m_mw->menu()->exec(e->globalPos());
    else if(e->button() == Qt::LeftButton && m_aboutWidget->underMouse())
        m_mw->about();
    PixmapWidget::mousePressEvent(e);
}