summaryrefslogtreecommitdiff
blob: 70a88dde4348d38855d1cf4d2a6984035c9f9a7f (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- squeezeslave-1.1_p309/src/slimaudio/slimaudio_decoder_aac.c.orig
+++ squeezeslave-1.1_p309/src/slimaudio/slimaudio_decoder_aac.c
@@ -28,6 +28,10 @@
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 
+#ifndef CODEC_TYPE_AUDIO
+#define CODEC_TYPE_AUDIO	AVMEDIA_TYPE_AUDIO
+#endif
+
 #include "slimproto/slimproto.h"
 #include "slimaudio/slimaudio.h"
 
@@ -96,11 +100,6 @@
 }
 
 int slimaudio_decoder_aac_process(slimaudio_t *audio) {
-//	unsigned char data[AUDIO_CHUNK_SIZE];
-//	int buffer[AUDIO_CHUNK_SIZE/2];
-//	int i;
-	
-//	unsigned char *ptr = data;
 	char streamformat[16];
 	int out_size;
 	int len = 0;
@@ -148,18 +147,6 @@
 
 	DEBUGF ("aac: play audioStream: %d\n", audioStream);
 
-	AVInputFormat* pAVInputFormat = av_find_input_format(streamformat);
-	if( !pAVInputFormat )
-	{
-		DEBUGF("aac: probe failed\n");
-		return -1;
-	}
-	else
-	{
-		DEBUGF("aac: probe ok name:%s lname:%s\n", pAVInputFormat->name, pAVInputFormat->long_name);
-		pAVInputFormat->flags |= AVFMT_NOFILE;
-	}
-
 	inbuf = av_malloc(AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
 	if ( !inbuf )
 	{
@@ -167,23 +154,35 @@
 		return -1;
 	}
 
-	ByteIOContext ByteIOCtx;
+	AVIOContext *AVIOCtx;
 
-	iRC = init_put_byte( &ByteIOCtx, inbuf, AUDIO_CHUNK_SIZE, 0, audio, av_read_data, NULL, NULL ) ;
-	if( iRC < 0)
+	AVIOCtx = avio_alloc_context(inbuf, AUDIO_CHUNK_SIZE, 0, audio, av_read_data, NULL, NULL);
+	if ( AVIOCtx == NULL )
 	{
-		DEBUGF("aac: init_put_byte failed:%d\n", iRC);
+		DEBUGF("aac: avio_alloc_context failed.\n");
 		return -1;
 	}
 	else
 	{
-		ByteIOCtx.is_streamed = 1;
+		AVIOCtx->is_streamed = 1;
+	}
+
+	AVInputFormat* pAVInputFormat = av_find_input_format(streamformat);
+	if( !pAVInputFormat )
+	{
+		DEBUGF("aac: probe failed\n");
+		return -1;
+	}
+	else
+	{
+		DEBUGF("aac: probe ok name:%s lname:%s\n", pAVInputFormat->name, pAVInputFormat->long_name);
+		pAVInputFormat->flags |= AVFMT_NOFILE;
 	}
 
 	AVFormatContext* pFormatCtx;
 	AVCodecContext *pCodecCtx;
 
-	iRC = av_open_input_stream(&pFormatCtx, &ByteIOCtx, "", pAVInputFormat, NULL);
+	iRC = av_open_input_stream(&pFormatCtx, AVIOCtx, "", pAVInputFormat, NULL);
 
 	if (iRC < 0)
 	{
@@ -261,7 +260,7 @@
 				eos=true;
 			}
 
-			if ( url_feof(pFormatCtx->pb) )
+			if ( pFormatCtx->pb->eof_reached )
 			{
 				DEBUGF("aac: url_feof\n");
 				eos=true;