2 * Copyright (C) 2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
25 #include "swfdec_audio_load.h"
26 #include "swfdec_debug.h"
27 #include "swfdec_sprite.h"
28 #include "swfdec_tag.h"
31 G_DEFINE_TYPE (SwfdecAudioLoad
, swfdec_audio_load
, SWFDEC_TYPE_AUDIO_STREAM
)
34 swfdec_audio_load_pull (SwfdecAudioStream
*audio
)
36 SwfdecAudioLoad
*stream
= SWFDEC_AUDIO_LOAD (audio
);
38 if (stream
->frame
>= stream
->load
->frames
->len
) {
39 if (stream
->load
->stream
== NULL
)
40 swfdec_audio_stream_done (audio
);
44 return swfdec_buffer_ref (g_ptr_array_index (stream
->load
->frames
, stream
->frame
++));
48 swfdec_audio_load_class_init (SwfdecAudioLoadClass
*klass
)
50 SwfdecAudioStreamClass
*stream_class
= SWFDEC_AUDIO_STREAM_CLASS (klass
);
52 stream_class
->pull
= swfdec_audio_load_pull
;
56 swfdec_audio_load_init (SwfdecAudioLoad
*stream
)
61 swfdec_audio_load_new (SwfdecPlayer
*player
, SwfdecLoadSound
*load
)
63 SwfdecAudioLoad
*stream
;
65 g_return_val_if_fail (SWFDEC_IS_PLAYER (player
), NULL
);
66 g_return_val_if_fail (SWFDEC_IS_LOAD_SOUND (load
), NULL
);
68 stream
= g_object_new (SWFDEC_TYPE_AUDIO_LOAD
, NULL
);
70 swfdec_audio_stream_use_decoder (SWFDEC_AUDIO_STREAM (stream
),
71 SWFDEC_AUDIO_CODEC_MP3
, swfdec_audio_format_new (44100, TRUE
, 2));
73 swfdec_audio_add (SWFDEC_AUDIO (stream
), player
);
75 return SWFDEC_AUDIO (stream
);