From d4244515ae7c205cb100f297f261d4c4a5b00f7a Mon Sep 17 00:00:00 2001 From: darkeye Date: Sat, 19 Oct 2002 13:31:46 +0000 Subject: [PATCH] some cleanup with the open() / close() functions --- darkice/trunk/src/LameLibEncoder.cpp | 17 +++++++++++------ darkice/trunk/src/VorbisLibEncoder.cpp | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/darkice/trunk/src/LameLibEncoder.cpp b/darkice/trunk/src/LameLibEncoder.cpp index a7717f3..3c972fb 100644 --- a/darkice/trunk/src/LameLibEncoder.cpp +++ b/darkice/trunk/src/LameLibEncoder.cpp @@ -70,6 +70,12 @@ LameLibEncoder :: open ( void ) close(); } + // open the underlying sink + if ( !sink->open() ) { + throw Exception( __FILE__, __LINE__, + "lame lib opening underlying sink error"); + } + lameGlobalFlags = lame_init(); // ugly lame returns -1 in a pointer on allocation errors @@ -246,12 +252,6 @@ LameLibEncoder :: open ( void ) lame_print_config( lameGlobalFlags); - // open the underlying sink - if ( !sink->open() ) { - throw Exception( __FILE__, __LINE__, - "lame lib opening underlying sink error"); - } - return true; } @@ -372,6 +372,8 @@ LameLibEncoder :: close ( void ) throw ( Exception ) flush(); lame_close( lameGlobalFlags); lameGlobalFlags = 0; + + sink->close(); } } @@ -384,6 +386,9 @@ LameLibEncoder :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.18 2002/10/19 13:31:46 darkeye + some cleanup with the open() / close() functions + Revision 1.17 2002/10/19 12:22:10 darkeye return 0 immediately for write() if supplied length is 0 diff --git a/darkice/trunk/src/VorbisLibEncoder.cpp b/darkice/trunk/src/VorbisLibEncoder.cpp index f15f532..c6a26aa 100644 --- a/darkice/trunk/src/VorbisLibEncoder.cpp +++ b/darkice/trunk/src/VorbisLibEncoder.cpp @@ -121,6 +121,12 @@ VorbisLibEncoder :: open ( void ) close(); } + // open the underlying sink + if ( !sink->open() ) { + throw Exception( __FILE__, __LINE__, + "vorbis lib opening underlying sink error"); + } + vorbis_info_init( &vorbisInfo); switch ( getOutBitrateMode() ) { @@ -180,12 +186,6 @@ VorbisLibEncoder :: open ( void ) throw Exception( __FILE__, __LINE__, "ogg stream init error", ret); } - // open the underlying sink - if ( !sink->open() ) { - throw Exception( __FILE__, __LINE__, - "vorbis lib opening underlying sink error"); - } - // create an empty vorbis_comment structure vorbis_comment_init( &vorbisComment); @@ -356,6 +356,8 @@ VorbisLibEncoder :: close ( void ) throw ( Exception ) vorbis_info_clear( &vorbisInfo); encoderOpen = false; + + sink->close(); } } @@ -368,6 +370,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.16 2002/10/19 13:31:46 darkeye + some cleanup with the open() / close() functions + Revision 1.15 2002/10/19 12:22:10 darkeye return 0 immediately for write() if supplied length is 0