Author: miguel
Date: 2007-05-31 14:13:00 -0400 (Thu, 31 May 2007)
New Revision: 78363
Modified:
trunk/moon/configure.ac
trunk/moon/src/video.cpp
Log:
Flush
Modified: trunk/moon/configure.ac
===================================================================
--- trunk/moon/configure.ac 2007-05-31 18:09:29 UTC (rev 78362)
+++ trunk/moon/configure.ac 2007-05-31 18:13:00 UTC (rev 78363)
@@ -9,7 +9,7 @@
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
-LIBS_TO_CHECK="gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale"
+LIBS_TO_CHECK="gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale alsa"
if pkg-config gtk+-2.0; then
echo Gtk+ 2.0 found
@@ -29,10 +29,18 @@
exit 1
fi
-CFLAGS="$CFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat
gthread-2.0 libswscale`"
-CXXFLAGS="$CXXFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat
gthread-2.0 libswscale`"
-LIBS="$LIBS `pkg-config --libs gtk+-2.0 libavcodec libavformat gthread-2.0
libswscale`"
+if pkg-config alsa; then
+ echo Found Alsa
+else
+ echo You are missing ALSA
+ echo looking for the alsa.pc file through pkgconfig.
+ exit 1
+fi
+CFLAGS="$CFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat
gthread-2.0 libswscale alsa`"
+CXXFLAGS="$CXXFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat
gthread-2.0 libswscale alsa`"
+LIBS="$LIBS `pkg-config --libs gtk+-2.0 libavcodec libavformat gthread-2.0
libswscale alsa`"
+
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LIBS)
Modified: trunk/moon/src/video.cpp
===================================================================
--- trunk/moon/src/video.cpp 2007-05-31 18:09:29 UTC (rev 78362)
+++ trunk/moon/src/video.cpp 2007-05-31 18:13:00 UTC (rev 78363)
@@ -34,6 +34,9 @@
#include <sys/time.h>
+// Alsa
+#include <asoundlib.h>
+
Video::Video (const char *filename, double x, double y)
{
this->filename = g_strdup (filename);
@@ -80,7 +83,11 @@
AVStream *video_stream;
int video_stream_idx;
GMutex *video_mutex;
+ AVStream *audio_stream;
+ int audio_stream_idx;
+ snd_pcm_t *pcm;
+
// The decoding thread will wait until the main thread reads our
CMD_INITED
// command
GCond *cond_decode_thread_proceed;
@@ -162,7 +169,7 @@
VideoFfmpeg *video = (VideoFfmpeg *) data;
AVFrame *video_frame;
int i;
- int video_stream_idx;
+ int video_stream_idx, audio_stream_idx;
AVFormatParameters pars;
printf ("Video THREAD STARTS\n");
@@ -190,8 +197,28 @@
for (i = 0; i < video->av_format_context->nb_streams; i++){
AVStream *stream = video->av_format_context->streams [i];
AVCodecContext *cc;
+ int n;
switch (stream->codec->codec_type){
+ case CODEC_TYPE_AUDIO:
+ video->audio_stream_idx = i;
+ video->audio_stream = video->av_format_context->streams
[i];
+ audio_stream_idx = video->audio_stream_idx;
+ cc = video->audio_stream->codec;
+ n = snd_pcm_open (&video->pcm, "default",
SND_PCM_STREAM_PLAYBACK, 0);
+ if (n < 0)
+ printf ("Error, can not initialize audio\n");
+ else {
+ snd_pcm_set_params (
+ video->pcm,
+ SND_PCM_FORMAT_S16,
+ SND_PCM_ACCESS_RW_INTERLEAVED,
+ cc->channels,
+ cc->sample_rate,
+ 1, 0);
+ }
+ break;
+
case CODEC_TYPE_VIDEO:
video->video_codec = avcodec_find_decoder
(stream->codec->codec_id);
video->video_stream = video->av_format_context->streams
[i];
@@ -236,6 +263,10 @@
break;
}
+ if (pkt->stream_index == audio_stream_idx){
+ //snd_pcm_writei (video->pcm,
+ }
+
if (pkt->stream_index == video_stream_idx){
int got_picture, n;
static int count;
@@ -421,11 +452,13 @@
}
static int ffmpeg_inited;
+static snd_pcm_t *pcm;
static void
ffmpeg_init ()
{
if (!ffmpeg_inited){
+
video_lock = g_mutex_new ();
avcodec_init ();
av_register_all ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches