source: qutecom-coip/libs/sound/src/win32/SoundThread.cpp @ 123:e06473b93b96

Last change on this file since 123:e06473b93b96 was 123:e06473b93b96, checked in by laurent, 3 years ago

openwengo => qutecom

File size: 1.6 KB
Line 
1/*
2 * QuteCom, a voice over Internet phone
3 * Copyright (C) 2004-2006  Wengo
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#include "SoundThread.h"
21
22#include "playsound/PlaySoundFile.h"
23
24#include <windows.h>
25#include <process.h>
26
27SoundThread::SoundThread(const std::string & filename) {
28        _filename = filename;
29        _stop = false;
30
31        //Plays the sound only one time by default
32        _loops = 1;
33}
34
35SoundThread::~SoundThread() {
36}
37
38bool SoundThread::setWaveOutDevice(const AudioDevice & device) {
39        _device = device;
40        return true;
41}
42
43void SoundThread::setLoops(int loops) {
44        _loops = loops;
45}
46
47void SoundThread::play() {
48        start();
49}
50
51void SoundThread::run() {
52        _soundFile.setWaveOutDevice(_device);
53
54        int i = 0;
55        while ((i < _loops || _loops == -1) && !_stop) {
56                if (!_soundFile.play(_filename)) {
57                        //If the file cannot be played, stop the thread
58                        _stop = true;
59                }
60                i++;
61        }
62        _stop = false;
63}
64
65void SoundThread::stop() {
66        _stop = true;
67        _soundFile.stop();
68}
Note: See TracBrowser for help on using the repository browser.