Browse code

lavd/pulse: move common code to separate file

Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Lukasz Marek authored on 2013/10/04 21:21:29
Showing 5 changed files
... ...
@@ -30,8 +30,10 @@ OBJS-$(CONFIG_LAVFI_INDEV)               += lavfi.o
30 30
 OBJS-$(CONFIG_OPENAL_INDEV)              += openal-dec.o
31 31
 OBJS-$(CONFIG_OSS_INDEV)                 += oss_audio.o
32 32
 OBJS-$(CONFIG_OSS_OUTDEV)                += oss_audio.o
33
-OBJS-$(CONFIG_PULSE_INDEV)               += pulse_audio_dec.o
34
-OBJS-$(CONFIG_PULSE_OUTDEV)              += pulse_audio_enc.o
33
+OBJS-$(CONFIG_PULSE_INDEV)               += pulse_audio_dec.o \
34
+                                            pulse_audio_common.o
35
+OBJS-$(CONFIG_PULSE_OUTDEV)              += pulse_audio_enc.o \
36
+                                            pulse_audio_common.o
35 37
 OBJS-$(CONFIG_SDL_OUTDEV)                += sdl.o
36 38
 OBJS-$(CONFIG_SNDIO_INDEV)               += sndio_common.o sndio_dec.o
37 39
 OBJS-$(CONFIG_SNDIO_OUTDEV)              += sndio_common.o sndio_enc.o
38 40
new file mode 100644
... ...
@@ -0,0 +1,42 @@
0
+/*
1
+ * Pulseaudio input
2
+ * Copyright (c) 2011 Luca Barbato <lu_zero@gentoo.org>
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg 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
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#include "libavutil/attributes.h"
22
+#include "libavcodec/avcodec.h"
23
+#include "pulse_audio_common.h"
24
+
25
+pa_sample_format_t av_cold codec_id_to_pulse_format(int codec_id)
26
+{
27
+    switch (codec_id) {
28
+    case AV_CODEC_ID_PCM_U8:    return PA_SAMPLE_U8;
29
+    case AV_CODEC_ID_PCM_ALAW:  return PA_SAMPLE_ALAW;
30
+    case AV_CODEC_ID_PCM_MULAW: return PA_SAMPLE_ULAW;
31
+    case AV_CODEC_ID_PCM_S16LE: return PA_SAMPLE_S16LE;
32
+    case AV_CODEC_ID_PCM_S16BE: return PA_SAMPLE_S16BE;
33
+    case AV_CODEC_ID_PCM_F32LE: return PA_SAMPLE_FLOAT32LE;
34
+    case AV_CODEC_ID_PCM_F32BE: return PA_SAMPLE_FLOAT32BE;
35
+    case AV_CODEC_ID_PCM_S32LE: return PA_SAMPLE_S32LE;
36
+    case AV_CODEC_ID_PCM_S32BE: return PA_SAMPLE_S32BE;
37
+    case AV_CODEC_ID_PCM_S24LE: return PA_SAMPLE_S24LE;
38
+    case AV_CODEC_ID_PCM_S24BE: return PA_SAMPLE_S24BE;
39
+    default:                    return PA_SAMPLE_INVALID;
40
+    }
41
+}
0 42
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+/*
1
+ * Pulseaudio input
2
+ * Copyright (c) 2011 Luca Barbato <lu_zero@gentoo.org>
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg 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
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#ifndef AVDEVICE_PULSE_AUDIO_COMMON_H
22
+#define AVDEVICE_PULSE_AUDIO_COMMON_H
23
+
24
+#include <pulse/simple.h>
25
+
26
+pa_sample_format_t codec_id_to_pulse_format(int codec_id);
27
+
28
+#endif /* AVDEVICE_PULSE_AUDIO_COMMON_H */
... ...
@@ -28,10 +28,10 @@
28 28
 #include <pulse/simple.h>
29 29
 #include <pulse/rtclock.h>
30 30
 #include <pulse/error.h>
31
-
32 31
 #include "libavformat/avformat.h"
33 32
 #include "libavformat/internal.h"
34 33
 #include "libavutil/opt.h"
