source: trunk/third/audiofile/libaudiofile/aes.c @ 17099

Revision 17099, 2.2 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17098, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2        Audio File Library
3        Copyright (C) 1998-1999, Michael Pruett <michael@68k.org>
4        Copyright (C) 2000, Silicon Graphics, Inc.
5
6        This library is free software; you can redistribute it and/or
7        modify it under the terms of the GNU Library General Public
8        License as published by the Free Software Foundation; either
9        version 2 of the License, or (at your option) any later version.
10
11        This library is distributed in the hope that it will be useful,
12        but WITHOUT ANY WARRANTY; without even the implied warranty of
13        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14        Library General Public License for more details.
15
16        You should have received a copy of the GNU Library General Public
17        License along with this library; if not, write to the
18        Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19        Boston, MA  02111-1307  USA.
20*/
21
22/*
23        aes.c
24
25        This file contains routines for dealing with AES recording data.
26*/
27
28#include <string.h>
29#include <assert.h>
30
31#include "audiofile.h"
32#include "afinternal.h"
33#include "util.h"
34
35void afInitAESChannelData (AFfilesetup setup, int trackid)
36{
37        _TrackSetup     *track;
38
39        if (!_af_filesetup_ok(setup))
40                return;
41
42        if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL)
43                return;
44
45        track->aesDataSet = AF_TRUE;
46}
47
48void afInitAESChannelDataTo (AFfilesetup setup, int trackid, int willBeData)
49{
50        _TrackSetup     *track;
51
52        if (!_af_filesetup_ok(setup))
53                return;
54
55        if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL)
56                return;
57
58        track->aesDataSet = willBeData;
59}
60
61/*
62        What is with these return values?
63*/
64int afGetAESChannelData (AFfilehandle file, int trackid, unsigned char buf[24])
65{
66        _Track *track;
67
68        if ((track = _af_filehandle_get_track(file, trackid)) == NULL)
69                return -1;
70
71        if (track->hasAESData == AF_FALSE)
72        {
73                if (buf)
74                        memset(buf, 0, 24);
75                return 0;
76        }
77
78        if (buf)
79                memcpy(buf, track->aesData, 24);
80
81        return 1;
82}
83
84void afSetAESChannelData (AFfilehandle file, int trackid, unsigned char buf[24])
85{
86        _Track  *track;
87
88        if ((track = _af_filehandle_get_track(file, trackid)) == NULL)
89                return;
90
91        if (!_af_filehandle_can_write(file))
92                return;
93
94        if (track->hasAESData)
95        {
96                memcpy(track->aesData, buf, 24);
97        }
98        else
99        {
100                _af_error(AF_BAD_NOAESDATA,
101                        "unable to store AES channel status data for track %d",
102                        trackid);
103        }
104}
Note: See TracBrowser for help on using the repository browser.