diff options
Diffstat (limited to 'src/decoder.cc')
-rw-r--r-- | src/decoder.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/decoder.cc b/src/decoder.cc index 3c5a4e8..eae0f76 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -24,7 +24,8 @@ #include "decoder.h" -Decoder::Decoder(char *device, +Decoder::Decoder(Error* err, + char *device, int channel, sem_t *gencode_sem, sem_t *gplayer_sem, @@ -33,6 +34,8 @@ Decoder::Decoder(char *device, pthread_mutex_t *gmutex, volatile int *grunning) { + errobj = err; + encode_sem = gencode_sem; player_sem = gplayer_sem; encode_queue = gencode_queue; @@ -48,7 +51,7 @@ Decoder::Decoder(char *device, memset(&dvpars, 0, sizeof(dvpars)); if(!(iformat = av_find_input_format("dv1394"))) { - fprintf(stderr, "Failed to get input format dv1394\n"); + errobj->setError("Failed to get input format dv1394"); exit(1); } @@ -57,23 +60,23 @@ Decoder::Decoder(char *device, dvpars.standard = "pal"; if(av_open_input_file(&ifc, "", iformat, 0, &dvpars) < 0) { - fprintf(stderr, "Device is in use\n"); + errobj->setError("Device is in use."); fc = NULL; return; } if(av_find_stream_info(ifc) < 0) { - fprintf (stderr, "Could not find enough parameters\n"); + errobj->setError("Could not find enough parameters."); fc = NULL; return; } dump_format(ifc, 1, "", 0); if(!(dec_codec = avcodec_find_decoder(ifc->streams[0]->codec.codec_id))) { - printf("Unsupported codec for input stream \n"); + errobj->setError("Unsupported codec for input stream "); fc = NULL; return; } if(avcodec_open(&ifc->streams[0]->codec, dec_codec) < 0) { - printf("Error while opening codec for input stream\n"); + errobj->setError("Error while opening codec for input stream"); fc = NULL; return; } @@ -89,7 +92,7 @@ Decoder::~Decoder() void Decoder::decode() { if(fc == NULL) { - printf("Decoder not initialized.\n"); + errobj->setError("Decoder not initialized."); return; } @@ -116,13 +119,13 @@ void Decoder::decode() memcpy(dvf->frame, ptr, len); - // fprintf(stderr, "DVBufferSize: [%d]bytes\n", len); + //printf("DVBufferSize: [%d]bytes\n", len); ret = avcodec_decode_video(&fc->streams[0]->codec, fff->frame, &got_picture, ptr, len); if(ret < 0) { - fprintf(stderr, "Error while decoding stream\n"); + errobj->setError("Error while decoding stream"); exit(1); } |