2
* $Id: pa_stream.c 1339 2008-02-15 07:50:33Z rossb $
3
* Portable Audio I/O Library
6
* Based on the Open Source API proposed by Ross Bencina
7
* Copyright (c) 2008 Ross Bencina
9
* Permission is hereby granted, free of charge, to any person obtaining
10
* a copy of this software and associated documentation files
11
* (the "Software"), to deal in the Software without restriction,
12
* including without limitation the rights to use, copy, modify, merge,
13
* publish, distribute, sublicense, and/or sell copies of the Software,
14
* and to permit persons to whom the Software is furnished to do so,
15
* subject to the following conditions:
17
* The above copyright notice and this permission notice shall be
18
* included in all copies or substantial portions of the Software.
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
24
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
* The text above constitutes the entire PortAudio license; however,
31
* the PortAudio community also makes the following non-binding requests:
33
* Any person wishing to distribute modifications to the Software is
34
* requested to send the modifications to the original developer so that
35
* they can be incorporated into the canonical version. It is also
36
* requested that these non-binding requests be included along with the
43
@brief Stream interfaces, representation structures and helper functions
44
used to interface between pa_front.c host API implementations.
48
#include "pa_stream.h"
51
void PaUtil_InitializeStreamInterface( PaUtilStreamInterface *streamInterface,
52
PaError (*Close)( PaStream* ),
53
PaError (*Start)( PaStream* ),
54
PaError (*Stop)( PaStream* ),
55
PaError (*Abort)( PaStream* ),
56
PaError (*IsStopped)( PaStream* ),
57
PaError (*IsActive)( PaStream* ),
58
PaTime (*GetTime)( PaStream* ),
59
double (*GetCpuLoad)( PaStream* ),
60
PaError (*Read)( PaStream*, void *, unsigned long ),
61
PaError (*Write)( PaStream*, const void *, unsigned long ),
62
signed long (*GetReadAvailable)( PaStream* ),
63
signed long (*GetWriteAvailable)( PaStream* ) )
65
streamInterface->Close = Close;
66
streamInterface->Start = Start;
67
streamInterface->Stop = Stop;
68
streamInterface->Abort = Abort;
69
streamInterface->IsStopped = IsStopped;
70
streamInterface->IsActive = IsActive;
71
streamInterface->GetTime = GetTime;
72
streamInterface->GetCpuLoad = GetCpuLoad;
73
streamInterface->Read = Read;
74
streamInterface->Write = Write;
75
streamInterface->GetReadAvailable = GetReadAvailable;
76
streamInterface->GetWriteAvailable = GetWriteAvailable;
80
void PaUtil_InitializeStreamRepresentation( PaUtilStreamRepresentation *streamRepresentation,
81
PaUtilStreamInterface *streamInterface,
82
PaStreamCallback *streamCallback,
85
streamRepresentation->magic = PA_STREAM_MAGIC;
86
streamRepresentation->nextOpenStream = 0;
87
streamRepresentation->streamInterface = streamInterface;
88
streamRepresentation->streamCallback = streamCallback;
89
streamRepresentation->streamFinishedCallback = 0;
91
streamRepresentation->userData = userData;
93
streamRepresentation->streamInfo.inputLatency = 0.;
94
streamRepresentation->streamInfo.outputLatency = 0.;
95
streamRepresentation->streamInfo.sampleRate = 0.;
99
void PaUtil_TerminateStreamRepresentation( PaUtilStreamRepresentation *streamRepresentation )
101
streamRepresentation->magic = 0;
105
PaError PaUtil_DummyRead( PaStream* stream,
107
unsigned long frames )
109
(void)stream; /* unused parameter */
110
(void)buffer; /* unused parameter */
111
(void)frames; /* unused parameter */
113
return paCanNotReadFromACallbackStream;
117
PaError PaUtil_DummyWrite( PaStream* stream,
119
unsigned long frames )
121
(void)stream; /* unused parameter */
122
(void)buffer; /* unused parameter */
123
(void)frames; /* unused parameter */
125
return paCanNotWriteToACallbackStream;
129
signed long PaUtil_DummyGetReadAvailable( PaStream* stream )
131
(void)stream; /* unused parameter */
133
return paCanNotReadFromACallbackStream;
137
signed long PaUtil_DummyGetWriteAvailable( PaStream* stream )
139
(void)stream; /* unused parameter */
141
return paCanNotWriteToACallbackStream;
145
double PaUtil_DummyGetCpuLoad( PaStream* stream )
147
(void)stream; /* unused parameter */