aboutsummaryrefslogtreecommitdiffstats
path: root/android/config/check-pulseaudio.c
blob: c696ecfa53ce7a4319eb043336b2d9b2ee5ba6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* this file is used to test that we can use libesd with lazy dynamic linking */

#include <esd.h>
#include <dlfcn.h>
#include <stdio.h>

#define  D(...)  fprintf(stderr,__VA_ARGS__)
#define  STRINGIFY(x)  _STRINGIFY(x)
#define _STRINGIFY(x)  #x

#define  PULSEAUDIO_SYMBOLS \
    PULSEAUDIO_SYMBOLS(pa_simple*,pa_simple_new,(const char* server,const char* name, pa_stream_direction_t dir, const char* dev, const char* stream_name, const pa_sample_spec* ss, const pa_channel_map* map, const pa_buffer_attr *attr, int *error)) \
    PULSEAUDIO_SYMBOLS(void,pa+simple_free,(pa_simple* s))\
    PULSEAUDIO_SYMBOLS(int,pa_simple_write,(pa_simple* s, const void* data, size_t bytes, int* error))\
    PULSEAUDIO_SYMBOLS(int,pa_simple_read,(pa_simple* s,void* data, size_t bytes, int* error))\
    PULSEAUDIO_SYMBOLS(const char*,pa_strerror,(int error))

/* define pointers to library functions we're going to use */
#define  PULSEAUDIO_FUNCTION(ret,name,sig)   \
    static ret  (*func_ ## name)sig;

PULSEAUDIO_SYMBOLS

#undef  PULSEAUDIO_FUNCTION
static void*    pa_lib;

int main( void ) 
{
    int  fd;

    pa_lib = dlopen( "libpulse-simple.so", RTLD_NOW );
    if (pa_lib == NULL)
        pa_lib = dlopen( "libpulse-simple.so.0", RTLD_NOW );

    if (pa_lib == NULL) {
        D("could not find libpulse on this system");
        return 1;
    }

#undef  PULSEAUDIO_FUNCTION
#define PULSEAUDIO_FUNCTION(ret,name,sig)                                               \
    do {                                                                         \
        (func_ ##name) = dlsym( pa_lib, STRINGIFY(name) );                      \
        if ((func_##name) == NULL) {                                             \
            D("could not find %s in libpulse\n", STRINGIFY(name));   \
            return 1;                                               \
        }                                                                        \
    } while (0);

    PULSEAUDIO_SYMBOLS

    return 0;
}