~ubuntu-branches/ubuntu/wily/openal-soft/wily-proposed

« back to all changes in this revision

Viewing changes to Alc/backends/wave.c

  • Committer: Package Import Robot
  • Author(s): Bret Curtis
  • Date: 2014-07-16 08:35:25 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140716083525-5rldbuk4mo211l1a
Tags: 1:1.15.1-1
* Added openal-info binary. (Closes: 659198)
* Added makehrtf binary.
* Added 'audio' to short description. (Closes: 598064) 
* Added FLAGS fixes for cmake in rules for hardening.
* Added man pages for the two binaries.
* New upstream release. (Closes: 731159)
* Removed libsndio-dlopen-change.patch, no longer required.
* Removed no-fpuextended.patch, macros no longer used.
* Removed need for lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <stdlib.h>
24
24
#include <stdio.h>
25
25
#include <memory.h>
 
26
#ifdef HAVE_WINDOWS_H
 
27
#include <windows.h>
 
28
#endif
 
29
 
26
30
#include "alMain.h"
27
 
#include "AL/al.h"
28
 
#include "AL/alc.h"
 
31
#include "alu.h"
29
32
 
30
33
 
31
34
typedef struct {
81
84
 
82
85
static ALuint WaveProc(ALvoid *ptr)
83
86
{
84
 
    ALCdevice *pDevice = (ALCdevice*)ptr;
85
 
    wave_data *data = (wave_data*)pDevice->ExtraData;
 
87
    ALCdevice *Device = (ALCdevice*)ptr;
 
88
    wave_data *data = (wave_data*)Device->ExtraData;
86
89
    ALuint frameSize;
87
90
    ALuint now, start;
88
91
    ALuint64 avail, done;
89
92
    size_t fs;
90
 
    const ALuint restTime = (ALuint64)pDevice->UpdateSize * 1000 /
91
 
                            pDevice->Frequency / 2;
 
93
    const ALuint restTime = (ALuint64)Device->UpdateSize * 1000 /
 
94
                            Device->Frequency / 2;
92
95
 
93
 
    frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType);
 
96
    frameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType);
94
97
 
95
98
    done = 0;
96
99
    start = timeGetTime();
97
 
    while(!data->killNow && pDevice->Connected)
 
100
    while(!data->killNow && Device->Connected)
98
101
    {
99
102
        now = timeGetTime();
100
103
 
101
 
        avail = (ALuint64)(now-start) * pDevice->Frequency / 1000;
 
104
        avail = (ALuint64)(now-start) * Device->Frequency / 1000;
102
105
        if(avail < done)
103
106
        {
104
107
            /* Timer wrapped (50 days???). Add the remainder of the cycle to
105
108
             * the available count and reset the number of samples done */
106
 
            avail += ((ALuint64)1<<32)*pDevice->Frequency/1000 - done;
 
109
            avail += ((ALuint64)1<<32)*Device->Frequency/1000 - done;
107
110
            done = 0;
108
111
        }
109
 
        if(avail-done < pDevice->UpdateSize)
 
112
        if(avail-done < Device->UpdateSize)
110
113
        {
111
114
            Sleep(restTime);
112
115
            continue;
113
116
        }
114
117
 
115
 
        while(avail-done >= pDevice->UpdateSize)
 
118
        while(avail-done >= Device->UpdateSize)
116
119
        {
117
 
            aluMixData(pDevice, data->buffer, pDevice->UpdateSize);
118
 
            done += pDevice->UpdateSize;
 
120
            aluMixData(Device, data->buffer, Device->UpdateSize);
 
121
            done += Device->UpdateSize;
119
122
 
120
123
            if(!IS_LITTLE_ENDIAN)
121
124
            {
122
 
                ALuint bytesize = BytesFromDevFmt(pDevice->FmtType);
 
125
                ALuint bytesize = BytesFromDevFmt(Device->FmtType);
123
126
                ALubyte *bytes = data->buffer;
124
127
                ALuint i;
125
128
 
140
143
                }
141
144
            }
142
145
            else
143
 
                fs = fwrite(data->buffer, frameSize, pDevice->UpdateSize,
 
146
            {
 
147
                fs = fwrite(data->buffer, frameSize, Device->UpdateSize,
144
148
                            data->f);
 
149
                fs = fs;
 
150
            }
145
151
            if(ferror(data->f))
146
152
            {
147
153
                ERR("Error writing to file\n");
148
 
                aluHandleDisconnect(pDevice);
 
154
                ALCdevice_Lock(Device);
 
155
                aluHandleDisconnect(Device);
 
156
                ALCdevice_Unlock(Device);
149
157
                break;
150
158
            }
151
159
        }
178
186
        return ALC_INVALID_VALUE;
179
187
    }
180
188
 
181
 
    device->szDeviceName = strdup(deviceName);
 
189
    device->DeviceName = strdup(deviceName);
182
190
    device->ExtraData = data;
183
191
    return ALC_NO_ERROR;
184
192
}
249
257
    fwrite32le(channel_masks[channels], data->f);
250
258
    // 16 byte GUID, sub-type format
251
259
    val = fwrite(((bits==32) ? SUBTYPE_FLOAT : SUBTYPE_PCM), 1, 16, data->f);
 
260
    val = val;
252
261
 
253
262
    fprintf(data->f, "data");
254
263
    fwrite32le(0xFFFFFFFF, data->f); // 'data' header len; filled in at close
329
338
    NULL,
330
339
    NULL,
331
340
    NULL,
332
 
    NULL
 
341
    NULL,
 
342
    ALCdevice_LockDefault,
 
343
    ALCdevice_UnlockDefault,
 
344
    ALCdevice_GetLatencyDefault
333
345
};
334
346
 
335
347
ALCboolean alc_wave_init(BackendFuncs *func_list)
350
362
    switch(type)
351
363
    {
352
364
        case ALL_DEVICE_PROBE:
353
 
            AppendAllDeviceList(waveDevice);
 
365
            AppendAllDevicesList(waveDevice);
354
366
            break;
355
367
        case CAPTURE_DEVICE_PROBE:
356
368
            break;