Subversion Repositories Kolibri OS

Rev

Rev 5603 | Rev 6117 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5603 Rev 6106
Line 1... Line 1...
1
#include 
1
#include 
-
 
2
#include 
-
 
3
#include 
2
#include 
4
#include 
3
#include 
5
#include 
4
#include "libswresample/swresample.h"
6
#include 
-
 
7
#include 
Line 5... Line -...
5
 
-
 
6
#include 
-
 
7
#include 
8
 
8
#include "winlib/winlib.h"
9
#include "winlib/winlib.h"
9
#include "sound.h"
10
#include "sound.h"
Line 38... Line 39...
38
    int    err;
39
    int    err;
39
    int    version =-1;
40
    int    version =-1;
40
    char  *errstr;
41
    char  *errstr;
41
 
42
 
Line 42... Line -...
42
    mutex_lock(&driver_lock);
-
 
43
 
-
 
44
    if((err = InitSound(&version)) !=0 )
43
    if((err = InitSound(&version)) !=0 )
45
    {
44
    {
46
        mutex_unlock(&driver_lock);
-
 
47
        errstr = "Sound service not installed\n\r";
45
        errstr = "Sound service not installed\n\r";
48
        goto exit_whith_error;
46
        goto exit_whith_error;
49
    };
47
    };
Line 50... Line -...
50
 
-
 
51
    mutex_unlock(&driver_lock);
-
 
52
 
-
 
53
//    printf("sound version 0x%x\n", version);
-
 
54
 
48
 
55
    if( (SOUND_VERSION>(version&0xFFFF)) ||
49
    if( (SOUND_VERSION>(version&0xFFFF)) ||
56
        (SOUND_VERSION<(version >> 16)))
50
        (SOUND_VERSION<(version >> 16)))
57
    {
51
    {
58
        errstr = "Sound service version mismatch\n\r";
52
        errstr = "Sound service version mismatch\n\r";
Line 104... Line 98...
104
    int len, len2;
98
    int len, len2;
105
    int got_frame;
99
    int got_frame;
106
    int data_size;
100
    int data_size;
107
 
101
 
Line 108... Line -...
108
 
-
 
109
    if( astream.count > 192000*2)
102
    if( astream.count > 192000*2)
110
        return -1;
103
        return -1;
Line 111... Line 104...
111
 
104
 
112
    if( get_packet(qa, &pkt) == 0 )
105
    if( get_packet(qa, &pkt) == 0 )
Line 113... Line -...
113
        return 0;
-
 
114
 
-
 
115
 //          __asm__("int3");
106
        return 0;
116
 
107
 
117
    if (!aFrame)
108
    if (!aFrame)
118
    {
109
    {
119
        if (!(aFrame = avcodec_alloc_frame()))
110
        if (!(aFrame = avcodec_alloc_frame()))
Line 126... Line 117...
126
    while(pkt_tmp.size > 0)
117
    while(pkt_tmp.size > 0)
127
    {
118
    {
128
        data_size = 192000;
119
        data_size = 192000;
Line 129... Line -...
129
 
-
 
130
//        len = avcodec_decode_audio3(ctx,(int16_t*)decoder_buffer,
-
 
131
//                                   &data_size, &pkt_tmp);
120
 
132
        got_frame = 0;
121
        got_frame = 0;
Line 133... Line 122...
133
        len = avcodec_decode_audio4(ctx, aFrame, &got_frame, &pkt_tmp);
122
        len = avcodec_decode_audio4(ctx, aFrame, &got_frame, &pkt_tmp);
134
 
123
 
Line 198... Line 187...
198
 
187
 
Line 199... Line 188...
199
                samples = astream.buffer+astream.count;
188
                samples = astream.buffer+astream.count;
Line 200... Line 189...
200
 
189
 
201
                memcpy(samples, decoder_buffer, data_size);
-
 
202
/*
-
 
Line 203... Line -...
203
            memcpy(samples, aFrame->extended_data[0], plane_size);
-
 
204
 
-
 
205
            if (planar && ctx->channels > 1)
-
 
206
            {
-
 
207
                uint8_t *out = ((uint8_t *)samples) + plane_size;
-
 
208
                for (ch = 1; ch < ctx->channels; ch++)
-
 
209
                {
-
 
210
                    memcpy(out, aFrame->extended_data[ch], plane_size);
-
 
211
                    out += plane_size;
-
 
212
                }
-
 
213
            }
190
                memcpy(samples, decoder_buffer, data_size);
214
*/
191
 
215
                astream.count += data_size;
192
                astream.count += data_size;
216
                mutex_unlock(&astream.lock);
193
                mutex_unlock(&astream.lock);
217
            };
194
            };