comparison src/cdrom/macosx/SDLOSXCAGuard.h @ 1143:71a2648acc75

Replaced Mac OS X's C++ cdrom code with almost-direct translation to C. Sam requested this effort on the mailing list, apparently because of binary compatibility issues between 10.4 and earlier systems (or gcc4 and earlier compilers?). Works fine with SDL12/test/testcdrom.c, with this command line: ./testcdrom -status -list -play -sleep 5000 -pause -sleep 3000 -resume \ -sleep 5000 -stop -sleep 3000 -play -sleep 3000 -stop \ -sleep 3000 -eject Unix Makefiles work, XCode project still need updating for new filenames.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 22 Sep 2005 08:48:16 +0000
parents
children d910939febfa
comparison
equal deleted inserted replaced
1142:c7376efecdb5 1143:71a2648acc75
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2004 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 /*
23 Note: This file hasn't been modified so technically we have to keep the disclaimer :-(
24
25
26 Copyright: © Copyright 2002 Apple Computer, Inc. All rights reserved.
27
28 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
29 ("Apple") in consideration of your agreement to the following terms, and your
30 use, installation, modification or redistribution of this Apple software
31 constitutes acceptance of these terms. If you do not agree with these terms,
32 please do not use, install, modify or redistribute this Apple software.
33
34 In consideration of your agreement to abide by the following terms, and subject
35 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
36 copyrights in this original Apple software (the "Apple Software"), to use,
37 reproduce, modify and redistribute the Apple Software, with or without
38 modifications, in source and/or binary forms; provided that if you redistribute
39 the Apple Software in its entirety and without modifications, you must retain
40 this notice and the following text and disclaimers in all such redistributions of
41 the Apple Software. Neither the name, trademarks, service marks or logos of
42 Apple Computer, Inc. may be used to endorse or promote products derived from the
43 Apple Software without specific prior written permission from Apple. Except as
44 expressly stated in this notice, no other rights or licenses, express or implied,
45 are granted by Apple herein, including but not limited to any patent rights that
46 may be infringed by your derivative works or by other works in which the Apple
47 Software may be incorporated.
48
49 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
50 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
51 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
52 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
53 COMBINATION WITH YOUR PRODUCTS.
54
55 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
56 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
57 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
59 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
60 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
61 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 */
63 /*=============================================================================
64 CAGuard.h
65
66 =============================================================================*/
67 #if !defined(__CAGuard_h__)
68 #define __CAGuard_h__
69
70 //=============================================================================
71 // Includes
72 //=============================================================================
73
74 #include <CoreAudio/CoreAudioTypes.h>
75 #include <pthread.h>
76
77
78 //=============================================================================
79 // CAGuard
80 //
81 // This is your typical mutex with signalling implemented via pthreads.
82 // Lock() will return true if and only if the guard is locked on that call.
83 // A thread that already has the guard will receive 'false' if it locks it
84 // again. Use of the stack-based CAGuard::Locker class is highly recommended
85 // to properly manage the recursive nesting. The Wait calls with timeouts
86 // will return true if and only if the timeout period expired. They will
87 // return false if they receive notification any other way.
88 //=============================================================================
89
90 typedef struct S_SDLOSXCAGuard
91 {
92
93 // Construction/Destruction
94 //public:
95 // Actions
96 //public:
97 int (*Lock)(struct S_SDLOSXCAGuard *cag);
98 void (*Unlock)(struct S_SDLOSXCAGuard *cag);
99 int (*Try)(struct S_SDLOSXCAGuard *cag, int *outWasLocked); // returns true if lock is free, false if not
100 void (*Wait)(struct S_SDLOSXCAGuard *cag);
101 void (*Notify)(struct S_SDLOSXCAGuard *cag);
102
103 // Implementation
104 //protected:
105 pthread_mutex_t mMutex;
106 pthread_cond_t mCondVar;
107 pthread_t mOwner;
108 } SDLOSXCAGuard;
109
110 SDLOSXCAGuard *new_SDLOSXCAGuard(void);
111 void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag);
112
113 #endif
114