34
+#include "pulse_audio_common.h"
35 35
 
36 36
 #define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)
37 37
 
... ...
@@ -49,23 +49,6 @@ typedef struct PulseData {
49 49
     int64_t frame_duration;
50 50
 } PulseData;
51 51
 
52
-static pa_sample_format_t codec_id_to_pulse_format(int codec_id) {
53
-    switch (codec_id) {
54
-    case AV_CODEC_ID_PCM_U8:    return PA_SAMPLE_U8;
55
-    case AV_CODEC_ID_PCM_ALAW:  return PA_SAMPLE_ALAW;
56
-    case AV_CODEC_ID_PCM_MULAW: return PA_SAMPLE_ULAW;
57
-    case AV_CODEC_ID_PCM_S16LE: return PA_SAMPLE_S16LE;
58
-    case AV_CODEC_ID_PCM_S16BE: return PA_SAMPLE_S16BE;
59
-    case AV_CODEC_ID_PCM_F32LE: return PA_SAMPLE_FLOAT32LE;
60
-    case AV_CODEC_ID_PCM_F32BE: return PA_SAMPLE_FLOAT32BE;
61
-    case AV_CODEC_ID_PCM_S32LE: return PA_SAMPLE_S32LE;
62
-    case AV_CODEC_ID_PCM_S32BE: return PA_SAMPLE_S32BE;
63
-    case AV_CODEC_ID_PCM_S24LE: return PA_SAMPLE_S24LE;
64
-    case AV_CODEC_ID_PCM_S24BE: return PA_SAMPLE_S24BE;
65
-    default:                 return PA_SAMPLE_INVALID;
66
-    }
67
-}
68
-
69 52
 static av_cold int pulse_read_header(AVFormatContext *s)
70 53
 {
71 54
     PulseData *pd = s->priv_data;
... ...
@@ -20,11 +20,12 @@
20 20
 
21 21
 #include <pulse/simple.h>
22 22
 #include <pulse/error.h>
23
+#include "libavformat/avformat.h"
24
+#include "libavformat/internal.h"
23 25
 #include "libavutil/opt.h"
24 26
 #include "libavutil/time.h"
25 27
 #include "libavutil/log.h"
26
-#include "libavformat/avformat.h"
27
-#include "libavformat/internal.h"
28
+#include "pulse_audio_common.h"
28 29
 
29 30
 typedef struct PulseData {
30 31
     AVClass *class;
... ...
@@ -36,24 +37,6 @@ typedef struct PulseData {
36 36
     unsigned int stream_index;
37 37
 } PulseData;
38 38
 
39
-static pa_sample_format_t codec_id_to_pulse_format(enum AVCodecID codec_id)
40
-{
41
-    switch (codec_id) {
42
-    case AV_CODEC_ID_PCM_U8:    return PA_SAMPLE_U8;
43
-    case AV_CODEC_ID_PCM_ALAW:  return PA_SAMPLE_ALAW;
44
-    case AV_CODEC_ID_PCM_MULAW: return PA_SAMPLE_ULAW;
45
-    case AV_CODEC_ID_PCM_S16LE: return PA_SAMPLE_S16LE;
46
-    case AV_CODEC_ID_PCM_S16BE: return PA_SAMPLE_S16BE;
47
-    case AV_CODEC_ID_PCM_F32LE: return PA_SAMPLE_FLOAT32LE;
48
-    case AV_CODEC_ID_PCM_F32BE: return PA_SAMPLE_FLOAT32BE;
49
-    case AV_CODEC_ID_PCM_S32LE: return PA_SAMPLE_S32LE;
50
-    case AV_CODEC_ID_PCM_S32BE: return PA_SAMPLE_S32BE;
51
-    case AV_CODEC_ID_PCM_S24LE: return PA_SAMPLE_S24LE;
52
-    case AV_CODEC_ID_PCM_S24BE: return PA_SAMPLE_S24BE;
53
-    default:                    return PA_SAMPLE_INVALID;
54
-    }
55
-}
56
-
57 39
 static av_cold int pulse_write_header(AVFormatContext *h)
58 40
 {
59 41
     PulseData *s = h->priv_data;