aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui/pluginitem.cpp
Commit message (Collapse)AuthorAgeFilesLines
* added feature to disable transport pluginstrialuser022013-05-121-2/+4
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3463 90c681e8-e032-0410-971d-27865f9a5e38
* added file dialog plugin path; file dialog api cleanuptrialuser022012-09-031-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2929 90c681e8-e032-0410-971d-27865f9a5e38
* changed configuration dialogtrialuser022012-08-291-4/+66
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2908 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF headerstrialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2845 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF address (trunk)trialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2844 90c681e8-e032-0410-971d-27865f9a5e38
* updated yeartrialuser022012-01-191-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2551 90c681e8-e032-0410-971d-27865f9a5e38
* added configuration dialogtrialuser022011-07-121-0/+184
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2270 90c681e8-e032-0410-971d-27865f9a5e38
655030078c74c17fd121122'>8bded202c
5ed184f6e
41c8a60a2
8bded202c






e747c2b87
8bded202c


76f436c36
8bded202c

260e607f9
8bded202c








6f6c39e54




8bded202c













8bded202c











260e607f9
8bded202c

76f436c36
8bded202c



8bded202c




065387600
8bded202c
065387600
8bded202c
76f436c36
240d991e4

76f436c36
8bded202c





76f436c36
8bded202c

bf9fb95f3
8bded202c
bf9fb95f3
ebd7f9bc6
8bded202c
8bded202c

bf9fb95f3
260e607f9
5c9ab872f

b16a319d1
d7caead49
8bded202c


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
                                                                            
                                                                            
                                                                            





















                                                                             
                 
                       
                            
                       




                   
             
                     
                       

             
                         
                                         






                                               
                            


                                                                      
                                  

                                                                            
                                                  








                                                                                    




                                                                       













                                                                                                    











                                            
                                  

                                     
                                        



                                    




                                     
                                               
                                            
                                            
                                        
                             

                              
 





                            
                          

                                 
                                          
                      
                              
                 
                                                 

                             
                             
                                

                                          
                                
                                   


                          
/***************************************************************************
 *   Copyright (C) 2012-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.         *
 ***************************************************************************/

#ifndef OUTPUTWRITER_P_H
#define OUTPUTWRITER_P_H

#include <QThread>
#include <QMutex>
#include <atomic>
#include "recycler_p.h"
#include "audioparameters.h"
#include "channelmap.h"

class QTimer;
class QmmpSettings;
class StateHandler;
class Output;
class Effect;
class AudioConverter;
class ChannelConverter;

/** @internal
    @brief Output thread.
    @author Ilya Kotov <forkotov02@ya.ru>
*/
class OutputWriter : public QThread
{
    Q_OBJECT
public:
    explicit OutputWriter(QObject *parent = 0);

    virtual ~OutputWriter();
    /*!
     * Prepares object for usage and setups required audio parameters.
     * @param freq Sample rate.
     * @param map Map of channels.
     * @return initialization result (\b true - success, \b false - failure)
     */
    bool initialize(quint32 freq, ChannelMap map);
    /*!
     * Requests playback to pause. If it was paused already, playback should resume.
     */
    void pause();
    /*!
     * Requests playback to stop.
     */
    void stop();
    /*!
     * Mutes/Restores volume
     * @param mute state of volume (\b true - mute, \b false - restore)
     */
    void setMuted(bool muted);
    /*!
     * Requests playback to finish.
     */
    void finish();
    /*!
     * Requests a seek to the time \b pos indicated, specified in milliseconds.
     * If \b reset is \b true, this function also clears internal output buffers for faster seeking;
     * otherwise does nothing with buffers.
     */
    void seek(qint64 pos, bool reset = false);
    /*!
     * Returns Recycler pointer.
     */
    Recycler *recycler();
    /*!
     * Returns selected audio parameters.
     */
    AudioParameters audioParameters() const;
    /*!
     * Returns samplerate.
     */
    quint32 sampleRate();
    /*!
     * Returns channels number.
     */
    int channels();
    /*!
     * Returns input audio format.
     */
    Qmmp::AudioFormat format() const;
    const ChannelMap channelMap() const;
    /*!
     * Returns sample size in bytes.
     */
    int sampleSize() const;
    void updateEqSettings();

private:
    void run(); //thread run function
    void status();
    void dispatch(qint64 elapsed, int bitrate);
    void dispatch(const Qmmp::State &state);
    void dispatch(const AudioParameters &p);
    void dispatchVisual(Buffer *buffer);
    bool prepareConverters();
    void startVisualization();
    void stopVisualization();

    bool m_skip;
    QMutex m_mutex;
    Recycler m_recycler;
    StateHandler *m_handler;
    quint32 m_frequency;
    int m_channels, m_kbps;
    ChannelMap m_chan_map;
    Qmmp::AudioFormat m_format;
    qint64 m_bytesPerMillisecond;
    std::atomic_bool m_user_stop, m_pause;
    bool m_prev_pause;
    std::atomic_bool m_finish;
    bool m_useEq;
    qint64 m_totalWritten, m_currentMilliseconds;
    QmmpSettings *m_settings;
    Output *m_output;
    std::atomic_bool m_muted;
    AudioParameters m_in_params;
    AudioConverter *m_format_converter;
    ChannelConverter *m_channel_converter;
    unsigned char *m_output_buf;
    size_t m_output_size; //samples
};

#endif // OUTPUTWRITER_P_H