view LinkedList.h @ 48:00b770b0d2aa

Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared. The current check is compiled only for iOS and does a runtime version check against CoreFoundation version 674.0. When Apple finally ships a fix, this fix should be amended to not run on fixed versions. Also ironically, it was originally the Apple Mac OpenAL implementation that had a problem with buffer unqueuing which ultimately led to the use of alSourcei(source_id, AL_BUFFER, AL_NONE); This is another reason the workaround is only constrained to iOS. In some cases I've seen, the buffer unqueue also triggers OpenAL errors, however, the current workaround seems to usually avoid those OpenAL errors (even though the buffers fail to unqueue some times). The 20ms sleep seems to avoid the race condition entirely, but when it doesn't, the sleep seems to do something that magically avoids tripping OpenAL errors.
author Eric Wing <ewing@anscamobile.com>
date Fri, 30 Sep 2011 16:44:08 -0700
parents a8d96c934e77
children 516da6d93534
line wrap: on
line source

/*
 LinkedList
 Copyright (C) 2010  Eric Wing <ewing . public @ playcontrol.net>
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.
 
 This library 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
 Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the Free
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/* I'm so sick of constantly rewriting linked lists in C. 
So here's some initial work to write a very simple reusable implementation.
The API could use a lot more functions, but I'll add them as I need them.
*/

#ifndef C_LINKED_LIST_H
#define C_LINKED_LIST_H

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

typedef struct LinkedListNode LinkedListNode;
typedef struct LinkedList LinkedList;

LinkedList* LinkedList_Create();

void LinkedList_Free(LinkedList* linked_list);

void* LinkedList_Front(LinkedList* linked_list);

void* LinkedList_Back(LinkedList* linked_list);

unsigned int LinkedList_PushFront(LinkedList* linked_list, void* new_item);

unsigned int LinkedList_PushBack(LinkedList* linked_list, void* new_item);

void* LinkedList_PopFront(LinkedList* linked_list);

void* LinkedList_PopBack(LinkedList* linked_list);

size_t LinkedList_Size(LinkedList* linked_list);

void LinkedList_Clear(LinkedList* linked_list);

void* LinkedListNode_GetData(LinkedListNode* list_node);

LinkedListNode* LinkedList_Find(LinkedList* linked_list, void* the_data, LinkedListNode* start_node);

unsigned int LinkedList_Remove(LinkedList* linked_list, LinkedListNode* list_node);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
	
#endif /* C_LINKED_LIST_H */