~ubuntu-branches/debian/sid/jackd2/sid

« back to all changes in this revision

Viewing changes to posix/JackPosixMutex.h

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Knoth
  • Date: 2011-03-31 13:54:50 UTC
  • mfrom: (1.1.3 upstream) (2.1.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110331135450-zafc1di024kzeu31
Tags: 1.9.7~dfsg-1
* New upstream version 1.9.7 (ALSA resume, new latency API)
* Build with --mixed on i386 to be compatible with amd64.
* Don't patch jack_connect for fast consecutive calls anymore, it's now
  using the same code as in jackd1 and waits for the port connection to
  appear.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
\brief Mutex abstraction.
34
34
*/
35
35
 
36
 
    
 
36
 
37
37
class JackBasePosixMutex
38
38
{
39
 
    
 
39
 
40
40
    protected:
41
 
        
 
41
 
42
42
        pthread_mutex_t fMutex;
43
 
        
 
43
 
44
44
    public:
45
 
        
 
45
 
46
46
        JackBasePosixMutex()
47
47
        {
48
 
            pthread_mutex_init(&fMutex, NULL);        
 
48
            pthread_mutex_init(&fMutex, NULL);
49
49
        }
50
 
        
 
50
 
51
51
        virtual ~JackBasePosixMutex()
52
52
        {
53
53
            pthread_mutex_destroy(&fMutex);
54
54
        }
55
 
        
 
55
 
56
56
        void Lock()
57
57
        {
58
58
            int res = pthread_mutex_lock(&fMutex);
59
59
            if (res != 0)
60
 
                jack_error("JackBasePosixMutex::Lock res = %d", res);
 
60
                jack_log("JackBasePosixMutex::Lock res = %d", res);
61
61
        }
62
 
        
 
62
 
63
63
        bool Trylock()
64
64
        {
65
65
            return (pthread_mutex_trylock(&fMutex) == 0);
66
66
        }
67
 
        
 
67
 
68
68
        void Unlock()
69
69
        {
70
70
            int res = pthread_mutex_unlock(&fMutex);
71
71
            if (res != 0)
72
 
                jack_error("JackBasePosixMutex::Unlock res = %d", res);
 
72
                jack_log("JackBasePosixMutex::Unlock res = %d", res);
73
73
        }
74
 
    
 
74
 
75
75
};
76
 
    
 
76
 
77
77
class JackPosixMutex
78
78
{
79
79
 
97
97
            res = pthread_mutexattr_destroy(&mutex_attr);
98
98
            assert(res == 0);
99
99
        }
100
 
        
 
100
 
101
101
        virtual ~JackPosixMutex()
102
102
        {
103
103
            pthread_mutex_destroy(&fMutex);
107
107
        {
108
108
            int res = pthread_mutex_lock(&fMutex);
109
109
            if (res != 0)
110
 
                jack_error("JackPosixMutex::Lock res = %d", res);
 
110
                jack_log("JackPosixMutex::Lock res = %d", res);
111
111
            return (res == 0);
112
112
        }
113
113
 
120
120
        {
121
121
            int res = pthread_mutex_unlock(&fMutex);
122
122
            if (res != 0)
123
 
                jack_error("JackPosixMutex::Unlock res = %d", res);
 
123
                jack_log("JackPosixMutex::Unlock res = %d", res);
124
124
            return (res == 0);
125
125
        }
126
126