aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/FileDialogs/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* updated cmake filestrialuser022016-03-041-0/+5
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6153 90c681e8-e032-0410-971d-27865f9a5e38
* enabled qmmp file dialogtrialuser022008-06-191-0/+5
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@428 90c681e8-e032-0410-971d-27865f9a5e38
ed FSF headers' href='/qmmp/commit/src/plugins/Output/oss4/outputoss4.cpp?id=a8bf072ec18a3ecfd6110a1dcfdef7f7e0daf4bd'>a8bf072ec
0d55d4504



























0d55d4504
74afcc2d9
0d55d4504
8bded202c
0d55d4504
0d55d4504
















9d35f2ce0




















0d55d4504
bbc2ba59e
9d35f2ce0







bbc2ba59e

0d55d4504
















9d35f2ce0
0d55d4504
8bded202c
bbc2ba59e

39556dbfe

0d55d4504
39556dbfe
0d55d4504
0d55d4504
39556dbfe
bbc2ba59e




ce4b4306e
9d35f2ce0
64d2541b7


0d55d4504









bbc2ba59e
0d55d4504










3f3d2b088
0d55d4504


74afcc2d9
64d2541b7




0d55d4504
74afcc2d9
64d2541b7
be420a9ec

64d2541b7



0d55d4504
75c4eaf61
0d55d4504
75c4eaf61
0d55d4504

64d2541b7
0d55d4504


75c4eaf61
0d55d4504
75c4eaf61
0d55d4504




be420a9ec






0d55d4504
75c4eaf61
0d55d4504
64d2541b7
74afcc2d9
64d2541b7
75c4eaf61



64d2541b7
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
                                                                            
                                                                            














                                                                            
                                                                            



























                                                                             
                                       
                                 
 
                                   
 
















                                                                           




















                                                                             
 
                                                          







                                                                            

                                           
















                                                         
                     
     
 

                                                                                   

                                                           
                                                                                      
 
                                                       
                                                                                   
 




                                                                                 
 
                                  


                        









                                                                  
                                                










                                          
                                          


                   
                        




                                                                 
 
                         
 

                                           



                                                                 
 
                                                     
 
                                           

                                                                   
                                                                              


     
                                         
 
                       




                                                                               






                                             
     
               
 
 
                          
 



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

extern "C"
{
#ifdef HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#else
#include <soundcard.h>
#endif
//#include </usr/lib/oss/include/sys/soundcard.h>
}

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <qmmp/buffer.h>
#include <qmmp/visual.h>
#include "outputoss4.h"

OutputOSS4 *OutputOSS4::m_instance = 0;
VolumeOSS4 *OutputOSS4::m_vc = 0;

OutputOSS4::OutputOSS4() : Output()
{
    m_audio_fd = -1;
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    m_audio_device = settings.value("OSS4/device", DEFAULT_DEV).toString();
    m_instance = this;
}

OutputOSS4::~OutputOSS4()
{
    if (m_audio_fd >= 0)
    {
        ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
        close(m_audio_fd);
        m_audio_fd = -1;
    }
    m_instance = 0;
}

int OutputOSS4::fd()
{
    return m_audio_fd;
}

OutputOSS4 *OutputOSS4::instance()
{
    return m_instance;
}

void OutputOSS4::post()
{
    ioctl(m_audio_fd, SNDCTL_DSP_POST, 0);
}

void OutputOSS4::sync()
{
    ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
}

bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format)
{
    m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY);

    if (m_audio_fd < 0)
    {
        qWarning("OSS4Output: unable to open output device '%s'; error: %s",
                 qPrintable(m_audio_device), strerror(errno));
        return false;
    }

    ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);

    int p;
    switch (format)
    {
    case Qmmp::PCM_S32LE:
        p = AFMT_S32_LE;
        break;
    case Qmmp::PCM_S24LE:
        p = AFMT_S24_LE;
        break;
    case Qmmp::PCM_S16LE:
        p = AFMT_S16_LE;
        break;
    case Qmmp::PCM_S8:
        p = AFMT_S8;
        break;
    default:
        qWarning("OutputOSS4: unsupported audio format");
        return false;
    }

    if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1)
        qWarning("OutputOSS4: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno));

    if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) == -1)
        qWarning("OutputOSS4: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno));

    if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) < 0)
        qWarning("OutputOSS4: ioctl SNDCTL_DSP_SPEED failed: %s", strerror(errno));

    int enabled = 1;
    if(ioctl(m_audio_fd, SNDCTL_DSP_COOKEDMODE, &enabled) == -1)
        qWarning("OutputOSS4: ioctl SNDCTL_DSP_COOKEDMODE: %s", strerror(errno));

    ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);

    configure(freq, chan, format);

    if(m_vc)
        m_vc->restore();
    return true;
}

qint64 OutputOSS4::latency()
{
    return 0;
}

qint64 OutputOSS4::writeAudio(unsigned char *data, qint64 maxSize)
{
    qint64 m = write(m_audio_fd, data, maxSize);
    post();
    return m;
}

void OutputOSS4::drain()
{
    ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
}

void OutputOSS4::reset()
{
    ioctl(m_audio_fd, SNDCTL_DSP_SKIP, 0);
}

/***** MIXER *****/
VolumeOSS4::VolumeOSS4()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    m_volume = settings.value("OSS4/volume", 0x3232).toInt();
    OutputOSS4::m_vc = this;
}

VolumeOSS4::~VolumeOSS4()
{
    VolumeSettings vol = volume();
    m_volume = (vol.right << 8) | vol.left;
    OutputOSS4::m_vc = 0;
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.setValue("OSS4/volume", m_volume);
}

void VolumeOSS4::setVolume(const VolumeSettings &vol)
{
    m_volume = (vol.right << 8) | vol.left;
    if(OutputOSS4::instance() && OutputOSS4::instance()->fd() >= 0)
    {
        ioctl(OutputOSS4::instance()->fd(), SNDCTL_DSP_SETPLAYVOL, &m_volume);
    }
}

VolumeSettings VolumeOSS4::volume() const
{
    VolumeSettings vol;
    if(OutputOSS4::instance() && OutputOSS4::instance()->fd() >= 0)
    {
        int v = 0;
        if (ioctl(OutputOSS4::instance()->fd(), SNDCTL_DSP_GETPLAYVOL, &v) < 0)
            v = 0;
        vol.left = v & 0x00FF;
        vol.right = (v & 0xFF00) >> 8;
    }
    else
    {
        vol.left = m_volume & 0x00FF;
        vol.right = (m_volume & 0xFF00) >> 8;
    }
    return vol;
}

void VolumeOSS4::restore()
{
    if(OutputOSS4::instance() && OutputOSS4::instance()->fd() >= 0)
    {
        ioctl(OutputOSS4::instance()->fd(), SNDCTL_DSP_SETPLAYVOL, &m_volume);
    }
}