~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to lib-src/libsndfile/src/broadcast.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
** Copyright (C) 2006 Paul Davis <paul@linuxaudiosystems.com>
3
 
** Copyright (C) 2006 Erik de Castro Lopo <erikd@mega-nerd.com>
4
 
**
5
 
** This program is free software; you can redistribute it and/or modify
6
 
** it under the terms of the GNU Lesser General Public License as published by
7
 
** the Free Software Foundation; either version 2.1 of the License, or
8
 
** (at your option) any later version.
9
 
**
10
 
** This program 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
13
 
** GNU Lesser General Public License for more details.
14
 
**
15
 
** You should have received a copy of the GNU Lesser General Public License
16
 
** along with this program; if not, write to the Free Software
17
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 
*/
19
 
 
20
 
#include <stdio.h>
21
 
#include <string.h>
22
 
 
23
 
#include "common.h"
24
 
 
25
 
/*
26
 
** Allocate and initialize a broadcast info structure.
27
 
*/
28
 
 
29
 
SF_BROADCAST_INFO*
30
 
broadcast_info_alloc (void)
31
 
{       SF_BROADCAST_INFO* bext ;
32
 
 
33
 
        if ((bext = calloc (1, sizeof (SF_BROADCAST_INFO))) == NULL)
34
 
                return NULL ;
35
 
 
36
 
        return bext ;
37
 
} /* broadcast_info_alloc */
38
 
 
39
 
int
40
 
broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src)
41
 
{       memcpy (dst, src, sizeof (SF_BROADCAST_INFO)) ;
42
 
 
43
 
        /* Currently writing this version. */
44
 
        dst->version = 1 ;
45
 
 
46
 
        return SF_TRUE ;
47
 
} /* broadcast_info_copy */
48
 
 
49
 
int
50
 
broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate)
51
 
{       char chnstr [16] ;
52
 
        int count ;
53
 
 
54
 
        switch (channels)
55
 
        {       case 0 :
56
 
                        return SF_FALSE ;
57
 
 
58
 
                case 1 :
59
 
                        strncpy (chnstr, "mono", sizeof (chnstr)) ;
60
 
                        break ;
61
 
 
62
 
                case 2 :
63
 
                        strncpy (chnstr, "stereo", sizeof (chnstr)) ;
64
 
                        break ;
65
 
 
66
 
        default :
67
 
                LSF_SNPRINTF (chnstr, sizeof (chnstr), "%uchn", channels) ;
68
 
                break ;
69
 
        }
70
 
 
71
 
        count = LSF_SNPRINTF (bext->coding_history, sizeof (bext->coding_history), "F=%u,A=PCM,M=%s,W=24,T=%s-%s", samplerate, chnstr, PACKAGE, VERSION) ;
72
 
 
73
 
        if (count >= SIGNED_SIZEOF (bext->coding_history))
74
 
                bext->coding_history_size = sizeof (bext->coding_history) ;
75
 
        else
76
 
        {       count += count & 1 ;
77
 
                bext->coding_history_size = count ;
78
 
                } ;
79
 
 
80
 
        return SF_TRUE ;
81
 
} /* broadcast_add_coding_history */
82
 
 
83
 
/*
84
 
** Do not edit or modify anything in this comment block.
85
 
** The following line is a file identity tag for the GNU Arch
86
 
** revision control system.
87
 
**
88
 
** arch-tag: 4b3b69c7-d710-4424-9da0-5048534a0beb
89
 
*/