File: sound.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (83 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (10)
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
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/osx/sound.h
// Purpose:     wxSound class (loads and plays short Windows .wav files).
//              Optional on non-Windows platforms.
// Author:      Ryan Norton, Stefan Csomor
// Modified by:
// Created:     1998-01-01
// Copyright:   (c) Ryan Norton, Stefan Csomor
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_SOUND_H_
#define _WX_SOUND_H_

#if wxUSE_SOUND

#include "wx/object.h"

class WXDLLIMPEXP_FWD_ADV wxSoundTimer;

class WXDLLIMPEXP_ADV wxSoundData
{
public :
    wxSoundData();
    virtual ~wxSoundData();

    virtual bool Play(unsigned int flags) = 0;
    // stops the sound and deletes the optional timer
    virtual void Stop();
    // can be called by a timer for repeated tasks during playback
    virtual void SoundTask();
    // mark this to be deleted
    virtual void MarkForDeletion();
    virtual bool IsMarkedForDeletion() const { return m_markedForDeletion; }

    // does the true work of stopping and cleaning up
    virtual void DoStop() = 0;
protected :
    void CreateAndStartTimer();

    unsigned int m_flags;
    wxSoundTimer* m_pTimer;
    bool m_markedForDeletion;
} ;

class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
{
public:
    wxSound();
    wxSound(const wxString& fileName, bool isResource = false);
    wxSound(size_t size, const void* data);
    virtual ~wxSound();

    // Create from resource or file
    bool  Create(const wxString& fileName, bool isResource = false);
    // Create from data
    bool Create(size_t size, const void* data);

    bool IsOk() const { return m_data != NULL; }

    // Stop playing any sound
    static void Stop();

    // Returns true if a sound is being played
    static bool IsPlaying();

    // Notification when a sound has stopped
    static void SoundStopped(const wxSoundData* data);

protected:
    bool    DoPlay(unsigned flags) const;
    void    Init();

private:
    // data of this object
    class wxSoundData *m_data;

    wxDECLARE_NO_COPY_CLASS(wxSound);
};

#endif
#endif
    // _WX_SOUND_H_