[Haiku-commits] r30987 - in haiku/trunk: headers/os/media src/kits/media

stippi at mail.berlios.de stippi at mail.berlios.de
Sun Jun 7 21:43:27 CEST 2009


Author: stippi
Date: 2009-06-07 21:43:26 +0200 (Sun, 07 Jun 2009)
New Revision: 30987
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30987&view=rev

Modified:
   haiku/trunk/headers/os/media/MediaFile.h
   haiku/trunk/src/kits/media/MediaFile.cpp
Log:
Added BMediaFile::_UnInit() and implemented the two SetTo() methods.


Modified: haiku/trunk/headers/os/media/MediaFile.h
===================================================================
--- haiku/trunk/headers/os/media/MediaFile.h	2009-06-07 19:35:14 UTC (rev 30986)
+++ haiku/trunk/headers/os/media/MediaFile.h	2009-06-07 19:43:26 UTC (rev 30987)
@@ -157,6 +157,7 @@
 			BMediaTrack**		fTrackList;
 
 			void				_Init();
+			void				_UnInit();
 			void				_InitReader(BDataIO* source, int32 flags = 0);
 			void				_InitWriter(BDataIO* source,
 									const media_file_format* mfi, int32 flags);

Modified: haiku/trunk/src/kits/media/MediaFile.cpp
===================================================================
--- haiku/trunk/src/kits/media/MediaFile.cpp	2009-06-07 19:35:14 UTC (rev 30986)
+++ haiku/trunk/src/kits/media/MediaFile.cpp	2009-06-07 19:43:26 UTC (rev 30987)
@@ -78,16 +78,25 @@
 status_t
 BMediaFile::SetTo(const entry_ref* ref)
 {
-	debugger("BMediaFile::SetTo not implemented");
-	return B_OK;
+	CALLED();
+
+	_UnInit();
+	fDeleteSource = true;
+	_InitReader(new (std::nothrow) BFile(ref, O_RDONLY));
+
+	return fErr;
 }
 
 
 status_t
 BMediaFile::SetTo(BDataIO* destination)
 {
-	debugger("BMediaFile::SetTo not implemented");
-	return B_OK;
+	CALLED();
+
+	_UnInit();
+	_InitReader(destination);
+
+	return fErr;
 }
 
 
@@ -95,11 +104,7 @@
 {
 	CALLED();
 
-	ReleaseAllTracks();
-	delete[] fTrackList;
-	delete fExtractor;
-	if (fDeleteSource)
-		delete fSource;
+	_UnInit();
 }
 
 
@@ -360,6 +365,23 @@
 
 
 void
+BMediaFile::_UnInit()
+{
+	ReleaseAllTracks();
+	delete[] fTrackList;
+	fTrackList = NULL;
+	fTrackNum = 0;
+	delete fExtractor;
+	fExtractor = NULL;
+	if (fDeleteSource) {
+		delete fSource;
+		fSource = NULL;
+		fDeleteSource = false;
+	}
+}
+
+
+void
 BMediaFile::_InitReader(BDataIO* source, int32 flags)
 {
 	CALLED();




More information about the Haiku-commits mailing list