Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 386909 | Differences between
and this patch

Collapse All | Expand All

(-)src/ao.h (+156 lines)
Line 0 Link Here
1
/*
2
 *
3
 *  ao.h 
4
 *
5
 *  Original Copyright (C) Aaron Holtzman - May 1999
6
 *      Modifications Copyright (C) Stan Seibert - July 2000, July 2001
7
 *      More Modifications Copyright (C) Jack Moffitt - October 2000
8
 *
9
 *  This file is part of libao, a cross-platform audio outputlibrary.  See
10
 *  README for a history of this source code.
11
 *
12
 *  libao is free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 2, or (at your option)
15
 *  any later version.
16
 *
17
 *  libao is distributed in the hope that it will be useful,
18
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 *  GNU General Public License for more details.
21
 *
22
 *  You should have received a copy of the GNU General Public License
23
 *  along with GNU Make; see the file COPYING.  If not, write to
24
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25
 *
26
 */
27
#ifndef __AO_H__
28
#define __AO_H__
29
30
#ifdef __cplusplus
31
extern "C"
32
{
33
#endif /* __cplusplus */
34
35
#include <stdio.h>
36
#include <stdlib.h>
37
#include <stdint.h>
38
#include <errno.h>
39
40
/* --- Constants ---*/
41
42
#define AO_TYPE_LIVE 1
43
#define AO_TYPE_FILE 2
44
45
46
#define AO_ENODRIVER   1
47
#define AO_ENOTFILE    2
48
#define AO_ENOTLIVE    3
49
#define AO_EBADOPTION  4
50
#define AO_EOPENDEVICE 5
51
#define AO_EOPENFILE   6
52
#define AO_EFILEEXISTS 7
53
#define AO_EBADFORMAT  8
54
55
#define AO_EFAIL       100
56
57
58
#define AO_FMT_LITTLE 1
59
#define AO_FMT_BIG    2
60
#define AO_FMT_NATIVE 4
61
62
/* --- Structures --- */
63
64
typedef struct ao_info {
65
  int  type; /* live output or file output? */
66
  char *name; /* full name of driver */
67
  char *short_name; /* short name of driver */
68
        char *author; /* driver author */
69
  char *comment; /* driver comment */
70
  int  preferred_byte_format;
71
  int  priority;
72
  char **options;
73
  int  option_count;
74
} ao_info;
75
76
typedef struct ao_functions ao_functions;
77
typedef struct ao_device ao_device;
78
79
typedef struct ao_sample_format {
80
  int  bits; /* bits per sample */
81
  int  rate; /* samples per second (in a single channel) */
82
  int  channels; /* number of audio channels */
83
  int  byte_format; /* Byte ordering in sample, see constants below */
84
        char *matrix; /* input channel location/ordering */
85
} ao_sample_format;
86
87
typedef struct ao_option {
88
  char *key;
89
  char *value;
90
  struct ao_option *next;
91
} ao_option;
92
93
#if defined(AO_BUILDING_LIBAO)
94
#include "ao_private.h"
95
#endif
96
97
/* --- Functions --- */
98
99
/* library setup/teardown */
100
void ao_initialize(void);
101
void ao_shutdown(void);
102
103
/* device setup/playback/teardown */
104
int   ao_append_global_option(const char *key,
105
                              const char *value);
106
int          ao_append_option(ao_option **options,
107
                              const char *key,
108
                              const char *value);
109
void          ao_free_options(ao_option *options);
110
111
char* ao_get_option(ao_option *options, const char* key);
112
113
ao_device*       ao_open_live(int driver_id,
114
                              ao_sample_format *format,
115
                              ao_option *option);
116
ao_device*       ao_open_file(int driver_id,
117
                              const char *filename,
118
                              int overwrite,
119
                              ao_sample_format *format,
120
                              ao_option *option);
121
122
int                   ao_play(ao_device *device,
123
                              char *output_samples,
124
                              uint32_t num_bytes);
125
int                  ao_close(ao_device *device);
126
127
/* driver information */
128
int              ao_driver_id(const char *short_name);
129
int      ao_default_driver_id(void);
130
ao_info       *ao_driver_info(int driver_id);
131
ao_info **ao_driver_info_list(int *driver_count);
132
char       *ao_file_extension(int driver_id);
133
134
/* miscellaneous */
135
int          ao_is_big_endian(void);
136
137
138
#ifdef __cplusplus
139
}
140
#endif /* __cplusplus */
141
142
#endif  /* __AO_H__ */
143
144
extern struct AudioOutput g_ao;
145
struct AudioOutput                                                                                                                                                                                              
146
  {                                                                                                                                                                                                              
147
      void (*ao_initialize)(void);                                                                                                                                                                               
148
      int (*ao_play)(ao_device *, char *, uint32_t);                                                                                                                                                             
149
      int (*ao_default_driver_id)(void);                                                                                                                                                                         
150
      ao_device* (*ao_open_live)( int, ao_sample_format *, ao_option *);                                                                                                                                         
151
      int (*ao_close)(ao_device *);                                                                                                                                                                              
152
      /* -- Device Setup/Playback/Teardown -- */                                                                                                                                                                 
153
      int (*ao_append_option)(ao_option **, const char *, const char *);                                                                                                                                         
154
      void (*ao_free_options)(ao_option *);                                                                                                                                                                      
155
      char* (*ao_get_option)(ao_option *, const char* );                                                                                                                                                         
156
  }; 
(-)src/hairtunes.c (-8 / +8 lines)
Lines 25-31 Link Here
25
 */
25
 */
26
26
27
#define XBMC
27
#define XBMC
28
//#defined HAS_AO
28
#define HAS_AO
29
29
30
#include <stdio.h>
30
#include <stdio.h>
31
#include <stdlib.h>
31
#include <stdlib.h>
Lines 45-51 Link Here
45
#include <sys/signal.h>
45
#include <sys/signal.h>
46
#include <fcntl.h>
46
#include <fcntl.h>
47
#ifdef HAS_AO
47
#ifdef HAS_AO
48
#include <ao/ao.h>
48
#include "ao.h"
49
#endif
49
#endif
50
50
51
#ifdef FANCY_RESAMPLING
51
#ifdef FANCY_RESAMPLING
Lines 881-887 Link Here
881
            }
881
            }
882
#ifdef HAS_AO
882
#ifdef HAS_AO
883
        } else {
883
        } else {
884
            ao_play(dev, (char *)outbuf, play_samples*4);
884
            g_ao.ao_play(dev, (char *)outbuf, play_samples*4);
885
#endif
885
#endif
886
        }
886
        }
887
    }
887
    }
Lines 906-912 Link Here
906
ao_device *dev;
906
ao_device *dev;
907
907
908
void* init_ao() {
908
void* init_ao() {
909
    ao_initialize();
909
    g_ao.ao_initialize();
910
910
911
    int driver;
911
    int driver;
912
#ifndef XBMC
912
#ifndef XBMC
Lines 921-927 Link Here
921
#endif
921
#endif
922
    {
922
    {
923
        // otherwise choose the default
923
        // otherwise choose the default
924
        driver = ao_default_driver_id();
924
        driver = g_ao.ao_default_driver_id();
925
    }
925
    }
926
926
927
    ao_sample_format fmt;
927
    ao_sample_format fmt;
Lines 944-952 Link Here
944
    }
944
    }
945
#endif
945
#endif
946
946
947
    ao_append_option(&ao_opts, "name", "Streaming...");
947
    g_ao.ao_append_option(&ao_opts, "name", "Streaming...");
948
948
949
    dev = ao_open_live(driver, &fmt, ao_opts);
949
    dev = g_ao.ao_open_live(driver, &fmt, ao_opts);
950
    if (dev == NULL) {
950
    if (dev == NULL) {
951
        die("Could not open ao device");
951
        die("Could not open ao device");
952
    }
952
    }
Lines 985-991 Link Here
985
  audio_running = 0;
985
  audio_running = 0;
986
  pthread_join(audio_thread, NULL);
986
  pthread_join(audio_thread, NULL);
987
#ifdef HAS_AO
987
#ifdef HAS_AO
988
  ao_close(dev);
988
  g_ao.ao_close(dev);
989
#endif
989
#endif
990
}
990
}
991
991
(-)src/shairport.c (+8 lines)
Lines 92-97 Link Here
92
static char tPassword[56] = "";
92
static char tPassword[56] = "";
93
static char tHWID[HWID_SIZE] = {0,51,52,53,54,55};
93
static char tHWID[HWID_SIZE] = {0,51,52,53,54,55};
94
94
95
#ifdef XBMC
96
struct AudioOutput g_ao;
97
void shairport_set_ao(struct AudioOutput *ao)
98
{
99
 g_ao=*ao;
100
}
101
#endif
102
95
#ifndef XBMC
103
#ifndef XBMC
96
int main(int argc, char **argv)
104
int main(int argc, char **argv)
97
#else
105
#else
(-)src/shairport.h (+3 lines)
Lines 11-16 Link Here
11
#include <regex.h>
11
#include <regex.h>
12
#include <sys/types.h>
12
#include <sys/types.h>
13
#include <regex.h>
13
#include <regex.h>
14
#include "ao.h"
14
15
15
16
16
#define HWID_SIZE 6
17
#define HWID_SIZE 6
Lines 62-70 Link Here
62
void shairport_exit(void);
63
void shairport_exit(void);
63
int shairport_loop(void);
64
int shairport_loop(void);
64
int shairport_is_running(void);
65
int shairport_is_running(void);
66
void shairport_set_ao(struct AudioOutput *ao);
65
67
66
#ifdef __cplusplus
68
#ifdef __cplusplus
67
}
69
}
68
#endif /* __cplusplus */
70
#endif /* __cplusplus */
69
71
70
#endif
72
#endif
73

Return to bug 386909